### K8s General ```bash 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 # Output information about a node ``` ### Pod & Containers ```bash kubectl get pods # List the current pods kubectl describe pod # Describe pod kubectl get rc # List the replication controllers kubectl get rc --namespace="" # List the replication controllers in kubectl describe rc # Describe replication controller kubectl get svc # List the services kubectl describe svc # Describe service ``` ### Interacting with Pods ```bash kubectl run --image= # Launch a pod called # using image kubectl create -f # Create a service described # in kubectl scale --replicas= rc # Scale replication controller # to instances kubectl expose rc --port= --target-port= # Map port to # port on replication # controller ``` ### Stopping K8s ```bash kubectl delete pod # Delete pod kubectl delete rc # Delete replication controller kubectl delete svc # Delete service kubectl drain --delete-local-data --force --ignore-daemonsets # Stop all pods on kubectl delete node # Remove from the cluster ``` ### Debugging ```bash kubectl exec [-c <$container>] # execute on , optionally # selecting container <$container> kubectl logs -f [-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 ``` ### Administration ```bash kubeadm init # Initialize your master node kubeadm join --token : # Join a node to your Kubernetes cluster kubectl create 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 ```