Skip to content

Latest commit

 

History

History
147 lines (90 loc) · 3.9 KB

05-Practice-Test-Deploy-Kubernetes-Cluster-using-Kubeadm.md

File metadata and controls

147 lines (90 loc) · 3.9 KB

Practice Test - Install kubernetes cluster using kubeadm tool

If you have an Apple M1 or M2 (Apple Silicon) machine, then please follow the separate instructions here.

Solutions for practice test - Install Using Kubeadm

  1. Install the kubeadm, kubelet and kubectl packages at exact version 1.24.0 on the controlplane and node01.

    Run the following two steps on both controlplane and node01 (use ssh node01 to get to the worker node).

    1. Configure kernel parameters

      cat <<EOF | tee /etc/modules-load.d/k8s.conf
      br_netfilter
      EOF
      
      cat <<EOF | tee /etc/sysctl.d/k8s.conf
      net.bridge.bridge-nf-call-ip6tables = 1
      net.bridge.bridge-nf-call-iptables = 1
      net.ipv4.ip_forward = 1
      EOF
      sysctl --system
      
    2. Install kubernetes binaries

      apt-get update
      apt-get install -y apt-transport-https ca-certificates curl
      
      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" | tee /etc/apt/sources.list.d/kubernetes.list
      
      apt-get update
      apt-get install -y kubelet=1.24.0-00 kubeadm=1.24.0-00 kubectl=1.24.0-00
      apt-mark hold kubelet kubeadm kubectl
      
  2. What is the version of kubelet installed?

    kubelet --version
    
  3. How many nodes are part of kubernetes cluster currently?

    Are you able to run kubectl get nodes?

    Know that the kubeconfig file installed by kubeadm is located in /etc/kubernetes/admin.conf

    kubectl get nodes --kubeconfig /etc/kubernetes/admin.conf
    

    0

  4. Information only

  5. Initialize controlplane node

    1. Get the IP address of the eth0 adapter of the controlplane

      ifconfig eth0
      

      Take the value printed for inet in the output. This will be something like the following, but can be different each time you run the lab.

      10.13.26.9

    2. Run kubeadm init using the IP address determined above for --apiserver-advertise-address

      kubeadm init \
         --apiserver-cert-extra-sans=controlplane \
         --apiserver-advertise-address 10.13.26.9 \
         --pod-network-cidr=10.244.0.0/16
      
    3. Set up the default kubeconfig file

      mkdir ~/.kube
      cp /etc/kubernetes/admin.conf ~/.kube/config
      
  6. Generate a kubeadm join token

    You can copy the join command output by kubeadm init which looks like

    kubeadm join 10.13.26.9:6443 --token cpwmot.ldhadf3cokvyyx60 \
      --discovery-token-ca-cert-hash sha256:ea3a622922315b14b289c6efd7b1a77cbf81d29f6ddaf03472c304b6d3228c06
    

    Note it will be different each time you do the lab.

  7. Join node01 to the cluster using the join token

    1. ssh onto node01 and paste the join command from above
    2. Return to the controlplane node
    3. Run kubectl get nodes. Note that both nodes are NotReady. This is OK because we have not yet installed networking.
  8. Install a Network Plugin

    1. Install flannel

      kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
      
    2. Wait 30 seconds or so, then run kubectl get nodes. Nodes should now be ready.