cheatsheet.antonnovikov.com

DevOps cheatsheet

1,661 commands across 116 tools, each with a one-line explanation. Search, filter by tool or tag; click a command to copy it.

Commands 1,661 shown

  • kubectl get pods -A -o wide

    All pods with node placement and IPs

  • kubectl describe pod <name> -n <ns>

    Full details: events, conditions, volume mounts

  • kubectl logs -f <pod> -n <ns>

    Stream logs in real time; add -c <container> for multi-container pods

  • kubectl logs <pod> --previous -n <ns>

    Logs from the last crashed/restarted container instance

  • kubectl exec -it <pod> -n <ns> -- bash

    Interactive shell inside a running container

  • kubectl port-forward svc/<name> 8080:80 -n <ns>

    Tunnel a cluster service port to localhost

  • kubectl rollout status deployment/<name> -n <ns>

    Block until rollout completes or times out (use in CI)

  • kubectl rollout undo deployment/<name> -n <ns>

    Revert to the previous revision

  • kubectl scale deployment/<name> --replicas=3 -n <ns>

    Immediately change replica count

  • kubectl get events -A --sort-by='.lastTimestamp'

    Recent cluster events, oldest first — great for post-incident review

  • kubectl apply --server-side --dry-run=server -f file.yaml

    Validate manifest against live API without applying changes

  • kubectl get deployment/<name> -n <ns> -o yaml

    Current live state with managed fields stripped; useful as a base

  • kubectl delete pod <name> -n <ns> --grace-period=0 --force

    Remove a Terminating pod immediately (use with caution)

  • kubectl cp <ns>/<pod>:/remote/path ./local-path

    Extract a file from a running container

  • kubectl cordon <node>

    Mark node as unschedulable — no new pods land here

  • kubectl drain <node> --ignore-daemonsets --delete-emptydir-data

    Gracefully evict all pods before maintenance

  • kubectl edit deployment/<name> -n <ns>

    Open resource in $EDITOR; changes applied on save

  • kubectl auth can-i list pods --as=system:serviceaccount:<ns>:<sa> -n <ns>

    Check what a ServiceAccount is allowed to do

  • helm install <release> <chart> -f values.yaml -n <ns> --create-namespace

    Deploy a chart; creates namespace if it doesn't exist

  • helm upgrade --install <release> <chart> -f values.yaml -n <ns>

    Safe in CI — installs if absent, upgrades if present

  • helm diff upgrade <release> <chart> -f values.yaml -n <ns>

    Show exactly what will change (requires helm-diff plugin)

  • helm template <release> <chart> -f values.yaml --debug

    Output rendered YAML to stdout without deploying

  • helm get values <release> -n <ns> --all

    All computed values for a deployed release

  • helm list -A --output table

    All Helm releases across every namespace

  • helm rollback <release> <revision> -n <ns>

    Revert to a specific historical revision

  • helm uninstall <release> -n <ns>

    Remove release and all managed resources

  • helm lint <chart-dir> -f values.yaml --strict

    Validate chart structure and values; fails on warnings in --strict mode

  • flux check

    Verify all Flux controllers are running and CRDs are installed

  • flux get all -A

    Summary table: Kustomizations, HelmReleases, Sources — with sync status

  • flux reconcile kustomization <name> --with-source -n <ns>

    Trigger immediate git pull + apply

  • flux reconcile helmrelease <name> --with-source -n <ns>

    Re-run Helm install/upgrade cycle immediately

  • flux trace <kind>/<name> -n <ns>

    Show which Flux objects own and manage this resource

  • flux suspend kustomization <name> -n <ns>

    Pause sync — useful while doing manual hotfixes

  • flux resume kustomization <name> -n <ns>

    Re-enable a suspended Kustomization or HelmRelease

  • flux export kustomization --all > clusters/cluster.yaml

    Backup current Flux config as plain YAML for bootstrapping another cluster

  • docker buildx build --platform linux/amd64,linux/arm64 -t reg/img:tag --push .

    Cross-compile and push directly to registry with BuildKit

  • docker run --rm -it --env-file .env -p 8000:8000 img:tag

    Local run with env vars from file; --rm auto-removes on exit

  • docker history --no-trunc img:tag

    See each layer, its command, and size; identify bloat

  • docker system prune -af --volumes

    Remove stopped containers, unused images, networks, volumes

  • docker pull src-reg/img:tag && docker tag src-reg/img:tag dst-reg/img:tag && docker push dst-reg/img:tag

    Re-tag and push to another registry

  • docker save img:tag | gzip > img.tar.gz

    Export an image for air-gapped transfer

  • terraform plan -var-file=prod.tfvars -out=plan.tfplan

    Show changes; save plan artifact for CI gating

  • terraform apply plan.tfplan

    Apply exactly the previously generated plan — no interactive prompts

  • terraform import module.path.resource_type.name <remote-id>

    Bring an already-existing resource under Terraform control

  • terraform state show module.path.resource_type.name

    Inspect Terraform state attributes for a single resource

  • terraform state mv old.address new.address

    Rename/reorganize resource without destroying and recreating it

  • kubectl debug -it <pod> --image=nicolaka/netshoot -n <ns>

    Attach a debug container (netshoot) to a running pod — shares PID/net namespaces

  • kubectl top nodes

    CPU and memory per node (requires metrics-server)

  • kubectl top pods -A --sort-by=memory

    Memory-sorted pod usage across all namespaces — find the hungry ones

  • kubectl get cm <name> -n <ns> -o jsonpath='{.data}'

    Print just the data field; pipe to python -m json.tool for formatting

  • kubectl get secret <name> -n <ns> -o jsonpath='{.data}' | python3 -c "import sys,json,base64; [print(k,'=',base64.b64decode(v).decode()) for k,v in json.load(sys.stdin).items()]"

    Dump and base64-decode all fields in a k8s Secret

  • kubectl api-resources --verbs=list --namespaced -o name | xargs -I{} kubectl get {} -n <ns> --ignore-not-found

    Enumerate every resource type in a namespace — useful for auditing

  • kubectl get pods -A -o jsonpath='{range .items[*]}{.metadata.namespace}\t{.metadata.name}\t{.status.phase}\n{end}'

    Extract specific fields from k8s API objects without jq

  • kubectl get pods -n <ns> -o custom-columns='NAME:.metadata.name,NODE:.spec.nodeName,STATUS:.status.phase'

    Print only the fields you care about without jq

  • kubectl patch deployment <name> -n <ns> -p '{"spec":{"replicas":2}}'

    Inline JSON patch without editing the whole manifest

  • kubectl annotate pod <pod> -n <ns> key=value --overwrite

    Set or update an annotation; --overwrite replaces existing value

  • kubectl label node <node> role=worker --overwrite

    Add or change a label on any resource

  • kubectl taint nodes <node> key=value:NoSchedule

    Prevent pods without matching toleration from scheduling on node

  • kubectl taint nodes <node> key=value:NoSchedule-

    Remove a taint by appending a dash at the end

  • kubectl set image deployment/<name> <container>=image:tag -n <ns>

    Rolling-update the container image without editing YAML