kubectl get services # List all serviceskubectl get pods # List all podskubectl get nodes -w # Watch nodes continuouslykubectl version # Get version informationkubectl cluster-info # Get cluster informationkubectl config view # Get the configurationkubectl describe node <node> # Output information about a node
Pod and container introspection
kubectl get pods # List the current podskubectl describe pod <name> # Describe pod <name>kubectl get rc # List the replication controllerskubectl get rc --namespace="<namespace>" # List the replication controllers in <namespace>kubectl describe rc <name> # Describe replication controller <name>kubectl get svc # List the serviceskubectl describe svc <name> # Describe service <name>
Interacting with pods
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> instanceskubectl expose rc <name> --port=<external> --target-port=<internal> # Map port <external> to # port <internal> on replication # controller <name>
Stopping Kubernetes
kubectl delete pod <name> # Delete pod <name>kubectl delete rc <name> # Delete replication controller <name>kubectl delete svc <name> # Delete service <name>kubectl drain <n> --delete-local-data --force --ignore-daemonsets # Stop all pods on <n>kubectl delete node <name> # Remove <node> from the cluster
Debugging
kubectl exec <service> <command> [-c <$container>] # execute <command> on <service>, optionally # selecting container <$container>kubectl logs -f <name> [-c <$container>] # Get logs from service <name>, optionally # selecting container <$container>watch -n 2 cat /var/log/kubelet.log # Watch the kubelet logskubectl top node # Show metrics for nodeskubectl top pod # Show metrics for pods
Administration
kubeadm init # Initialize your master nodekubeadm join --token <token> <master-ip>:<master-port> # Join a node to your Kubernetes clusterkubectl create namespace <namespace> # Create namespace <name>kubectl taint nodes --all node-role.kubernetes.io/master- # Allow Kubernetes master nodes to run podskubeadm reset # Reset current statekubectl get secrets # List all secrets