DevOps Classroomnotes 01/Jul/2022

kubeadm installation

 kubeadm init --pod-network-cidr=10.244.0.0/16 --cri-socket unix:///var/run/cri-dockerd.sock
  • Once the command is succesful you would get and output
Your Kubernetes control-plane has initialized successfully!

To start using your cluster, you need to run the following as a regular user:

  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config

Alternatively, if you are the root user, you can run:

  export KUBECONFIG=/etc/kubernetes/admin.conf

You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
  https://kubernetes.io/docs/concepts/cluster-administration/addons/

Then you can join any number of worker nodes by running the following on each as root:

kubeadm join 172.31.9.186:6443 --token oc7nyd.g36rl6lycyk15ywl \
        --discovery-token-ca-cert-hash sha256:ef3f2b626d6168b4d2cbb64a044285def92423aa312f37405d49adb31a356815
  • To run kubernetes as a non root user on control plane
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
  • The network of the kuberentes is CNI is implemented by many providers Refer Here
  • When the manual installation of k8s is done, most of the organizations prefer flannel Refer Here
kubectl apply -f https://raw.githubusercontent.com/flannel-io/flannel/master/Documentation/kube-flannel.yml
  • Now login into the node 1 and become a root user and then execute
kubeadm join 172.31.9.186:6443 --token oc7nyd.g36rl6lycyk15ywl \
        --discovery-token-ca-cert-hash sha256:ef3f2b626d6168b4d2cbb64a044285def92423aa312f37405d49adb31a356815
  • Now perform the same on the node 2 by executing the same command shown below as a root user
kubeadm join 172.31.9.186:6443 --token oc7nyd.g36rl6lycyk15ywl \
        --discovery-token-ca-cert-hash sha256:ef3f2b626d6168b4d2cbb64a044285def92423aa312f37405d49adb31a356815
  • Now login into master/control plane and execute kubectl get nodes
    Preview

Kubernetes playground

  • Login into kubernetes playground Refer Here and create two nodes
  • On the node which you choose as control plane/master execute the following commands
You can bootstrap a cluster as follows:

 1. Initializes cluster master node:

 kubeadm init --apiserver-advertise-address $(hostname -i) --pod-network-cidr 10.5.0.0/16


 2. Initialize cluster networking:

kubectl apply -f https://raw.githubusercontent.com/cloudnativelabs/kube-router/master/daemonset/kubeadm-kuberouter.yaml

Preview
* Now join the node2 to cluster and once its done, login into control plane and execute the below commands
Preview

Kubectl cheatsheet

kubectl

  • This is official k8s client
  • Checking cluster status kubectl version
    Preview
  • To check whether your cluster is healthy kubectl get componentstatuses
    Preview
  • kubectl has two primary commands to obtain information
    • get
    • describe
      Preview
      Preview

kube-proxy

  • kube proxy is responsibe for routing network traffic in the k8s cluster. To do this job, the proxy should be present on all the nodes in the cluster
    Preview

kuberenetes DNS

  • kuberentes also runs a DNS server, which provides naming and discovery for the services in k8s cluster
    Preview
  • There is also a k8s service that performs load balancing for the DNS server
    Preview

Note: As of now we are using kubectl from the control plane i.e we login into control plane and use kubectl, when we start using k8s as a service i.e on cloud we would setup kubectl on any machine from where we want to deploy applications.

Leave a Reply

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

About continuous learner

devops & cloud enthusiastic learner