Kubernetes
- Production-Grade Container Orchestration
- History:
- Google had a project called as borg and later omega which they use for their internal applications.
- Google built a project based on learnings in borg and omega in golang they called it as kubernetes (k8s).
- This project was donated to CNCF
- As of now k8s is defacto container orchestration system.
Basic Architecture
- K8s is a cluster which is one or more nodes
-
K8s cluster have two types of nodes
- Master Node(s):
- Manage the cluster
- Node(s):
- Run the workloads (applications)

- Run the workloads (applications)
- Master Node(s):
- Refer Here for master and node components
-
K8s Master Node Components
-
K8s Node Components
-
K8s always tries to maintain a desired state.
K8s interfaces for extensability
- k8s when it started used to support only docker as container technology.
- K8s to call docker used to have lots of code
dockershimwhich was part of k8s release. - K8s has introduced a standard called CRI (Container Runtime Interface). Any container technology can be used in k8s as Container Runtime if it has CRI.
- K8s also has
- CNI (Container Network Interface)
- CSI (Container Storage Interface)
Options for using k8s
- Self-Hosted/On-prem:
- Install on your own servers
- Cloud-Hosted (Managed) k8s:
- Azure AKS
- Google GKE
- AWS EKS
- Single Host k8s (Developers):
- minikube
- kind
Installing k8s
- To Install k8s we need atleast two nodes
- master node
- node
- Installing k8s using kubeadm and Refer Here for installation guide
- In the class i have used Azure
- Create two vms in same network and ensure they have atleast 2 vCPUs and 2 GB of RAM.
- Installing container runtime on all nodes Refer Here
- For this installation lets use containerd
sudo apt update
sudo apt install -y curl gnupg2 software-properties-common apt-transport-https ca-certificates
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/docker.gpg
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update
sudo apt install -y containerd.io
containerd config default | sudo tee /etc/containerd/config.toml >/dev/null 2>&1
sudo sed -i 's/SystemdCgroup = false/SystemdCgroup = true/g' /etc/containerd/config.toml
sudo systemctl restart containerd
sudo systemctl enable containerd
- Now install the following kubelet, kubectl and kubeadm on all nodes
sudo apt-get update
# apt-transport-https may be a dummy package; if so, you can skip that package
sudo apt-get install -y apt-transport-https ca-certificates curl gpg
# If the directory `/etc/apt/keyrings` does not exist, it should be created before the curl command, read the note below.
# sudo mkdir -p -m 755 /etc/apt/keyrings
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.33/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.33/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl
Now lets create a k8s cluster
- Refer Here
- Change the ip forward settings on all nodes
vi /etc/sysctl.conf
# see the image below and uncomment the highlighted line
sudo sysctl -p

* on the master node execute as sudo or root user
kubeadm init

- Now login into node as root user and run the kubeadm join command from above image

- As of now nodes are not ready due to CNI not being installed. lets install weavenet
kubectl apply -f https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s.yaml

