Geavanceerd
Zoeken inSamenvattingen
Zo zoek je
  • Woorden vinden lestitels, tekst en code. Filter op soort (gidsen, cursussen, programma's, boeken) of blijf in dit boek.
  • book:rhcsa en ch:8 maken de zoektocht kleiner; #code vindt een woord alleen in commando's van de lessen.
  • "twee woorden" vindt precies die zin.
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken
Probeer:

Cursus 7Naam in de cursus: Certified Kubernetes Application Developer (CKAD) Prep Course

Certified Kubernetes Application Developer (CKAD) Prep Course

Course 7 of 13 in the Alta3 Academy library. Alta3 Academy self-paced course.

Notitie

My result — Lessons read: all 92/92; Course progress: 100%.

  • 29 Lessen
  • 7 Commando's
  • 2 Labs

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

7.1

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.

7.2

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.

7.3

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-b then % (side by side) or " (top and bottom).
  • Use one pane for watch and the other pane for commands.

Commando's in deze les

7.4

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.

7.5

Pod Basics

A manifest needs four keys: apiVersion, kind, metadata, and spec.

7.6

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, and kube-node-lease.
  • A context is a cluster plus a user plus a namespace. Switch with kubectl config use-context.
  • kubectl get takes flags such as -n, --all-namespaces, -o wide, --show-labels, and --sort-by.

7.7

Container Health, Security, and Observability

kubectl port-forward opens a local port to a Pod, even when no Service exists.

  • kubectl exec -it POD -- sh opens a shell in a container. kubectl cp copies 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, and readOnlyRootFilesystem: true.

7.8

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 nodes and kubectl top pods need the metrics-server.

7.9

RBAC

A ServiceAccount is the identity a Pod uses to call the API.

  • The default ServiceAccount 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 with kubectl describe rolebinding.

7.10

Logging

Containers should write logs to stdout and stderr.

  • kubectl logs POD -c CONTAINER picks one container.
  • Add -f to follow, --tail for the last lines, and --since for a time window.
  • --all-containers shows logs from every container in the Pod.
  • Fluentd can run as a sidecar and ship logs to a central place.

7.11

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.

7.12

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.
  • hostPath and local disks are fine for labs but risky for production.

7.13

Multi-Container Pod Design

A sidecar adds a helper container to the same Pod, such as a log shipper.

  • An emptyDir volume starts empty and is shared by all containers in the Pod.
  • An emptyDir lives only as long as the Pod.
  • Init containers run one by one, to completion, before the app containers start.

7.14

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, and kubectl 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.

7.15

Jobs and CronJobs

A Job runs until its command finishes.

  • completions and parallelism control how much work runs at once.
  • ttlSecondsAfterFinished deletes 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.

7.16

Affinity and Anti-Affinity

A taint on a node keeps Pods away. A toleration on a Pod lets it use that node.

7.17

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.

7.18

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 80 makes a Service fast.
  • An Ingress routes HTTP by host and path to Services. It needs an Ingress controller.

7.19

DNS

A Service gets a name like svc.namespace.svc.cluster.local.

  • A Pod can have a hostname and a subdomain.
  • setHostnameAsFQDN: true writes the full name into the Pod hostname.
  • hostname --fqdn shows the full name. nslookup and ping test name resolution.
  • Pods can look up each other and Services by name inside the cluster.

7.20

Helm and Kustomize

A Helm chart is a folder of templates plus a values.yaml file.

7.21

Extending Kubernetes

A CustomResourceDefinition (CRD) adds a new kind to the API.

7.22

Troubleshooting

Read the logs first. Then read all of the logs.

7.23

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.

7.24

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.

7.25

Key commands and tools

7.26

Key terms

The words of this course in one table. Learn them before the quiz or exam.

TermMeaning
ConfigMapA place to keep config data outside the container image.
ContextA cluster, a user, and a namespace, saved for kubectl.
CRDA CustomResourceDefinition. It adds a new kind to the Kubernetes API.
CronJobA Job that runs on a time schedule.
DaemonSetA controller that runs one Pod on every node.
DeploymentA controller that manages a ReplicaSet and keeps revision history.
HorizontalPodAutoscaler (HPA)A controller that adds or removes Pods when load changes.
IngressAn HTTP router. It sends a host and path to a Service.
Init containerA container that runs to completion before the app containers start.
JobA workload that runs a command until it finishes.
kubectlThe command-line tool that talks to the Kubernetes API.
LabelA key=value tag on an object, used by selectors.
ManifestA YAML or JSON file that says what object you want.
NamespaceA slice of a cluster that keeps objects apart.
NetworkPolicyA 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.
PodThe smallest unit Kubernetes runs. It holds one or more containers that share a network.
ProbeA health check. Readiness holds traffic, liveness restarts, startup waits.
ReplicaSetA controller that keeps a set number of identical Pods.
SecretA place to keep private data, such as passwords and tokens. It is base64-encoded.
SelectorA rule that finds objects by their labels.
ServiceA stable IP and DNS name in front of a group of Pods.
SidecarA helper container that runs next to the main container in a Pod.
StorageClassA rule that lets the cluster create PVs on demand.

7.27

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.

Oefenen

Alle commando's in dit hoofdstuk