Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
$ als gewone gebruiker# als root (of met sudo)
What the course covers
The parts of a Kubernetes cluster and the job of each part.
- How to install a cluster with kubeadm.
- How to back up etcd, upgrade a cluster, and fix a broken node.
- How to run Pods, ReplicaSets, Deployments, and StatefulSets.
- How to limit CPU and memory, and how to give users access.
- How to store data that must outlive a Pod.
- How to connect apps with Services, Ingress, and CoreDNS.
- How to extend Kubernetes with CRDs, Helm, and Kustomize.
Welcome to Alta3 Research Labs!
This is a self-paced lab. You work in a browser and a Linux shell.
- The lab machines are
bchd(beachhead),controller,node-1, andnode-2. - Helper commands such as
setup <lab>prepare each lab for you.
Required Tools
Vim is a modal editor. Start in command mode, press i to type, and use Esc then :wq to save and quit.
- tmux splits one terminal into panes. You can watch a command in one pane and edit files in another.
- Both tools speed up your work at the terminal.
Becoming a Certified Kubernetes Administrator
The exam is task based. You work on a real cluster.
- The objectives and their weights: cluster architecture 25%, workloads 15%, services and networking 20%, storage 10%, troubleshooting 30%.
- You may open kubernetes.io during the exam. Practice finding pages fast.
- A good method: search the docs, copy an example, then change it to fit the task. Stop looking when the task is solved.
Introduction to Cluster Architecture
A cluster has a control plane and worker nodes.
- The control plane stores cluster state and decides where Pods run. Worker nodes run the Pods.
- One Pod holds one or more containers and shares one network space.
Cluster Building with Kubeadm
Check the machine first: 2 GB RAM, 2 CPUs, swap off, a unique hostname, and the needed ports open.
- Load the bridge module and turn on
net.ipv4.ip_forward=1so Pod traffic can pass. kubeadm initbuilds the control plane. Then install a CNI plugin; this course uses Calico.kubeadm token create --print-join-commandprints the line that a new worker node needs.
Cluster Administration
Save etcd with etcdctl snapshot save. Restore with etcdctl snapshot restore.
- Upgrade with
kubeadm upgrade plan, thenkubeadm upgrade apply, then update kubelet and kubectl. - A node that shows NotReady often has a stopped kubelet. Start it and watch the node turn Ready.
- Read events and logs before you change anything.
Part 2: Cluster Setup
Press "Rebuild Environment" before this lab. If you skip it, the later labs break.
- Ansible builds the whole cluster from code: network, certificates, components, and services.
- The result is one controller and two worker nodes, ready for the next labs.
Containers
An image holds the app and all it needs. A container is a running copy of an image.
- Build an image from a Dockerfile with
docker build -t name:tag .. - Layers are cached, so a small change does not rebuild everything.
Pod Basics
YAML uses indentation. A manifest has metadata (name, labels) and spec (what to run).
- A Pod manifest lists containers, images, ports, and volumes.
- A Namespace splits one cluster into groups such as
dev,test, andprod. - API versions change. Old versions are removed, so check the
apiVersionof every manifest.
Kubectl
kubectl get lists objects. Add -o wide or -o yaml to see more.
- Sort output with
--sort-by=.metadata.nameor by a value such as a metric. kubectl topshows live CPU and memory. It needs the Metrics Server.
Resource Management
requests is what a container needs. limits is the most it may use.
- QoS classes: BestEffort (no requests or limits), Burstable (some), Guaranteed (requests equal limits).
- A ResourceQuota caps total use inside one namespace.
- A LimitRange sets default and maximum values for each container in a namespace.
User Administration
A context is a cluster plus a namespace plus a user. Switch with kubectl config use-context.
- RBAC has four objects: Role, ClusterRole, RoleBinding, and ClusterRoleBinding.
- RBAC only adds rights. There are no deny rules.
- Give a user a certificate and key. Approve the request with
kubectl certificate approve.
Advanced Pod Design
A liveness probe restarts a sick container. A readiness probe controls when traffic arrives. A startup probe waits for a slow boot.
- ConfigMaps hold normal settings. Secrets hold private data such as passwords and tokens.
- Init containers finish before the app containers start. Sidecar containers run beside the app.
- Taints push Pods away from a node. Tolerations let a Pod stay. Node affinity picks nodes by label. A PriorityClass decides which Pod schedules first.
Logging
kubectl logs reads the logs of a container. Use -c for one container and -f to follow.
- Flags such as
--tail,--since, and--timestampstrim the output. - A sidecar can ship logs to one central place, away from the cluster.
Labels
A label is a key=value pair. It helps you find and group objects.
- Select with
-l app=webby. Show them with--show-labels. - Annotations store notes and tool data, but you cannot select objects by annotation.
Replica and Daemon Sets
A ReplicaSet keeps an exact number of Pods. It compares the desired count with the real count.
- A DaemonSet runs one Pod on every node, or on the nodes that match a selector.
- Use a Deployment instead of a bare ReplicaSet when you need updates and history.
Deployments
A Deployment wraps a ReplicaSet and keeps a revision history.
- A rolling update replaces Pods a few at a time.
kubectl rollout undoreturns to an old revision, andkubectl rollout historylists them. - Other strategies are Recreate, Blue/Green, and Canary.
- The HPA adds or removes replicas to meet a CPU or memory target. A StatefulSet gives each Pod a stable name and its own storage.
Persistent Storage
A PersistentVolume (PV) is real storage. A PersistentVolumeClaim (PVC) is a request for storage.
- A StorageClass creates PVs on demand.
- Local storage is simple, but it ties a Pod to one node.
- The NFS CSI driver is a modern way to add storage. If a PVC names no class, Kubernetes uses the default StorageClass.
Extending Kubernetes
A CustomResourceDefinition (CRD) adds a new object type to the API.
- After the CRD is in place, you can use
kubectl getandkubectl applyon that type. - A CRD alone adds no logic. A controller does the real work.
Helm and Kustomize
Helm packs manifests into a chart. Templates and values.yaml fill in the settings.
- Common Helm commands:
helm create,helm template,helm install,helm upgrade,helm rollback. - Kustomize changes a base with overlays. The base files stay the same.
- Apply a kustomization with
kubectl apply -k ..
Services & Networking
A NetworkPolicy is a firewall for Pods. It sets ingress and egress rules. Calico enforces it; Flannel alone does not.
- Service types: ClusterIP (inside the cluster), NodePort (a port on every node), LoadBalancer (a cloud IP). An Ingress routes HTTP by host and path and needs a controller.
- The Gateway API uses a Gateway and an HTTPRoute. It is now part of the CKA scope.
- To debug, check the Service endpoints, the labels, the ports, and DNS.
DNS
A Pod can have a hostname and a full name (FQDN), such as busybox-1.alta3.default.svc.cluster.local. Pods can find each other by name, not only by IP.
Continuing Education
Next steps are CKS for security, CKAD for developers, and Rancher for cluster management.
- The course ends with a curriculum map for container orchestration.
Key commands and tools
kubectl get pods -o wide— list Pods with node and IP.kubectl get pods --show-labels— show the labels on each Pod.kubectl get pods -l app=webby— select Pods by label.kubectl describe pod <name>— show events and details.kubectl apply -f file.yaml— create or update objects from a manifest.kubectl delete -f file.yaml— remove the objects in a manifest.kubectl exec -it <pod> -- bash— open a shell inside a container.kubectl logs <pod> -c <container> -f --tail=50— read and follow logs.kubectl top nodesandkubectl top pods— show CPU and memory use.kubectl rollout status deploy/<name>— watch a rollout.kubectl rollout history deploy/<name>— list revisions.kubectl rollout undo deploy/<name>— go back one revision.kubectl config get-contextsandkubectl config use-context <name>— list and switch contexts.kubectl certificate approve <csr>— approve a user certificate.kubectl create configmap <name> --from-file=<file>— build a ConfigMap from a file.kubeadm init --pod-network-cidr=192.168.0.0/16— build the control plane.kubeadm token create --print-join-command— print the join command.kubeadm join <ip>:6443 --token <token> --discovery-token-ca-cert-hash sha256:<hash>— add a node.kubeadm upgrade planandkubeadm upgrade apply v1.32.x— plan and run an upgrade.etcdctl snapshot save <file>— take an etcd backup.etcdctl snapshot restore <file>— restore etcd.systemctl status kubeletandsystemctl start kubelet— check and start kubelet.helm create,helm install,helm list,helm rollback— manage charts and releases.kubectl apply -k .— apply a Kustomize overlay.
Key terms
The words of this course in one table. Learn them before the quiz or exam.
| Term | Meaning |
|---|---|
| Cluster | One control plane plus the worker nodes it manages. |
| ConfigMap | An object that holds normal settings for a Pod. |
| Control plane | The part that stores cluster state and decides where Pods run. |
| CRD | CustomResourceDefinition. It adds a new object type to the Kubernetes API. |
| DaemonSet | A controller that runs one Pod on every node, or on chosen nodes. |
| Deployment | A controller that manages ReplicaSets and keeps a revision history. |
| etcd | The key-value store that holds all cluster state. |
| Helm | A tool that packs manifests into charts and installs them as releases. |
| Ingress | An HTTP routing rule that sends traffic to Services. It needs a controller. |
| kubeadm | The tool that builds a cluster and upgrades it. |
| kubectl | The command line tool that talks to the API server. |
| kubelet | The agent on a node. It starts Pods and reports node health. |
| Namespace | A group inside a cluster that keeps objects apart. |
| NetworkPolicy | Rules that allow or block traffic to and from Pods. |
| Node | A machine in the cluster that runs Pods. |
| PersistentVolume | Real storage in the cluster, ready to be used. |
| PersistentVolumeClaim | A Pod's request for storage. |
| Pod | The smallest unit. One or more containers with one network space. |
| RBAC | Role Based Access Control. Roles and bindings that give rights. |
| Secret | An object that holds private data, such as a password. |
| Service | A stable name and IP that points to a group of Pods. |
| StatefulSet | A controller that gives each Pod a stable name and its own storage. |
| StorageClass | A rule that creates storage on demand. |
| Taint | A mark on a node that keeps most Pods away. |
| Toleration | A Pod setting that lets the Pod go onto a tainted node. |
Check yourself
Answer each question first, then open it to check the answer.
1Which command builds the control plane with kubeadm?
kubeadm init. Add --pod-network-cidr and, if needed, --kubernetes-version. Then install a CNI plugin.
2What does a readiness probe do, and how is it different from a liveness probe?
A readiness probe says when a container can take traffic. A liveness probe says if the container is still healthy; if it fails, kubelet restarts the container.
3What is the difference between a PersistentVolume and a PersistentVolumeClaim?
A PV is the real storage. A PVC is a request for storage that a Pod can mount. A StorageClass can create the PV for the PVC.
4Which CNI in this course can enforce NetworkPolicy?
Calico. It does Pod networking and enforces NetworkPolicy. Flannel alone does not enforce NetworkPolicy.
5How do you back up etcd, and why is it important?
Run etcdctl snapshot save with the etcd endpoints and the certificate files. The backup lets you restore cluster state after a bad change or a crash.
Useful links
Official documentation and pages for this course.
- alta3.com — the training company that made this course.
- Alta3 on YouTube — free videos and demos.
- Alta3 on GitHub — code, examples, and lab files.