CKA: Cluster Architecture, Installation and Configuration
25% of the CKA exam, 8 competencies. Back to the CKA overview.
Each competency lists what to know and the official documentation to read, then a demo you can run. Demos run on the demo lab, a throwaway kind cluster on your own machine; set it up once before you start.
Manage role based access control (RBAC)
Section titled “Manage role based access control (RBAC)”Know
- Roles and ClusterRoles define verbs on resources; RoleBindings and ClusterRoleBindings grant them.
kubectl auth can-i --astests the result.
Read
Demo: A read-only user for one namespace
-
Create a namespace for this demo and make it the default for your context.
Terminal window kubectl create namespace cka-rbackubectl config set-context --current --namespace=cka-rbac -
Create a service account, a Role that can only read pods, and a RoleBinding.
Terminal window kubectl create serviceaccount viewerkubectl create role pod-reader --verb=get,list,watch --resource=pods,pods/logkubectl create rolebinding viewer-reads-pods --role=pod-reader --serviceaccount=cka-rbac:viewer -
Check what it can do without logging in as it.
Terminal window kubectl auth can-i list pods --as=system:serviceaccount:cka-rbac:viewerkubectl auth can-i delete pods --as=system:serviceaccount:cka-rbac:viewerkubectl auth can-i list pods -n default --as=system:serviceaccount:cka-rbac:viewerkubectl auth can-i --list --as=system:serviceaccount:cka-rbac:viewer -
Now use its token from a kubeconfig of its own, so your admin certificate isn’t sent along.
Terminal window kubectl config view --minify --raw -o jsonpath='{.clusters[0].cluster.certificate-authority-data}' | base64 -d > ca.crtSERVER=$(kubectl config view --minify -o jsonpath='{.clusters[0].cluster.server}')kubectl config set-cluster lab --server="$SERVER" --certificate-authority=ca.crt --embed-certs=true --kubeconfig=viewer.kubeconfigkubectl config set-credentials viewer --token="$(kubectl create token viewer --duration=10m)" --kubeconfig=viewer.kubeconfigkubectl config set-context viewer --cluster=lab --user=viewer --namespace=cka-rbac --kubeconfig=viewer.kubeconfigkubectl --kubeconfig=viewer.kubeconfig --context=viewer get podskubectl --kubeconfig=viewer.kubeconfig --context=viewer delete pod anything
What you should see: Only list in its own namespace is allowed. With the viewer’s kubeconfig, get pods works and delete fails with pods "anything" is forbidden: User "system:serviceaccount:cka-rbac:viewer" cannot delete resource "pods". Don’t pass --token on top of the admin kubeconfig to test this: the admin client certificate is still sent and authenticates you as admin.
Clean up:
rm -f ca.crt viewer.kubeconfigkubectl config set-context --current --namespace=defaultkubectl delete namespace cka-rbacPractise
- Create a ServiceAccount that can only list pods in one namespace and prove it with
kubectl auth can-i.
On this site
Prepare underlying infrastructure for installing a Kubernetes cluster
Section titled “Prepare underlying infrastructure for installing a Kubernetes cluster”Know
- Each node needs a container runtime with a matching cgroup driver, swap handled per the kubelet configuration, the required kernel modules and sysctls, and open ports between nodes.
Read
Demo: Check a node the way kubeadm does
-
A kind node is a container, but it has what a real node needs. Look at each prerequisite.
Terminal window docker exec kind-worker sh -c 'swapon --show; echo "swap lines above (none expected)"'docker exec kind-worker cat /proc/sys/net/ipv4/ip_forwarddocker exec kind-worker stat -fc %T /sys/fs/cgroupdocker exec kind-worker grep -i SystemdCgroup /etc/containerd/config.tomldocker exec kind-worker grep -i cgroupDriver /var/lib/kubelet/config.yaml -
List the images a control plane needs, as you would before an air-gapped install.
Terminal window docker exec kind-control-plane kubeadm config images list
What you should see: No swap, IP forwarding is 1, cgroups are cgroup2fs, and containerd and the kubelet agree on the systemd cgroup driver. Those are the checks you do by hand on a VM before kubeadm init; a mismatched cgroup driver is a classic cause of a kubelet that won’t stay up.
Note: kind shares the host kernel, so kernel modules and sysctls come from your machine. On real VMs you set them yourself; follow the kubeadm install page linked above.
Create and manage Kubernetes clusters using kubeadm
Section titled “Create and manage Kubernetes clusters using kubeadm”Know
kubeadm initbootstraps the control plane;kubeadm joinadds nodes with a token and CA hash. A CNI must be installed before nodes become Ready.
Read
Demo: Read what kubeadm built
-
kind uses kubeadm under the hood. Look at the configuration it used and the files it wrote.
Terminal window kubectl get configmap kubeadm-config -n kube-system -o jsonpath='{.data.ClusterConfiguration}'docker exec kind-control-plane ls /etc/kubernetes /etc/kubernetes/pki -
Check certificate expiry and print a join command.
Terminal window docker exec kind-control-plane kubeadm certs check-expirationdocker exec kind-control-plane kubeadm token create --print-join-commanddocker exec kind-control-plane kubeadm token list
What you should see: The ClusterConfiguration uses kubeadm.k8s.io/v1beta4. Certificates are valid for one year and the CA for ten. The join command contains a bootstrap token that expires after 24 hours, plus the CA hash a new node uses to trust the control plane.
Note: To practise kubeadm init and join end to end, use two or three VMs and the official “Creating a cluster with kubeadm” page; kind can’t show the install itself.
Practise
- Build a two-node cluster with kubeadm on VMs and install a CNI.
Manage the lifecycle of Kubernetes clusters
Section titled “Manage the lifecycle of Kubernetes clusters”Know
- Upgrade one minor version at a time: control plane first (
kubeadm upgrade plan,apply), then drain, upgrade, and uncordon each node. Back up etcd before you start.
Read
- Upgrading kubeadm clusters
- Operating etcd clusters for Kubernetes
- Certificate management with kubeadm
Demo: Plan an upgrade and back up etcd
-
See what an upgrade would do. On a real control plane you would follow this with
kubeadm upgrade apply.Terminal window docker exec kind-control-plane kubeadm upgrade plan 2>&1 | tail -20kubectl version -
Take an etcd snapshot. The etcd image has no shell, so call
etcdctldirectly.Terminal window kubectl -n kube-system exec etcd-kind-control-plane -- etcdctl \--endpoints=https://127.0.0.1:2379 \--cacert=/etc/kubernetes/pki/etcd/ca.crt \--cert=/etc/kubernetes/pki/etcd/server.crt \--key=/etc/kubernetes/pki/etcd/server.key \snapshot save /var/lib/etcd/demo-snapshot.dbdocker exec kind-control-plane ls -lh /var/lib/etcd/demo-snapshot.dbkubectl -n kube-system exec etcd-kind-control-plane -- etcdutl snapshot status /var/lib/etcd/demo-snapshot.db -w table -
The node side of an upgrade: drain, upgrade the kubelet, uncordon. Practise the drain part here.
Terminal window kubectl drain kind-worker --ignore-daemonsets --delete-emptydir-datakubectl get nodeskubectl uncordon kind-worker
What you should see: upgrade plan lists component versions and what it could move to (it needs internet access to look up versions). The snapshot status table shows a hash, revision, and key count. The snapshot is written to /var/lib/etcd, which is a host path, so it survives the etcd container restarting.
Clean up:
docker exec kind-control-plane rm -f /var/lib/etcd/demo-snapshot.dbPractise
- Take an etcd snapshot with
etcdctl snapshot saveand restore it to a new data directory.
On this site
Implement and configure a highly-available control plane
Section titled “Implement and configure a highly-available control plane”Know
- Multiple control plane nodes behind a load balancer for the API server, with stacked or external etcd. etcd needs an odd number of members for quorum.
Read
Demo: A three-node control plane on kind
-
Create a separate cluster with three control plane nodes.
Terminal window cat > ha.yaml <<'EOF'kind: ClusterapiVersion: kind.x-k8s.io/v1alpha4nodes:- role: control-plane- role: control-plane- role: control-plane- role: workerEOFkind create cluster --name ha --config ha.yaml --image kindest/node:v1.37.0@sha256:a1ed56cfb0e7b93589bdf97c8cd566405a265939e3620fc4f5de89adff580ae5kubectl --context kind-ha get nodes -
See the load balancer in front of the API servers, and the stacked etcd members.
Terminal window docker ps --filter name=ha-external-load-balancer --format '{{.Names}} {{.Ports}}'kubectl --context kind-ha get pods -n kube-system -l component=etcd -o widekubectl --context kind-ha -n kube-system exec etcd-ha-control-plane -- etcdctl --endpoints=https://127.0.0.1:2379 \--cacert=/etc/kubernetes/pki/etcd/ca.crt --cert=/etc/kubernetes/pki/etcd/server.crt --key=/etc/kubernetes/pki/etcd/server.key \member list -w table -
Stop one control plane node and keep working.
Terminal window docker stop ha-control-plane2kubectl --context kind-ha create deployment survive --image=registry.k8s.io/e2e-test-images/agnhost:2.66.1 -- /agnhost pausekubectl --context kind-ha get deployment survive
What you should see: Three etcd members, one per control plane node (stacked topology), behind a load balancer container. With one node stopped, etcd still has quorum (2 of 3) and the API keeps working. Stop a second one and writes fail: that is why HA needs an odd number, at least three.
Clean up:
kind delete cluster --name ha && rm -f ha.yamlkubectl config use-context kind-kindUse Helm and Kustomize to install cluster components
Section titled “Use Helm and Kustomize to install cluster components”Know
- Helm installs charts with values (
helm install,upgrade,rollback). Kustomize layers overlays on base YAML and is built intokubectl apply -k.
Read
Demo: The same component two ways
-
Create a namespace for this demo and make it the default for your context.
Terminal window kubectl create namespace cka-kustomizekubectl config set-context --current --namespace=cka-kustomize -
Helm: inspect a chart before installing it. (The lab setup already installed metrics-server this way.)
Terminal window helm list -Ahelm get values metrics-server -n kube-systemhelm show values metrics-server/metrics-server --version 3.14.0 | head -30helm template metrics-server metrics-server/metrics-server --version 3.14.0 -n kube-system | grep -c '^kind:' -
Kustomize: patch upstream YAML without editing it.
Terminal window mkdir -p kz && cat > kz/kustomization.yaml <<'EOF'apiVersion: kustomize.config.k8s.io/v1beta1kind: Kustomizationnamespace: cka-kustomizeresources:- deploy.yamllabels:- pairs:team: platformincludeSelectors: falsepatches:- target:kind: Deploymentname: webpatch: |-- op: replacepath: /spec/replicasvalue: 3EOFcat > kz/deploy.yaml <<'EOF'apiVersion: apps/v1kind: Deploymentmetadata:name: webspec:replicas: 1selector:matchLabels:app: webtemplate:metadata:labels:app: webspec:containers:- name: appimage: registry.k8s.io/e2e-test-images/agnhost:2.66.1args: ["netexec", "--http-port=8080"]EOFkubectl kustomize kz/kubectl apply -k kz/kubectl get deployment web --show-labels
What you should see: helm template renders every object the chart would create, without a cluster. kubectl kustomize prints the patched YAML: 3 replicas and a team: platform label, while deploy.yaml still says 1. Kustomize is built into kubectl; Helm is a separate binary.
Clean up:
rm -rf kzkubectl config set-context --current --namespace=defaultkubectl delete namespace cka-kustomizePractise
- Install a chart with a custom values file, then render the same chart with
helm templateand compare.
Understand extension interfaces (CNI, CSI, CRI, etc.)
Section titled “Understand extension interfaces (CNI, CSI, CRI, etc.)”Know
- CRI connects the kubelet to runtimes, CNI configures pod networking, CSI connects storage. Each is a plugin contract, so implementations are swappable.
Read
Demo: Find each interface on a running node
-
CRI: the kubelet talks to containerd over a socket.
Terminal window docker exec kind-worker sh -c 'grep -h -i runtime /var/lib/kubelet/config.yaml /var/lib/kubelet/kubeadm-flags.env'docker exec kind-worker crictl version -
CNI: plugin binaries and configuration live in well-known directories.
Terminal window docker exec kind-worker ls /opt/cni/bindocker exec kind-worker sh -c 'cat /etc/cni/net.d/*' -
CSI: which drivers are registered, and what provisions volumes in kind.
Terminal window kubectl get csidriverskubectl get storageclass -o custom-columns=NAME:.metadata.name,PROVISIONER:.provisioner
What you should see: containerd answers on the CRI socket, kindnet’s config sits in /etc/cni/net.d, and there are no CSI drivers: kind’s standard class uses the local-path provisioner, which isn’t a CSI driver. On a cloud cluster kubectl get csidrivers lists the cloud’s disk and file drivers.
Understand CRDs, install and configure operators
Section titled “Understand CRDs, install and configure operators”Know
- A CustomResourceDefinition adds a new API type; an operator is a controller that manages applications through custom resources.
Read
Demo: Add a resource type and use it
-
Create a namespace for this demo and make it the default for your context.
Terminal window kubectl create namespace cka-crdkubectl config set-context --current --namespace=cka-crd -
Create a CustomResourceDefinition.
Terminal window kubectl apply -f - <<'EOF'apiVersion: apiextensions.k8s.io/v1kind: CustomResourceDefinitionmetadata:name: backups.demo.brokeninprod.comspec:group: demo.brokeninprod.comscope: Namespacednames:plural: backupssingular: backupkind: BackupshortNames: ["bk"]versions:- name: v1served: truestorage: trueschema:openAPIV3Schema:type: objectproperties:spec:type: objectrequired: ["schedule"]properties:schedule:type: stringretainDays:type: integerminimum: 1EOFkubectl get crd backups.demo.brokeninprod.com -
Create objects of the new kind, including an invalid one.
Terminal window kubectl apply -f - <<'EOF'apiVersion: demo.brokeninprod.com/v1kind: Backupmetadata:name: nightlyspec:schedule: "0 2 * * *"retainDays: 7EOFkubectl get bkkubectl explain backup.speckubectl apply -f - <<'EOF'# expected to fail: schedule is missing and retainDays is below the minimumapiVersion: demo.brokeninprod.com/v1kind: Backupmetadata:name: brokenspec:retainDays: 0EOF
What you should see: kubectl get bk works like any built-in type and explain reads your schema. The invalid object is rejected with errors for the missing schedule and retainDays below 1. A CRD only stores data; an operator is the controller that watches these objects and acts on them.
Clean up:
kubectl delete crd backups.demo.brokeninprod.comkubectl config set-context --current --namespace=defaultkubectl delete namespace cka-crdPractise
- Install an operator from its manifests and list the CRDs it added with
kubectl get crd.
On this site
Domain and competency names are from the CNCF CKA curriculum (v1.37), cncf/curriculum, licensed CC BY 4.0. Summaries, demos, and exercises are original to this site.