0% found this document useful (0 votes)
11 views41 pages

Kuber Nates

The Kubernetes Cluster Setup Guide provides step-by-step instructions for setting up a Kubernetes cluster, including system requirements, installation of necessary packages, and configuration of the control plane and worker nodes. It covers deploying a pod network, verifying cluster status, and troubleshooting common issues. The guide concludes with suggestions for advanced features and best practices for maintaining the cluster.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views41 pages

Kuber Nates

The Kubernetes Cluster Setup Guide provides step-by-step instructions for setting up a Kubernetes cluster, including system requirements, installation of necessary packages, and configuration of the control plane and worker nodes. It covers deploying a pod network, verifying cluster status, and troubleshooting common issues. The guide concludes with suggestions for advanced features and best practices for maintaining the cluster.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

Kubernetes Cluster Setup Guide

Table of Contents

1. Introduction

2. System Requirements & Prerequisites

3. Installing Required Packages

4. Initializing the Control Plane

5. Adding Worker Nodes

6. Deploying the Pod Network

7. Verifying Cluster Status

8. Deploying a Sample Application

9. Troubleshooting Common Issues

10. Conclusion

1. Introduction

Overview
Kubernetes is an open-source container orchestration platform designed to automate the deployment, scaling, and management of containerized
applications. It allows organizations to run applications e iciently across multiple nodes, ensuring high availability, scalability, and fault tolerance.
Kubernetes is widely used in cloud environments and supports various networking, storage, and security configurations.

Setting up a Kubernetes cluster provides a centralized platform to manage workloads, making it easier to deploy and maintain applications. By
configuring a cluster with a master node and worker nodes, users can take advantage of Kubernetes features like self-healing, load balancing, rolling
updates, and automated scaling.

Architecture

I have used below Architecture for the setup:

 Number of nodes (1 Master, 2 Worker Nodes)

 Kubernetes version used

o Kubernetes v1.32

 Network Plugin

o Flannel - an overlay network provider that can be used with Kubernetes.



2. System Requirements & Prerequisites

List system requirements:

 OS Version - Ubuntu 22.04.2 LTS

 Hardware Specifications (CPU, RAM, Storage)

o CPU: Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz

o RAM: 4 GB

o Storage: 30G

 Network Configuration

o Single Adaptor configured with 192.168.95.14 ip

Prerequisite Configurations

 Update System Packages (perform on all machines)


 Disable Swap (perform on all machines)

o The default behavior of a kubelet is to fail to start if swap memory is detected on a node. This means that swap should either be disabled
or tolerated by kubelet.

 Enable IP Forwarding (perform on all machines)

o Kubernetes networking required IP forwarding to be enabled in kernel. Perform below steps to enable it in kernel.

3. Installing Required Packages

Download the public signing key for the Kubernetes package Repositories. (Perform on all Machines)

Add the appropriate Kubernetes apt repository (Perform on all Machines)


Install Kubernetes Components

sudo apt install -y kubeadm kubelet kubectl


Verify the Kubeadm installation

Install Docker/Container Runtime

sudo apt update && sudo apt install -y containerd


Configuring a cgroup driver

To check the current cgroup driver:


kubelet --version

To change the driver if needed, update the config:


sudo sed -i 's/systemd/cgroupfs/g' /etc/containerd/config.toml
sudo systemctl restart containerd kubelet

Verify that both Container run time and Kubelet have a same cgroup drive. It will be either “systemd” or “cgroup”. By default it will be system

Configuring containerd runtime to use systemd as a cgroup driver

Create a directory containerd inside /etc

Verify the value of “SystemdCgroup = true” under [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options] using containerd


config default cmd (by default value will not be present)
Create a file called config.toml inside /etc/containerd and pass the argument to add value as “SystemdCgroup = true” under
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
Once execute verify the value:
Restart the containerd service to apply the changes

4. Initializing the Control Plane


Run Kubeadm Init Command

sudo kubeadm init --apiserver-advertise-address=<Master-IP> --pod-network-cidr=10.244.0.0/16


Configure kubectl for Admin User

mkdir -p $HOME/.kube

sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

sudo chown $(id -u):$(id -g) $HOME/.kube/config

Verify the installation:


