This repo is consolidated list of ckad excersises and commands
alias k=kubectl
k config set-context $(k config current-context) --namespace=<namespace>
export KUBE_EDITOR=nano
Be familiar with below kubectl commands to create a pod with env variable, running on port 80, requests and limits, labels
k run mypod --image=nginx --restart=Never --port=80 --env="name=value" --requests=cpu=50m,memory=50Mi --limits=cpu=100m,memory=100Mi --replicas=1 --labels=exam=ckad --dry-run -o yaml -- /bin/bash -c
'echo Hello; sleep 3600'
k run mydeploy --image=nginx --port=80 --env="name=value" --requests=cpu=50m,memory=50Mi --limits=cpu=100m,memory=100Mi --replicas=1 --labels=exam=ckad --dry-run -o yaml -- /bin/bash -c 'echo Hello; sleep 3600'
k run cronjob --image=nginx --labels=exam=ckad --restart=OnFailure --schedule="*/1 * * * * " -- /bin/bash -c 'echo Hello CronJob'
k run job --image=nginx --labels=exam=ckad --restart=OnFailure -- /bin/bash -c 'echo Hello job'
k get po -o wide --no-headers|sort -k5 -r | awk '{print $5}' ## sorting on column 5 (-r to reverse) and printing only that column
k get po -o wide --no-headers|sort -k5 | awk '{print $5}' ## sorting on column 5 and printing only that column
k get po -o wide --no-headers|sort -k5 |head -1| awk '{print $5}' ## sorting on column 5 and printing only that column and first one
kubectl top pod nginx --containers
kubectl get events --sort-by=.metadata.creationTimestamp > events.txt
kubectl get events -o wide |grep <podname> > pod_events_wide.txt