CKA - Kubernetes Certified Administrator Cheatsheet
CKA - Kubernetes Certified Administrator Cheatsheet
CKA - Kubernetes Certified Administrator Cheatsheet
Generate a pod yaml file with nginx image and label env=prod :
test-service.dev
Create a service for a pod valid-pod , which serves on port 444 with the name frontend :
Scheduling
Get pods with their labels:
/etc/kubernetes/manifests
Monitoring
Check node resources usage:
Undo rollout:
kubectl rollout undo deployment/app
Cluster Maintenance
Drain node node01 of all workloads:
Backup etcd:
export ETCDCTL_API=3
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 \
Restore etcd:
ETCDCTL_API=3 etcdctl snapshot restore /tmp/etcd-backup.db --data-dir /var/lib/etcd-backup
Security
Create service account sa_1
Troubleshooting
View all the kube-system related pods:
df -h
top
kubectl cluster-info
Gather info
ssh node0master
ls /etc/cni/net.d/
General notes
To create a daemonset, use kubectl create deploy command to create a .yaml file and then
change the kind and remove replicas & strategy .
To find the static pod manifest path, check the exec command of kubelet
service or staticPodPath parameter of kubelet’s config file.
To create a static pod, place a yaml definition file in the staticPodPath directory.
To identify static pods look for the suffix -<node_name> on pods.
To add a new scheduler copy the existing one and add to the container’s command the flags --
leader-elect=false and --scheduler-name=my-scheduler-name . To use the new scheduler
under spec of a pod definition file specify the option schedulerName .
To add a default command to a pod use command that overrides the default ENTRYPOINT from
Dockerfile. Use args to override the Dockerfile CMD command for the commmand’s extra
parameters.