NOTE: controlnode status will be “NotReady” till the time you configured Network based pod. You must deploy a Container Network Interface (CNI)
based Pod network add-on so that your Pods can communicate with each other. Cluster DNS (CoreDNS) will not start up before a network is
installed.

5. Deploying the Pod Network

Install Flannel Network Plugin


Flannel is chosen as the CNI plugin because it provides a simple, reliable overlay network using VXLAN tunnels. It helps Kubernetes pods
communicate across nodes by encapsulating network tra ic.

kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml


NOTE: when I tried to create flanner network pod, it was failed to start because “br_netfilter” kernel module was missing and “bridge-nf-call-iptables”
configuration was also missing. You can see below steps of troubleshooting.
 I check the logs why pod was not starting
 Load the “br_netfilter” module in kernel

 Above setting will be revoked after restart, so make it persistent and enable bridge tra ic filtering

 Adding settings to sysctl.conf file so that it will make persistent. And apply the changes

 Verify the output


 Now delete the pods, it will create again and works
Check the node status
6. Adding Worker Nodes

Retrieve Join Command

kubeadm token create --print-join-command

Run Join Command on Worker Nodes

sudo kubeadm join <Master-IP>:6443 --token <TOKEN> --discovery-token-ca-cert-hash sha256:<HASH>


NOTE:

If swap space is not disabled on worker nodes and ip_forwarding was not enabled the worker node will not able to join the master node.
See the below error:
You need to swapo and enable the ip_forwarding to solve the issues.
7. Verifying Cluster Status

Check Node Status

kubectl get nodes

Check System Pods

kubectl get pods -A

8. Deploying a Sample Application


Create Deployment

kubectl create deployment nginx --image=nginx

Expose the Application

kubectl expose deployment nginx --type=NodePort --port=80

(Include screenshots of deployment and service creation)

9. Troubleshooting Common Issues

 Node Not Ready: Check kubectl describe node <node-name>

Additional Troubleshooting Steps:


1. Check kubelet logs:
journalctl -u kubelet -f

2. Verify API server connectivity:


nc -vz <master-ip> 6443

 Pods Stuck in Pending: Check kubectl describe pod <pod-name>

 Network Issues: Verify sysctl net.bridge.bridge-nf-call-iptables

10. Conclusion

Congratulations! You have successfully set up a Kubernetes cluster with a control plane and worker nodes, deployed a networking solution, and
verified the cluster’s health. This guide provided step-by-step instructions on:
 Installing and configuring Kubernetes components.

 Setting up a control plane and adding worker nodes.

 Deploying a pod network for inter-pod communication.

 Verifying cluster status and ensuring nodes are ready.

 Running a sample application to validate the setup.

With the cluster up and running, you can now explore advanced Kubernetes features, such as:

 Deploying Stateful Applications – Learn how to manage databases and persistent storage with Persistent Volumes (PVs) and Persistent
Volume Claims (PVCs).

 Implementing Ingress Controllers – Set up ingress controllers to expose applications via custom domain names.

 Securing the Cluster – Apply Role-Based Access Control (RBAC), Network Policies, and Pod Security Standards.

 Monitoring & Logging – Use Prometheus, Grafana, and Fluentd to monitor and analyze cluster activity.

 Scaling & Auto-healing – Learn about Horizontal Pod Autoscaler (HPA) and cluster auto-scaling.

This Kubernetes setup lays the foundation for container orchestration and microservices deployment. As a next step, consider integrating CI/CD
pipelines and service mesh technologies like Istio to enhance cluster e iciency.

Keep experimenting, deploying, and optimizing your Kubernetes cluster for real-world workloads!

Next Steps:
**Backup and Disaster Recovery** - Use `etcdctl snapshot save` to back up etcd.
**Upgrading Kubernetes** - Follow best practices for updating Kubernetes versions.
**Setting Up Monitoring** - Implement Prometheus and Grafana for cluster monitoring.
Appendix

This Kubernetes Cluster Setup Guide is intended for educational purposes only. The content, including commands, configurations, and
explanations, is meant to help learners understand and deploy Kubernetes in a controlled environment.

Unauthorized copying, redistribution, or commercial use of this guide is strictly prohibited. If you wish to use this content for any purpose beyond
personal learning, please seek permission.

For inquiries, collaboration, or further assistance, feel free to reach out to:

Tausif Shaikh
Email: shaikh.only@gmail.com
Contact: +91 99244 25668

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy