- Published on
Cheat Sheet: Kubernetes commands/shortcuts
- Authors
- Name
- Loi Tran
Introduction
Start local cluster
minikube start
Check kubernetes version
kubectl version
Check nodes
kubectl get nodes
Create a deployment using image primetimetran/micro-client
kubectl create deployment hello-world --image=primetimetran/micro-client
View status of deployments
kubectl get deployments
Open proxy to cluster from host
echo -e "\n\n\n\e[92mStarting Proxy. After starting it will not output a response. Please click the first Terminal Tab\n";
kubectl proxy
Check if proxy allows access to cluster VPN via host machine
curl http://localhost:8001/version
View pod status
kubectl get pods
Setup POD_NAME
env variable to check namespace momentarily
export POD_NAME=
curl http://localhost:8001/api/v1/namespaces/default/pods/$POD_NAME/
kubectl get pods
View more detailed information about pods
kubectl describe pods
curl http://localhost:8001/api/v1/namespaces/default/pods/$POD_NAME/proxy/
View logs from pod
kubectl logs $POD_NAME
Execute commands on POD_NAME
kubectl exec $POD_NAME -- env
Open shell to POD_NAME
kubectl exec -ti $POD_NAME -- /bin/sh
Expose
k get pods
kubectl get services
Expose deployment deployment/hello-world
on port 80 to host machine
kubectl expose deployment/hello-world --type="NodePort" --port 80