LearnCluster architecture and kubeadm

Tour a kubeadm cluster

A free lab to read. In Gazeek it runs on a real cluster built for you, with each task checked as you go. Register to run it.

You have a one-node kubeadm cluster, control-1: it is the control plane and it also runs your Pods. Before you upgrade, back up or repair a cluster you need to know where its parts live, so this lab is a guided walk around one.

You will find the static Pod manifests that start the control plane, read the Service address range, the kubelet's cgroup driver, the container runtime and the CNI configuration, start a test Pod, ask the API server for its health, and list when the certificates expire. Every answer is saved as a small file under ~/tour/, which the checks read; open them in the Files tab.

Three challenges, eight tasks. Every task shows the command.

  1. Task 1 of 8

    List the static Pod manifests

    Goal: ~/tour/static-pods.txt lists the files in /etc/kubernetes/manifests.

    Do it:

    mkdir -p ~/tour
    sudo ls /etc/kubernetes/manifests | tee ~/tour/static-pods.txt
    kubectl -n kube-system get pods -o wide
    

    You should see: four files, etcd.yaml, kube-apiserver.yaml, kube-controller-manager.yaml and kube-scheduler.yaml, then four Pods in kube-system whose names end in -control-1.

    Why: the Pods with the node's name on the end are mirror Pods: the kubelet started them from those files and shows them to the API server. Delete one with kubectl and it comes straight back; remove the file and it goes. The folder is sudo only because the files hold certificate paths and flags.

  2. Task 2 of 8

    Find the Service address range

    Goal: ~/tour/service-cidr.txt holds the API server's --service-cluster-ip-range, for example 10.96.0.0/12.

    Do it:

    sudo grep -- --service-cluster-ip-range /etc/kubernetes/manifests/kube-apiserver.yaml
    sudo grep -o 'service-cluster-ip-range=[^ "]*' /etc/kubernetes/manifests/kube-apiserver.yaml | cut -d= -f2 | tee ~/tour/service-cidr.txt
    kubectl get service kubernetes
    

    You should see: one range such as 10.96.0.0/12, and the kubernetes Service's CLUSTER-IP inside it (usually the first address, 10.96.0.1).

    Why: every ClusterIP Service gets an address from this range, and it must not overlap the Pod network or the nodes' own network. Exam questions about the cluster's settings are answered from these manifest files.

  3. Task 3 of 8

    Read the kubelet's cgroup driver

    Goal: ~/tour/cgroup-driver.txt holds the kubelet's cgroupDriver from /var/lib/kubelet/config.yaml.

    Do it:

    systemctl status kubelet --no-pager | head -5
    sudo grep cgroupDriver /var/lib/kubelet/config.yaml
    sudo grep cgroupDriver /var/lib/kubelet/config.yaml | awk '{print $2}' | tee ~/tour/cgroup-driver.txt
    

    You should see: the kubelet active (running) as a systemd service, and systemd as the driver.

    Why: the kubelet is the one component that is not a Pod: systemd runs it, and kubeadm writes its settings to /var/lib/kubelet/config.yaml. The kubelet and containerd must use the same cgroup driver (systemd here), or Pods fail in confusing ways.

  4. Task 4 of 8

    Name the container runtime

    Goal: ~/tour/runtime.txt holds the runtime and version the node reports, for example containerd://2.1.4.

    Do it:

    kubectl get node control-1 -o wide
    kubectl get node control-1 -o jsonpath='{.status.nodeInfo.containerRuntimeVersion}' | tee ~/tour/runtime.txt; echo
    sudo crictl ps --name kube-apiserver
    

    You should see: containerd:// and a version, then the API server's container in the crictl list.

    Why: crictl talks to the runtime directly through the CRI, so it works even when the API server does not. It is the tool for a control plane that will not start.

  5. Task 5 of 8

    Find the CNI configuration

    Goal: ~/tour/cni.txt holds the name of the CNI configuration file in /etc/cni/net.d.

    Do it:

    sudo ls -l /etc/cni/net.d/
    sudo ls /etc/cni/net.d/ | grep conflist | tee ~/tour/cni.txt
    kubectl -n kube-system get pods -l k8s-app=calico-node -o wide
    

    You should see: 10-calico.conflist (and a calico-kubeconfig), then one calico-node Pod, Running.

    Why: the kubelet reads the first configuration file in /etc/cni/net.d to know which network plugin sets up each Pod. No file there means no Pod networking, and the node reports NotReady. The folder is readable by root only (Calico keeps its credentials there), hence sudo.

  6. Task 6 of 8

    Start a Pod and read its address

    Goal: a Pod hello in namespace tour, image nginx:1.27-alpine, Running, with its IP saved in ~/tour/pod-ip.txt.

    Do it:

    kubectl create namespace tour
    kubectl -n tour run hello --image=nginx:1.27-alpine
    kubectl -n tour wait --for=condition=Ready pod/hello --timeout=120s
    kubectl -n tour get pod hello -o jsonpath='{.status.podIP}' | tee ~/tour/pod-ip.txt; echo
    

    You should see: pod/hello condition met, then an address such as 10.244.x.y.

    Why: that address came from Calico's pool (the --pod-network-cidr given to kubeadm init), not from the Service range you found in task 2. Pods and Services use different ranges on purpose.

  7. Task 7 of 8

    Ask the API server how it is

    Goal: ~/tour/readyz.txt holds the API server's verbose readiness report.

    Do it:

    kubectl get --raw='/readyz?verbose' | tee ~/tour/readyz.txt
    

    You should see: a list of [+]... ok lines, including [+]etcd ok, ending with readyz check passed.

    Why: /readyz (ready to serve) and /livez (alive) are what the kubelet's probes on the API server use. The verbose form names the failing part, which is quicker than reading logs when etcd is down.

  8. Task 8 of 8

    Check when the certificates expire

    Goal: ~/tour/certs.txt holds the output of kubeadm certs check-expiration.

    Do it:

    sudo kubeadm certs check-expiration | tee ~/tour/certs.txt
    

    You should see: a table of certificates (admin.conf, apiserver, etcd-server and others) with about a year left, then the certificate authorities with about ten years.

    Why: sudo kubeadm certs renew all renews them (then restart the control plane Pods), and kubeadm upgrade apply renews them for you. Knowing where to look is half of an exam question on certificates.

Run it on your own cluster

Register free and start with the taster hours when they are open. Your work is checked task by task.