This is a small Kubernetes Cheat Sheet with the list of commands and settings I use, almost on a daily basis, when working with kubernetes.
| Command |
Description |
kubectl get services |
List all services |
kubectl get pods |
List all pods |
kubectl get nodes -w |
Watch nodes continuously |
kubectl version |
Get version information |
kubectl cluster-info |
Get cluster information |
kubectl config view |
Get the configuration |
kubectl describe node <node> |
Output information about a node |
Pod and Container Introspection
| Command |
Description |
kubectl get pods |
List the current pods |
kubectl describe pod <name> |
Describe pod
|
kubectl get rc |
List the replication controllers |
kubectl get rc --namespace="<namespace>" |
List the replication controllers in
|
ubectl describe rc <name> |
Describe replication controller
|
kubectl get svc |
List the services |
kubectl describe svc <name> |
Describe service
|
| Command |
Description |
kubectl run <name> --image=<image-name> |
Launch a pod called <name> using image <image-name> |
kubectl create -f <manifest.yaml> |
Create a service described in <manifest.yaml> |
kubectl scale --replicas=<count> rc <name> |
Scale replication controller <name> to <count> instances |
kubectl expose rc <name> --port=<external> --target-port=<internal> |
Map port <external> to port <internal> on replication controller <name> |
| Command |
Description |
kubectl delete pod <name> |
Delete pod
|
kubectl delete rc <name> |
Delete replication controller
|
kubectl delete svc <name> |
Delete service
|
kubectl drain <n> --delete-local-data --force --ignore-daemonsets |
Stop all pods on
|
kubectl delete node <name> |
Remove from the cluster
|
| Command |
Description |
kubectl exec <service> <command> [-c <$container>] |
execute on , optionally selecting container <$container>
|
kubectl logs -f <name> [-c <$container>] |
Get logs from service , optionally selecting container <$container>
|
watch -n 2 cat /var/log/kublet.log |
Watch the Kublet logs |
kubectl top node |
Show metrics for nodes |
kubectl top pod |
Show metrics for pods |
| Command |
Description |
kubeadm init |
Initialize your master node |
kubeadm join --token <token> <master-ip>:<master-port> |
Join a node to your Kubernetes cluster |
kubectl create namespace <namespace> |
Create namespace
|
kubectl taint nodes --all node-role.kubernetes.io/master- |
Allow Kubernetes master nodes to run pods |
kubeadm reset |
Reset current state |
kubectl get secrets |
List all secrets |