3.3 KiB
3.3 KiB
| aliases | language | created | summary | tags | status | |
|---|---|---|---|---|---|---|
| English | 2025-09-24 | My preparation notes for the kubernetes CAD certificate by linux foundation |
|
- Suggested IDE: vscode
- YAML extension by Red Hat, configure in the extension settings the YAML schema and set this in the settings.json: `"yaml.schemas": {
"kubernetes": "*.yaml"
}` - restart the IDE afterwards
- kubectl
- has very good --help options even on subcommands! with example commands
kubectl run nginx --image=nginxwill fetch the nginx image from docker hub and create a podkubectl create deployment nginx --image=nginxcreates a deploymentkubectl create -f pod-definition.ymlcreate from file (kubectl apply -f file.ymlworks too?)kubectl get podskubectl set image deployment/nginx busybox=buysbox nginx=nginx:1.9.1(or pod/nginx ...)- maybe also try
kubectl edit ... - or change the yaml file and do
kubectl apply -f redis.yaml
- maybe also try
kubectl describe pod myapp-podkubectl run redis --image=redis123 --dry-run=client -o yaml > redis.yamlcreate yaml specification file for a podkubectl get replicasetandkubectl get replicacontrollerkubectl scale --replicas=6 -f replicaset-definition.ymlbetter thankubectl scale --replicas=6 replicaset myapp-replicasetbecause latter only modifies deployed definition and not source filekubectl apply -f replicaset-definition.ymlkubectl get all(lists deployment, then replicaset, then pods)
- scaling: we create additional pods. a pod can contain multiple containers but one pod shall only contain what is necessary for one instance of the application. we do NOT create additional containers in the same pod
- deployment: recreate (all down, then all new up) vs rollingUpdate (default, scales down/up replicasets by one at a time).
kubectl rollout undo deployment/myapp-deploymentwill roll back - minikube: bundles master node programs and node programs on one machine. requires virtualization (via hypervisor KVM, VirtualBox... or docker but latter is not recommended)
- ctr: CLI for containerD, not very user friendly and mostly for debugging
- It is advised to use nerdctl instead
- nerdctl: provides docker-like CLI for containerd, supports docker compose, supports newest features in containerD (encrypted container images, lazy pulling...)
- crictl: provides a CLI for CRI-compatible container runtimes, installed separately, used to inspect and debug container runtimes (not to create containers ideally), works across different runtimes
crictl podsshows podscrictl --runtime endpointenables you to specify a runtime endpoint (or use CONTAINER_RUNTIME_ENDPOINT env var)- other commands are similar to docker
Kubernetes definition file:
apiVersion: v1
kind: Pod
metadata: //dictionary, can only have name and labels
name: myapp-pod
labels: // can have any sub-attributes
app: myapp
spec: //individual for all deployments
containers:
- name: nginx-container
image: nginx
Glossary
- CRI: Container Runtime Interface
- Kubernetes originally only worked for Docker but then introduced the CRI to be more abstract and allow all sorts of container runtimes
- OCI: Open Container Initiative
- imagespec: specification on how an image should be build
- runtimespec: standards on how a container runtime shall be deployed