Note: The Listed platform will permanently shut down December 31, 2026. Your data published on Listed will still be available in your personal Standard Notes account. Learn more

Kubectl Cheatsheet

GENERAL

    kubectl version
    kubectl cluster-info

CONTEXT

    kubectl config current-context
    kubectl config use-context cp08

INFORMATION

    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

APPLY

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

VERBOSE

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

OTHER

    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