How To Setup Kubernetes Cluster Using Kubeadm
What is Kubeadm?
Kubeadm is a tool to set up a minimum viable Kubernetes cluster without much complex configuration. Also, Kubeadm makes the whole process easy by running a series of prechecks to ensure that the server has all the essential components and configs to run Kubernetes.
It is developed and maintained by the official Kubernetes community. There are other options like minikube, kind, etc., that are pretty easy to set up.
- Install docker fallow the link check for different flavours
| Platform | x86_64 / amd64 | arm64 / aarch64 | arm (32-bit) | s390x |
|---|---|---|---|---|
| CentOS | ||||
| Debian | ||||
| Fedora | ||||
| Raspbian | ||||
| RHEL | ||||
| SLES | ||||
| Ubuntu | ||||
| Binaries |
- Install kubelet kubeadm kubectl
Debian Family Update the apt package index and install packages needed to use the Kubernetes apt repository:
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl
Download the Google Cloud public signing key:
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
Add the Kubernetes apt repository:
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
Update apt package index, install kubelet, kubeadm and kubectl, and pin their version:
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl
Update the
aptpackage index and install packages needed to use the Kubernetesaptrepository:sudo apt-get update sudo apt-get install -y apt-transport-https ca-certificates curlDownload the Google Cloud public signing key:
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpgAdd the Kubernetes
aptrepository:echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.listUpdate
aptpackage index, install kubelet, kubeadm and kubectl, and pin their version:sudo apt-get update sudo apt-get install -y kubelet kubeadm kubectl sudo apt-mark hold kubelet kubeadm kubectl
cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-\$basearch
enabled=1
gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
exclude=kubelet kubeadm kubectl
EOF
# Set SELinux in permissive mode (effectively disabling it)
sudo setenforce 0
sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
sudo yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
sudo systemctl enable --now kubelet
On Master Node:
Initialize Kubernetes Cluster
kubeadm initCreate a user for kubernetes administration and copy kube config file.
mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/configDeploy Calico network as a kubeadmin user.
This should be executed as a user (heare as a kubeadmin )
curl https://docs.projectcalico.org/manifests/calico-typha.yaml -o calico.yaml kubectl apply -f calico.yamlCluster join command
kubeadm token create --print-join-command
On Worker Node:
Add worker nodes to cluster
Use the output from kubeadm token create command in previous step from the master server and run here.
look like this
kubeadm join 172.31.24.89:6443 ....
Verifying the cluster To Get Nodes status
kubectl get nodesTo Get component status
kubectl get cs

Comments
Post a Comment