Kubernetes Networking, Storage, and Config Cheat Sheet

Services, ingress, EndpointSlices, network policies, PVCs, PVs, storage classes, ConfigMaps, Secrets, and nodes.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all
## Services and Ingress
List services
kubectl get services -A

# Show services across namespaces.

Describe service
kubectl describe service web -n payments

# Inspect selectors, endpoints, ports, and type.

List endpoints
kubectl get endpoints -n payments

# Show service endpoint IPs.

List EndpointSlices
kubectl get endpointslices -n payments

# Inspect EndpointSlice objects used for service discovery.

List ingresses
kubectl get ingress -A

# Show ingress resources across namespaces.

Describe ingress
kubectl describe ingress web -n payments

# Inspect rules, backends, and events.

Port-forward deployment
kubectl port-forward deployment/web 8080:8080 -n payments

# Forward to a selected pod from a deployment.

Expose pod as service
kubectl expose pod debug-shell --port=8080 --target-port=8080 --name=debug-shell-svc -n tools

# Create a service from an existing pod.

## Network Policy
List network policies
kubectl get networkpolicies -A

# Show NetworkPolicy resources.

Describe network policy
kubectl describe networkpolicy default-deny -n payments

# Inspect ingress and egress rules.

Apply network policy
kubectl apply -f networkpolicy.yaml

# Create or update a NetworkPolicy manifest.

Delete network policy
kubectl delete networkpolicy allow-metrics -n observability

# Remove a NetworkPolicy.

## Persistent Storage
List PVCs
kubectl get pvc -A

# Show PersistentVolumeClaims across namespaces.

Describe PVC
kubectl describe pvc data-postgres-0 -n data

# Inspect requested storage, status, and bound PV.

List PVs
kubectl get pv

# Show cluster-wide PersistentVolumes.

Describe PV
kubectl describe pv pvc-12345678

# Inspect reclaim policy, claim ref, and backing class.

List storage classes
kubectl get storageclass

# Show available StorageClasses.

Describe storage class
kubectl describe storageclass gp3

# Inspect provisioner and mount options.

Expand PVC size
kubectl patch pvc data-postgres-0 -n data -p '{"spec":{"resources":{"requests":{"storage":"200Gi"}}}}'

# Request a larger PVC size when the class supports expansion.

Delete PVC
kubectl delete pvc cache-data -n payments

# Remove a PVC; PV behavior depends on reclaim policy.

## ConfigMaps and Secrets
List configmaps
kubectl get configmaps -A

# Show ConfigMaps across namespaces.

Describe configmap
kubectl describe configmap app-config -n payments

# Inspect key-value data and metadata.

Edit configmap
kubectl edit configmap app-config -n payments

# Update a ConfigMap live.

List secrets
kubectl get secrets -A

# Show Secrets across namespaces.

Describe secret
kubectl describe secret app-secret -n payments

# Inspect secret type and key names without dumping values.

Get secret key (base64)
kubectl get secret app-secret -n payments -o jsonpath='{.data.API_KEY}'

# Print a base64-encoded secret value.

Get decoded secret key
kubectl get secret app-secret -n payments -o jsonpath='{.data.API_KEY}' | base64 --decode

# Print a decoded secret value locally.

Create secret from env file
kubectl create secret generic app-env --from-env-file=.env.production -n payments

# Create a secret from an env file.

## Nodes, Taints, and Scheduling Controls
List nodes
kubectl get nodes -o wide

# Show node roles, versions, and internal IPs.

Describe node
kubectl describe node worker-02

# Inspect capacity, allocatable, taints, and conditions.

Add taint to node
kubectl taint nodes worker-02 dedicated=ml:NoSchedule

# Add a taint to influence scheduling.

Remove taint from node
kubectl taint nodes worker-02 dedicated=ml:NoSchedule-

# Remove a taint from a node.

Label node
kubectl label node worker-02 nodepool=general --overwrite

# Apply a scheduling label to a node.

List pods on node
kubectl get pods -A --field-selector spec.nodeName=worker-02 -o wide

# See what is scheduled on a node.