Kubernetes Cheatsheet

Get list of clusters available:

k config get-contexts

Switch cluster:

k config use-context _name_

Show pods and get ID:

kubectl get pods -n _namespace_

Show logs:

kubectl logs -n _namespace_ -c _container_ _podid_

Live logs:

kubectl logs -n _namespace_ -c _container_ --follow _podid_

Restart a pod:

kubectl delete pod -n _namespace_ _podid_

To stop a pod to e.g. execute some blocking stuff, scale it to 0 and afterwards scale it up:

To copy files

k cp _folder_ _podname_:/mnt/projects/epo/ -c _containername_

Get IPs from all nodes in cluster:

k get nodes -o wide

Get secrets:

kubectl -n _namespace_ get secrets _vaultkey_ -o yaml

Forward port to localhost:

kubectl port-forward --namespace _namespace_ _podId_ _port_

Checking which NFS version is used for the PV:

kubectl get pv | findstr _namespace_
kubectl get pv _pvName_

Search for spec → mountOptions → nfsvers.