rm ~/.vimrck run nginx --image nginx --dry-run -oyaml > 1.yamlvim 1.yamlcat > ~/.vimrc <<EOF
set ts=2 sts=2 sw=2 et nu ai cuc cul
EOFvim 1.yamlalias hg='history|grep'# FILE NAVIGATION AND ORGANISATION
mkdir `seq 20`
ls
cd 1/
cd ../2
cd ../3# ALWAYS CREATE DRY-RUN YAML FILES WITH 1.yaml, 2.yaml or 3.yamlk run nginx --image nginx --dry-run -oyaml > 1.yamlvim 1.yamlk create -f 1.yamlk get pod --watchk get pod nginx -oyaml > 2.yamlvim 2.yamlk apply -f 2.yaml# 6 CLUSTERS IN EXAM
https://docs.linuxfoundation.org/tc-docs/certification/tips-cka-and-ckadk config use-context [k8s|hk8s|bk8s|wk8s|ek8s|ik8s]# NAMESPACE TRICKN=namespace-asked-in-questionk delete ns $Nk create ns $Nk -n $N run question1 --image nginxk -n $N edit pod question1# FILENAME TRICKmkdir -p complete/file/path/touch complete/file/path/filename-asked-in-question F=complete/file/path/filename-asked-in-questionecho $Fcp $F .lsvim $F# HOW TO USE HELP IN COMMAND LINE
# Identify which objects can be created via command line
# and which objects need yaml to start withk -h # IT'S ALL STARTS HEREk expose -h # Use to expose pod or deployment to create a servicek create -h # Ingress, Deployments, SA, role, rolebinding, clusterrole, clusterrolebinding, serviceaccountk create ingress -h # THIS ONE IS REALLY HANDYk set -hk set resources -h # THIS ONE IS REALLY HANDY TOOk logs -hk drain -hk uncordon -hk scale -hk top -hk top pod -hk top pod --sort-by -h# Network Policies need yaml first
https://kubernetes.io/docs/concepts/services-networking/network-policies/# StorageClass, PersistentVolume, PersistentVolumeClaim need yaml first
https://kubernetes.io/docs/concepts/storage/storage-classes/
https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/# USE EXPLAIN COMMAND# 1ST FOCUS ON .SPEC FIELD# IF NOT THEN FOCUS ON .METADATA FIELDk explain quota.spec --recursivek explain limitrange.spec --recursivek explain node --recursivek explain pod.spec --recursive| grep -i nodeselk explain deploy.spec --recursive | grep -i nodeselk explain pod.spec --recursive| grep -i empty -C3# DON'T ABANDON A COMMAND IF YOU DON'T INTEND TO USE IT IMMEDIATELY
# INSTEAD PRESS CTRL+A TO GO TO START AND ADD A `#` IN FRONTETCDCTL_API=3 etcdctl snapshot save \
/tmp/etcd-backup.db \
--cacert /etc/kubernetes/pki/etcd/ca.crt \
--cert /etc/kubernetes/pki/apiserver-etcd-client.crt \
--key /etc/kubernetes/pki/apiserver-etcd-client.key# GET COMFORTABLE WITH SYSTEMCTL# sudo -i # DO SUDO -I if you cansystemctl status kubelet # CHECK SERVICE STATUSsystemctl enable kubelet # ENABLE THE SERVICEsystemctl start kubelet # START THE SERVICEsystemctl stop kubelet # STOP THE SERVICEsystemctl daemon-reload # DAEMON RELOADsystemctl restart kubelet # RESTART IF YOU MADE ANY CONFIG CHANGES# VIM TIPSSHIFT Cvim 1.yamlSHIFT V -> ARROWS ↑↓ -> y (copy) -> Goto line after which you want to copy -> p (paste after)vim 1.yamlSHIFT V -> ARROWS ↑↓ -> `><` -> . (repeat)vim 1.yamlk get nodessh minikube# sudo -i # become root# exit # sudo# exit # exit node# now you are back to client terminalhg question1