# Full cluster summary in one linekubectlgetall-A
kubectlgetnodes-owide
# Filter by labelkubectlgetpods-lapp=payments,env=prod-A
# Field selection with JSONPath (one of the most powerful weapons)kubectlgetpods-ojsonpath='{.items[*].spec.nodeName}'kubectlgetpods-ojsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.phase}{"\n"}{end}'# Sorted outputkubectlgetpods--sort-by=.status.startTime
kubectlgetpods--sort-by=.metadata.creationTimestamp
# Container images (drift check)kubectlgetpods-A-ojsonpath='{range .items[*]}{.metadata.namespace}{"\t"}{.metadata.name}{"\t"}{.spec.containers[*].image}{"\n"}{end}'|sort-u
# Events for pending podskubectlgetevents-A--field-selectortype=Warning--sort-by='.lastTimestamp'# Pods in CrashLoopBackOffkubectlgetpods-A|grep-E'CrashLoop|Error|Pending'
# Check pod logskubectllogs<POD>-c<CONTAINER># single containerkubectllogs<POD>--all-containers--previous# previous run of a crashed podkubectllogs<POD>-f--tail=100--since=10m
# Get into the pod (if the image has a shell)kubectlexec-it<POD>--/bin/sh
# If the image has no shell: ephemeral debug containerkubectldebug-it<POD>--image=busybox--target=<CONTAINER>
kubectldebug-it<POD>--image=nicolaka/netshoot--target=<CONTAINER>
# Debug with a copy of the pod (say the init container crashed)kubectldebug<POD>-it--copy-to=debug-pod--container=<CONTAINER>--/bin/sh
# Attach a debug container to the node (to see the host network)kubectldebugnode/<NODE>-it--image=ubuntu
# Resource describe (fastest way to catch events)kubectldescribepod<POD>
kubectldescribenode<NODE>
# Port-forward (from local to cluster)kubectlport-forwardpod/<POD>8080:80
kubectlport-forwardsvc/<SVC>8080:80
kubectlport-forwarddeployment/<NAME>8080:8080
# Test service accesskubectlrun-it--rmdebug--image=busybox--sh
# inside: wget -qO- http://<SVC>.<NS>.svc.cluster.local# DNS testkubectlrun-it--rmdns-test--image=busybox--nslookup<SVC>.<NS>
# NetworkPolicy debugkubectlrun-it--rmnetshoot--image=nicolaka/netshoot--bash
# inside: ping, dig, curl, traceroute, mtr are all there
# Create a secret (literal)kubectlcreatesecretgenericdb-creds\--from-literal=user=appuser\--from-literal=password='<PASSWORD>'# Create a secret (from a file)kubectlcreatesecretgenerictls--from-file=tls.crt--from-file=tls.key
# Decode a secret valuekubectlgetsecret<NAME>-ojsonpath='{.data.password}'|base64-d
# ConfigMap from filekubectlcreateconfigmapapp-config--from-file=app.conf
kubectlcreateconfigmapapp-config--from-env-file=.env