Kubectl Cheatsheet


    kubectl version
    kubectl cluster-info


    kubectl config current-context
    kubectl config use-context cp08


    kubectl get services                  # List all services in the namespace
    kubectl get pods --all-namespaces     # List all pods in all namespaces
    kubectl get pods -o wide              # List all pods in the namespace, with more details
    kubectl get rc <rc-name>              # List a particular replication controller
    kubectl get pods -l env=production    # List all pods with a label env=production
    kubectl get netpol                    # Get Network Policies


    kubectl apply -f .                    # Apply all scripts in this folder and sub folders
    kubectl delete -f .                   # Delete all scripts in this folder and sub folders


    kubectl describe nodes <node-name>
    kubectl describe pods <pod-name>
    kubectl describe pods <rc-name>       # Lists pods created by <rc-name> using common prefix


    kubectl cp <file> <pod>:<file_path>
    kubectl exec -it <pod> -- /bin/bash
    kubectl exec -it <pod> --container=<container> /bin/sh

More from David Strain
All posts