Last active
December 16, 2020 15:12
-
-
Save venkatzgithub/64c86eceac12f39ed3b6b01132b40695 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CKAD | |
Core Concepts (13%) | |
kubectl create namespace mynamespace | |
kubectl run nginx --image=nginx --restart=Never -n mynamespace | |
kubectl run nginx --image=nginx --restart=Never --dry-run -o yaml > myfile.yaml | |
kubectl run busybox --image=busybox --command --restart=Never -it -- env #withoutput | |
kubectl run busybox --image=busybox --command --restart=Never -- env #with | |
kubectl logs busybox | |
kubectl run busybox --image=busybox --restart=Never -o yaml --dry-run --command env > myfile.yaml | |
kubectl apply -f myfile.yaml | |
kubectl create namespace myns --dry-run -o yaml | |
kubectl config set-context $(kubectl config current-context) --namespace=prod | |
kubectl get pods --all-namespaces | |
kubectl get pods --namespace=research | |
kubectl get pods -n research | |
kubectl run nginx --image=nginx --restart=Never --port=80 | |
kubectl set image pod/nginx nginx=nginx:1.7.1 | |
kubectl describe pod nginx | |
kubectl get pod nginx -w | |
kubectl get pod nginx -o wide | |
kubectl get pod nginx -o yaml | |
kubectl create quota myrq --hard=cpu=1,memory=1g,pod=2 --dry-run -o yaml | |
kubectl run busybox --image=busybox -it --restart=Never -- /bin/sh -c "echo hello world" | |
kubectl run busybox --image=busybox -it --restart=Never -- echo "hello world" | |
kubectl run busybox --image=busybox -it --rm --restart=Never -- echo "hello world" | |
kubectl run nginx --image=nginx --restart=Never --env=val1=val2 | |
kubectl exec -it nginx -- env | |
kubectl run nginx --image=nginx --env=val1=val2 -it --rm -- env | |
Pod design (20%) | |
Labels and annotations | |
Kubectl run nginx1 --image=nginx --labels=app=v1 | |
Kubectl get pods --show-labels | |
kubectl edit pod <pod name> | |
Kubectl label pod nginx2 app=v2 –-overwrite | |
Kubectl get pod –l app | |
Kubectl get pods –l app=v2 | |
Kubectl get pods –-selector=app=v2 | |
Kubectl label pod nginx1 app- | |
kubectl label nodes node01 size=large | |
Kubectl explain pod.spec | |
Kubectl annotate pod nginx description=”my pod desc” | |
Kubectl describe pod nginx | grep –i “annotation” | |
Kubectl annotate pod nginx description- | |
Kubectl delete pod nginx{1..3} | |
kubectl delete pod nginx --force --grace-period=0 | |
Deployments | |
kubectl run nginx --image=nginx:1.7.8 --replicas=2 --port=80 | |
kubectl create deployment nginx --image=nginx:1.7.8 --dry-run -o yaml > myfile.yaml | |
kubectl get deploy nginx -o yaml | |
kubectl get pod ngninx-dsdsffssa -o yaml | |
kubectl get pod -l run=nginx | |
kubectl rollout status deploy nginx | |
kubectl set image deploy/nginx nginx=ngninx:1.7.9 | |
kubectl edit deployment my-deployment | |
kubectl rollout history deploy nginx | |
kubectl rollout undo deploy nginx --to-revision=2 | |
kubectl rollout history deploy nginx --revision=6 | |
kubectl rollout pause deploy nginx | |
kubectl rollout resume deploy nginx | |
kubectl scale deploy nginx --replicas=5 | |
kubectl autoscale deploy nginx --min=5 --max=10 --cpu-percent=80 | |
kubectl delete deploy nginx | |
kubectl delete hpa nginx | |
port forwarding | |
kubectl port-forward pods/redis-master-765d459796-258hz 7000:6379 | |
kubectl port-forward deployment/redis-master 7000:6379 | |
kubectl port-forward replicaset/redis-master 7000:6379 | |
kubectl port-forward service/redis-master 7000:6379 | |
congifmaps | |
kubectl create configmap config --from-literal=foo=lala --from-literal=foo2=lolo | |
kubectl get configmap config -o yaml | |
kubectl describe cm config | |
kubectl create cm config2 --from-file=config.txt | |
kubectl create cm config3 --from-env-file=config.env | |
requests and limits | |
kubectl run nginx --image=nginx --restart=Never --requests="cpu=100m,memory=256Mi" --limits="cpu=200m,memory=512Mi" | |
secrets | |
kubectl create secret generic secretname --from-literal=passoword=pass | |
kubectl edit secrets mysecret | |
kubectl create secret generic secretname --from-file=username | |
kubectl get secret secretname -o yaml | |
echo YWRtaW4K | base64 -d | |
serviceaccounts | |
kubectl get sa --all-namespaces | |
kubectl create serviceaccount myuser | |
kubectl get sa default -o yaml > s.yaml | |
kubectl run nginx --image=nginx --restart=Never --serviceaccount=myuser -o yaml --dry-run > pod.yaml | |
Observability (18%) | |
Liveness and readiness probes | |
kubectl explain pod.spec.containers.livenessProbe.exec | |
kubectl explain pod.spec.containers.livenessProbe | |
kubectl describe pod nginx | grep -i liveness | |
kubectl describe pod nginx | grep -i readiness | |
Logging | |
kubectl logs busybox | |
kubectl logs busybox -f | |
kubectl logs material-information-vue-5f566d89c-pz2rz flask -f | |
CPU/memory utilization for nodes | |
kubectl top node | |
kubectl top pod | |
services | |
kubectl expose pod redis --port=6379 --name redis-service | |
kubectl run ngninx --image=nginx --restart=Never --port=80 --expose | |
kubectl get svc nginx | |
kubectl get ep or endpoints | |
kubectl edit svc nginx | |
kubectl delete svc nginx | |
kubectl delete pod nginx | |
kubectl run foo --image=dgkanatsios/simpleapp --labels=app=foo --port=8080 --replicas=3 | |
kubectl get pods -l app=foo -o wide | |
wget -o- podip:8080 | |
kubectl expose deploy foo --port=6262 --target-port=8080 | |
wget -o- SERVICE_CLUSTER_IP:6262 | |
State Persistence | |
kubectl exec -it busybox -c busybox -- /bin/sh | |
kubectl cp busybox:/etc/passwd ./passwd | |
Taints & Tolerations | |
kubectl taint nodes node-name key=value:taint:NoSchedule | |
kubectl taint nodes node-name key=value:taint:NoExecute | |
kubectl taint nodes node-name key=value:taint:PreferNoSchedule | |
kubectl taint nodes master node-role.kubernetes.io/master:NoSchedule- | |
networkpolicy | |
kubectl get networkpolicy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment