Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
$ als gewone gebruiker# als root (of met sudo)
What the course covers
Pods and YAML manifests, plus the kubectl commands to create, read, change, and delete objects.
- Namespaces, contexts, and safe access to a cluster.
- Health checks, security settings, and running commands inside a container.
- CPU and memory control, metrics, and autoscaling.
- Logs, ConfigMaps, Secrets, and storage with PV, PVC, and CSI.
- Workloads: ReplicaSets, DaemonSets, Deployments, Jobs, and CronJobs.
- Networking: taints, NetworkPolicy, Services, Ingress, and DNS.
- Helm, Kustomize, CRDs, and troubleshooting.
Welcome to Alta3 Research Labs!
The lab has a jump box named bchd, one controller, and two worker nodes.
- Most labs start with a
setup <lab-name>command that builds the objects you need. - VIRGIL is the lab coach. You can ask it for help during a lab.
Required Tools
Vim is modal. Press i to type, Esc to leave insert mode, then :wq to save and quit.
- tmux keeps your work alive if the connection drops.
- Split the screen with
Ctrl-bthen%(side by side) or"(top and bottom). - Use one pane for
watchand the other pane for commands.
From Containers to Kubernetes
An image is a read-only template. A Dockerfile builds it layer by layer.
- A tag is a version. If you do not set one, Docker uses
latest. - The control plane holds the API server, etcd, the scheduler, and controllers.
- Worker nodes run kubelet, kube-proxy, and a container runtime.
- A Pod is the smallest unit. Its containers share a network and can share volumes.
- Alta3 builds the cluster with an Ansible playbook called
kubernetes-the-alta3-way.
Pod Basics
A manifest needs four keys: apiVersion, kind, metadata, and spec.
- YAML uses spaces, never tabs. Key order does not matter.
- Create a Pod with
kubectl apply -f pod.yaml, then check it withkubectl get pods. kubectl api-resourcesshows every kind and API version the cluster knows.
Cluster Basics
A namespace is one slice of a cluster. Names must be unique only inside a namespace.
- The default namespaces are
default,kube-system,kube-public, andkube-node-lease. - A context is a cluster plus a user plus a namespace. Switch with
kubectl config use-context. kubectl gettakes flags such as-n,--all-namespaces,-o wide,--show-labels, and--sort-by.
Container Health, Security, and Observability
kubectl port-forward opens a local port to a Pod, even when no Service exists.
kubectl exec -it POD -- shopens a shell in a container.kubectl cpcopies files in and out.- A readiness probe holds traffic until the app is ready.
- A liveness probe restarts an app that is stuck. A startup probe gives slow apps time to boot.
- A securityContext can set
runAsUser,runAsGroup,fsGroup,allowPrivilegeEscalation: false, andreadOnlyRootFilesystem: true.
Resource Management
A request is the CPU or memory the scheduler must find before it places the Pod.
- A limit is the most a container may use.
- A ResourceQuota caps a whole namespace. A LimitRange sets default and min/max values.
- LimitRanger is an admission controller. It changes new Pods and checks their values.
kubectl top nodesandkubectl top podsneed the metrics-server.
RBAC
A ServiceAccount is the identity a Pod uses to call the API.
- The
defaultServiceAccount has no extra rights. - A Role plus a RoleBinding gives rights in one namespace. A ClusterRole and ClusterRoleBinding do the same for the whole cluster.
- The lab creates ServiceAccount
privileged-sa, then a Role and RoleBinding. Check it withkubectl describe rolebinding.
Logging
Containers should write logs to stdout and stderr.
kubectl logs POD -c CONTAINERpicks one container.- Add
-fto follow,--tailfor the last lines, and--sincefor a time window. --all-containersshows logs from every container in the Pod.- Fluentd can run as a sidecar and ship logs to a central place.
Ephemeral Storage
A ConfigMap holds config as key/value pairs.
- Build one from a file with
kubectl create configmap NAME --from-file=KEY=PATH. - Mount a ConfigMap as a volume, or pass its keys as environment variables.
- A Secret holds private data. It is base64-encoded, not encrypted by default.
- Mount a Secret as a volume or inject it as env vars. Never bake a secret into an image.
Persistent Storage
A PersistentVolume (PV) is real storage in the cluster.
- A PersistentVolumeClaim (PVC) is a request for storage.
- A StorageClass can create PVs on demand. This is dynamic provisioning.
- CSI is the standard plugin model for storage drivers. The lab installs an NFS CSI driver.
hostPathand local disks are fine for labs but risky for production.
Multi-Container Pod Design
A sidecar adds a helper container to the same Pod, such as a log shipper.
- An
emptyDirvolume starts empty and is shared by all containers in the Pod. - An
emptyDirlives only as long as the Pod. - Init containers run one by one, to completion, before the app containers start.
Deployments
A label is a key=value pair. A selector finds objects by label.
- An annotation stores extra metadata for tools. You cannot select objects with it.
- A ReplicaSet keeps N copies of a Pod. A DaemonSet runs one Pod on every node.
- A Deployment wraps a ReplicaSet and keeps revision history.
- Use
kubectl rollout status,kubectl rollout history, andkubectl rollout undo. - Blue/green runs two full versions and moves all traffic at once. Canary sends a small slice of traffic to the new version.
- A HorizontalPodAutoscaler adds Pods when CPU or memory passes a target.
Jobs and CronJobs
A Job runs until its command finishes.
completionsandparallelismcontrol how much work runs at once.ttlSecondsAfterFinisheddeletes Pods some seconds after a Job finishes.- A CronJob runs a Job on a schedule, for example
*/1 * * * *. concurrencyPolicy,startingDeadlineSeconds,suspend, and history limits control runs.
Affinity and Anti-Affinity
A taint on a node keeps Pods away. A toleration on a Pod lets it use that node.
kubectl taint nodes node-1 key=value:NoScheduleadds a taint. Add-at the end to remove it.nodeSelectorpulls Pods toward nodes with a matching label.- A PriorityClass decides which Pods are scheduled first or evicted last.
NetworkPolicy
By default, every Pod can reach every other Pod.
- The lab first creates a policy that denies all traffic.
- A policy picks Pods with
podSelector, then allows ingress, egress, or both. - Rules can match Pods, whole namespaces, IP blocks, and ports.
Services and Ingress
A Service gives Pods one stable IP and DNS name.
- A Service sends traffic to Pod endpoints.
- ClusterIP works inside the cluster only. NodePort opens a port on every node. LoadBalancer asks the cloud for one.
kubectl expose pod/nginx --type=NodePort --port 80makes a Service fast.- An Ingress routes HTTP by host and path to Services. It needs an Ingress controller.
DNS
A Service gets a name like svc.namespace.svc.cluster.local.
- A Pod can have a hostname and a subdomain.
setHostnameAsFQDN: truewrites the full name into the Pod hostname.hostname --fqdnshows the full name.nslookupandpingtest name resolution.- Pods can look up each other and Services by name inside the cluster.
Helm and Kustomize
A Helm chart is a folder of templates plus a values.yaml file.
helm createmakes a chart.helm install,helm upgrade,helm list, andhelm rollbackmanage releases.helm repo addandhelm search hubhelp you find packages.- Kustomize uses a
kustomization.yamlwith a base and overlays. Apply it withkubectl apply -k ..
Extending Kubernetes
A CustomResourceDefinition (CRD) adds a new kind to the API.
- After the CRD exists, you can create objects of that kind with kubectl.
- A CRD alone adds no logic. A controller must act on the new objects.
kubectl wait --for=condition=Established crd/NAMEwaits until the CRD is ready.
Troubleshooting
Read the logs first. Then read all of the logs.
kubectl describeshows events, such as a failed image pull or a probe failure.kubectl get events -n NSgives a fast view of what happened.- In the lab, the missing Pod is caused by a ResourceQuota. Read the warning event.
kubectl describe ns NSshows the quota and how much is used.
CKAD
Each lab shows its CKA/CKAD objective at the top. Use these as a checklist.
- The last lesson is a short video of exam tips.
- Practice until you can write Pod, Deployment, and Service manifests from memory.
Continuing Education
The next step is Kubernetes 201, the CKA course.
- Alta3 also offers a 5-day Kubernetes Bootcamp with lecture and labs.
- The ContainerOrchestration path adds CKS, Rancher, Git, and Linux courses.
Key commands and tools
kubectl config get-contextsandkubectl config use-context NAME— pick a cluster.kubectl api-resources— list kinds and API versions.kubectl apply -f file.yamlandkubectl delete -f file.yaml— create and remove objects.kubectl get pods -n NS -o wide --show-labels— list Pods with extra detail.kubectl get pods --sort-by=.status.containerStatuses[0].restartCount— sort by restarts.kubectl describe pod NAME— show details and events.kubectl exec -it POD -- sh— open a shell inside a container.kubectl label pods nginx app=web_service— add a label to a Pod.kubectl port-forward POD 2224:9876 --address=0.0.0.0— open a local tunnel.kubectl logs POD -c CONTAINER --tail 5 --timestamps— read logs.kubectl create configmap NAME --from-file=key=path— build a ConfigMap.kubectl rollout history deploy/NAMEandkubectl rollout undo deploy/NAME— check and revert a release.kubectl scale deploy NAME --replicas 3— change the number of Pods.kubectl top nodesandkubectl top pods— show CPU and memory use.kubectl taint nodes node-1 key=value:NoSchedule— taint a node.kubectl expose pod/nginx --type=NodePort --port 80— make a Service.helm create NAME,helm install NAME ./chart,helm list— work with charts.kubectl apply -k .— apply a Kustomize overlay.kubectl wait --for=condition=Established crd/NAME --timeout=30s— wait for a CRD.- Vim:
i,Esc,:wq. tmux:Ctrl-b, then%,", or[.
Key terms
The words of this course in one table. Learn them before the quiz or exam.
| Term | Meaning |
|---|---|
| ConfigMap | A place to keep config data outside the container image. |
| Context | A cluster, a user, and a namespace, saved for kubectl. |
| CRD | A CustomResourceDefinition. It adds a new kind to the Kubernetes API. |
| CronJob | A Job that runs on a time schedule. |
| DaemonSet | A controller that runs one Pod on every node. |
| Deployment | A controller that manages a ReplicaSet and keeps revision history. |
| HorizontalPodAutoscaler (HPA) | A controller that adds or removes Pods when load changes. |
| Ingress | An HTTP router. It sends a host and path to a Service. |
| Init container | A container that runs to completion before the app containers start. |
| Job | A workload that runs a command until it finishes. |
| kubectl | The command-line tool that talks to the Kubernetes API. |
| Label | A key=value tag on an object, used by selectors. |
| Manifest | A YAML or JSON file that says what object you want. |
| Namespace | A slice of a cluster that keeps objects apart. |
| NetworkPolicy | A firewall rule for Pods. It allows or blocks ingress and egress. |
| PersistentVolume (PV) | Real storage in the cluster. |
| PersistentVolumeClaim (PVC) | A request for storage that a Pod can mount. |
| Pod | The smallest unit Kubernetes runs. It holds one or more containers that share a network. |
| Probe | A health check. Readiness holds traffic, liveness restarts, startup waits. |
| ReplicaSet | A controller that keeps a set number of identical Pods. |
| Secret | A place to keep private data, such as passwords and tokens. It is base64-encoded. |
| Selector | A rule that finds objects by their labels. |
| Service | A stable IP and DNS name in front of a group of Pods. |
| Sidecar | A helper container that runs next to the main container in a Pod. |
| StorageClass | A rule that lets the cluster create PVs on demand. |
Check yourself
Answer each question first, then open it to check the answer.
1What is the difference between a request and a limit?
A request is what the scheduler must reserve. A limit is the maximum the container may use.
2What does kubectl rollout undo deploy/zombie do?
It sends the Deployment back to the previous revision. Add --to-revision=N to pick one.
3Why do two containers in one Pod use an emptyDir volume?
Both containers can read and write the same files. The volume is deleted with the Pod.
4What is the difference between a label and an annotation?
A label is a key=value pair used by selectors. An annotation is extra metadata for tools and cannot select objects.
5Which Service type opens a port on every node?
NodePort. It opens the same port on every node and forwards traffic to the Pods.
Useful links
Official documentation and pages for this course.