There are no items in your cart
Add More
Add More
Item Details | Price |
---|
Fri Oct 27, 2023
Kubernetes is an open-source container orchestration platform that has gained immense popularity for its ability to manage containerized applications effortlessly. To set up a Kubernetes cluster, you'll need a tool like Kubeadm, which simplifies the process of bootstrapping a cluster and automating much of the tedious work.
In this blog, we'll explore what Kubeadm is, why you should use it, and provide a detailed guide on setting up a Kubernetes cluster with one control-plane and two worker nodes on AWS.
Kubeadm is a command-line tool that makes it easy to initialize, manage, and upgrade a Kubernetes cluster. It is part of the Kubernetes project and is designed to simplify cluster provisioning and deployment.
Kubeadm offers several advantages when it comes to setting up a Kubernetes cluster:
Now, let's dive into the step-by-step guide to set up a Kubernetes cluster with one control plane and two worker nodes on AWS using Kubeadm.
sudo su -
Kubernetes requires disabling swap to work correctly. You can do this on each node by editing the file:/etc/fstab
file.
sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
swapoff -aDisabling swap when installing Kubernetes is necessary because swap can lead to unpredictable resource usage, performance issues, and instability within the Kubernetes cluster. Kubernetes relies on precise control over system resources for efficient container management, and swap can disrupt this control.
cat <<EOF | sudo tee /etc/modules-load.d/k8s.confoverlaybr_netfilterEOFsudo modprobe overlaysudo modprobe br_netfilter
# sysctl params required by setup, params persist across rebootscat <<EOF | sudo tee /etc/sysctl.d/k8s.confnet.bridge.bridge-nf-call-iptables = 1net.bridge.bridge-nf-call-ip6tables = 1net.ipv4.ip_forward = 1EOF
# Apply sysctl params without rebootsudo sysctl --system
lsmod | grep br_netfilterlsmod | grep overlay
Verify that the net.bridge.bridge-nf-call-iptables, net.bridge.bridge-nf-call-ip6tables, and net.ipv4.ip_forward system variables are set to 1 in your sysctl
sysctl net.bridge.bridge-nf-call-iptables net.bridge.bridge-nf-call-ip6tables net.ipv4.ip_forward
apt-get install -y containerd
Create default configuration
mkdir -p /etc/containerd containerd config default > /etc/containerd/config.tomlEdit the configuration to set up CGroups
vi /etc/containerd/config.tomlRestart contained
systemctl restart containerd
Update the apt package index and install packages needed to use the Kubernetes apt repository:
Download the public signing key for the Kubernetes package repositories. The same signing key is used for all repositories so you can disregard the version in the URL:sudo apt-get update# apt-transport-https may be a dummy package; if so, you can skip that packagesudo apt-get install -y apt-transport-https ca-certificates curl gpg
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.28/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpgAdd the appropriate Kubernetes apt repository.
Update the apt package index, install kubelet, kubeadm and kubectl, and pin their version:# This overwrites any existing configuration in /etc/apt/sources.list.d/kubernetes.listecho 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.28/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
Configure crictlsudo apt-get updatesudo apt-get install -y kubelet kubeadm kubectlsudo apt-mark hold kubelet kubeadm kubectl
crictl config \--set runtime-endpoint=unix:///run/containerd/containerd.sock \--set image-endpoint=unix:///run/containerd/containerd.sock
sudo su -
kubeadm init --apiserver-advertise-address <controlplane ip> --pod-network-cidr=10.244.0.0/16
mkdir -p $HOME/.kubesudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/configsudo chown $(id -u):$(id -g) $HOME/.kube/config
kubectl apply -f https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s.yaml
You can easily add worker nodes to your Kubernetes cluster by executing the following command on the worker nodes.
The token required for this operation is generated on the control-plane node:
kubeadm join --token <token> <control-plane-host>:<control-plane-port> --discovery-token-ca-cert-hash sha256:<hash>
kubectl get no # To list all the nodes
kubectl get pods -A # To list all pods from all namespaces.
Kubeadm is a fantastic tool for simplifying the setup of Kubernetes clusters, and in this blog, we've shown you how to create one control-plane and two worker nodes on AWS.
I hope you enjoyed reading this blog and found it informative. If you have any questions or topics you'd like us to cover in future blogs, please don't hesitate to connect with me on LinkedIn.
Thank you for joining us on this Kubernetes journey,