DevOps Classroomnotes 30/Jun/2022

Kubernetes contd….

  • To interact with k8s cluster we have two major options
    • programatically by using REST API with json payloads
    • kubectl command line by using YAML manifests
      Preview
  • When we interact with kubectl we create yaml manifest which has minimum details required where we express what we want rather than how it is done.
  • when we work with clusters especially container clusters we embrace cattle mindset (pet vs cattle)
    Preview

Pods in k8s

  • A Pod is smallest unit of creation in k8s.
  • Container will exist inside Pod.
  • A Pod is collection of application containers and volumes running inside the same execution environment
  • Each container in a pod runs with in its own cgroup, but they share a number of Linux namespaces
  • Each Pod gets a unique IP address in k8s cluster. The containers running inside the Pod share the same Ip Address and port space, have the same host name
    Preview
  • A Pod can have any number of containers, but ideally its not a good idea to run multiple containers in a Pod.
  • A Pod should represent a microservice/application so running one container is considered as best idea.

K8s Installation

  • K8s has wide variety of installation options

    • local machine:
      • minikube
      • kind
      • k3s
      • k3d
      • microk8s
    • Manual cluster installation:
      • kubeadm
    • Automatic cluster installation
      • kubespray
      • kops
      • RKE
      • KubeSphere
      • Kubermatic
    • Managed clusters
      • Azure Kubernetes Service
      • Elastic Kubernetes Service
      • Google Kubernetes Engine
  • We would be using Manual Cluster installation to start with and then move towards Managed clusters
  • Once the k8s is installed in any of the above approaches, we need to create manifests to deploy our applications.

kubeadm single master installation

  • Refer Here for kubeadm installation
  • For practice try playground Refer Here
  • I will be create a 3 node k8s cluster with one master
  • On all the nodes install docker
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
sudo -i
# Run these commands as root
###Install GO###
wget https://storage.googleapis.com/golang/getgo/installer_linux
chmod +x ./installer_linux
./installer_linux
source ~/.bash_profile
git clone https://github.com/Mirantis/cri-dockerd.git
cd cri-dockerd
mkdir bin
go get && go build -o bin/cri-dockerd
mkdir -p /usr/local/bin
install -o root -g root -m 0755 bin/cri-dockerd /usr/local/bin/cri-dockerd
cp -a packaging/systemd/* /etc/systemd/system
sed -i -e 's,/usr/bin/cri-dockerd,/usr/local/bin/cri-dockerd,' /etc/systemd/system/cri-docker.service
systemctl daemon-reload
systemctl enable cri-docker.service
systemctl enable --now cri-docker.socket
usermod -aG docker ubuntu
  • On all the nodes install kubelet, kubeadm and kubectl Refer Here
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
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
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl
  • Next steps: We need to initialize k8s cluster.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About continuous learner

devops & cloud enthusiastic learner