Skip to main content

The Apollo11 Kubernetes Command Reference

Commands grouped by task. Namespaces: apollo-airlines (Stage 1), apollo-airlines-apps / -ui (Stage 2+), apollo-observability (Stage 6+).


🏗️ 1. Cluster & Node Operations (kind & kubectl)​

Managing Local Clusters​

# Create the 3-node Apollo11 cluster with port mappings
kind create cluster --config stages/ignition/kind-config.yaml

# List running kind clusters
kind get clusters

# Load a locally built Docker image into kind worker nodes
kind load docker-image apollo11/booking:latest --name apollo11

# Delete the kind cluster completely
kind delete cluster --name apollo11

Contexts & Multiple Clusters​

See Contexts and a second cluster.

# Which cluster will the next command hit?
kubectl config current-context
# List every context (cluster + user + namespace) in your kubeconfig
kubectl config get-contexts
# Switch the current context (affects every terminal and tool)
kubectl config use-context kind-apollo11
# Run one command against another cluster without switching
kubectl --context kind-apollo11-sandbox get nodes
# Remember a default namespace on the current context
kubectl config set-context --current --namespace=apollo-airlines
# Show only the current context's cluster, user and namespace
kubectl config view --minify

Terminal & Graphical UIs​

See the k9s and Headlamp tutorials.

# k9s, read-only, on a given context and namespace
k9s --context kind-apollo11 -n apollo-airlines --readonly
# Inside k9s: :pods :deploy :svc :ctx / filter d describe y YAML l logs Shift-J owner ? help

Node Inspection & Taints​

# View all nodes with roles, status, and IP addresses
kubectl get nodes -o wide

# View node labels
kubectl get nodes --show-labels

# Taint a worker node (repel non-tolerating pods)
kubectl taint node apollo11-worker workload=search:NoSchedule

# Remove a taint from a node (note the trailing minus '-')
kubectl taint node apollo11-worker workload=search:NoSchedule-

# Safely drain a node for maintenance (evicts pods respecting PDBs)
kubectl drain apollo11-worker --ignore-daemonsets --delete-emptydir-data

# Mark a node schedulable again after maintenance
kubectl uncordon apollo11-worker

🔎 2. Inspecting Workloads & Resources​

# Get all resources in the apps namespace
kubectl get all -n apollo-airlines-apps

# Filter resources by label selector
kubectl get pods -n apollo-airlines-apps -l app=booking

# Print custom columns (e.g. Pod Name, Node, and QoS Class)
kubectl get pods -n apollo-airlines-apps -o custom-columns=\
'NAME:.metadata.name,NODE:.spec.nodeName,QOS:.status.qosClass'

# Extract a specific field using JSONPath (e.g. all container images)
kubectl get pods -n apollo-airlines-apps \
-o jsonpath='{range .items[*]}{.metadata.name}{": "}{.spec.containers[*].image}{"\n"}{end}'

# Watch pod status transitions in real time
kubectl get pods -n apollo-airlines-apps -w

# Describe full resource specifications, status conditions, and events
kubectl describe deployment booking -n apollo-airlines-apps
kubectl describe pod <pod-name> -n apollo-airlines-apps

🔄 3. Deploying, Updating & Rollbacks​

# Apply a declarative manifest or directory
kubectl apply -f stages/stage1/k8s/apps/booking/booking-dep.yaml
kubectl apply -k stages/stage5/overlays/dev/

# Preview changes without applying (dry run)
kubectl apply --dry-run=client -f stages/stage1/k8s/apps/booking/booking-dep.yaml

# Update a container image imperatively
kubectl set image deployment/booking booking=apollo11/booking:v1.1.0 -n apollo-airlines-apps

# Monitor rollout progression until completion
kubectl rollout status deployment/booking -n apollo-airlines-apps

# View deployment revision history
kubectl rollout history deployment/booking -n apollo-airlines-apps

# Undo a failed rollout (rollback to previous stable revision)
kubectl rollout undo deployment/booking -n apollo-airlines-apps

# Request a rolling restart (availability depends on replicas, readiness, and strategy)
kubectl rollout restart deployment/booking -n apollo-airlines-apps

# Scale replicas imperatively
kubectl scale deployment/booking --replicas=4 -n apollo-airlines-apps

🩺 4. Debugging, Logs & Execution​

# View recent stdout/stderr logs of a Pod
kubectl logs <pod-name> -n apollo-airlines-apps

# Stream logs in real time
kubectl logs -f <pod-name> -n apollo-airlines-apps

# View logs from a previously crashed container (vital for CrashLoopBackOff!)
kubectl logs <pod-name> -n apollo-airlines-apps --previous

# Stream combined logs for all pods matching a label
kubectl logs -n apollo-airlines-apps -l app=booking --tail=50 -f

# Execute an interactive shell inside a running container
kubectl exec -it <pod-name> -n apollo-airlines-apps -- /bin/sh

# Run a single command inside a container without an interactive TTY
kubectl exec -n apollo-airlines-apps identity-db-0 -- \
psql -U postgres -d identity -c "SELECT count(*) FROM users;"

# Forward a local port directly to a private cluster Pod
kubectl port-forward pod/booking-xxx 18082:8082 -n apollo-airlines-apps

# Forward a local port to a Service or Gateway
kubectl port-forward svc/grafana 3000:3000 -n apollo-observability

🌐 5. Networking & Gateway API​

# List all Services with their ClusterIPs and NodePorts
kubectl get svc -A

# Inspect auto-generated endpoints tracking healthy Pods
kubectl get endpoints -n apollo-airlines-apps
kubectl get endpointslices -n apollo-airlines-apps

# Inspect Gateway API infrastructure
kubectl get gatewayclass
kubectl get gateway -A
kubectl get httproutes -A
kubectl get referencegrants -A

# Check conditions on Envoy Gateway (verify Programmed=True)
kubectl describe gateway apollo-gateway -n apollo-airlines-apps

# Retrieve the external LoadBalancer IP assigned by MetalLB
kubectl get gateway apollo-gateway -n apollo-airlines-apps \
-o jsonpath='{.status.addresses[0].value}'

💾 6. StatefulSets & Storage​

# List StatefulSets and their replicas
kubectl get statefulsets -n apollo-airlines-apps

# List PersistentVolumeClaims (PVCs) and binding status
kubectl get pvc -n apollo-airlines-apps

# List physical PersistentVolumes (PVs) and reclaim policies
kubectl get pv

# View available StorageClasses and provisioners
kubectl get storageclass

📦 7. Helm Release Management​

# Check syntax and validate a chart
helm lint stages/stage5/helm/apollo11

# Render templates locally to inspect generated YAML
helm template apollo11 stages/stage5/helm/apollo11 \
-f stages/stage5/helm/apollo11/values-dev.yaml

# Install a chart with environment overrides
helm install apollo11 stages/stage5/helm/apollo11 \
-f stages/stage5/helm/apollo11/values-dev.yaml \
-n apollo-airlines-apps

# Upgrade an existing release
helm upgrade apollo11 stages/stage5/helm/apollo11 \
-f stages/stage5/helm/apollo11/values-prod.yaml \
-n apollo-airlines-apps

# View release revision history
helm history apollo11 -n apollo-airlines-apps

# Roll back to a previous revision
helm rollback apollo11 1 -n apollo-airlines-apps

# Uninstall a release
helm uninstall apollo11 -n apollo-airlines-apps

📈 8. Metrics, Autoscaling & Resources​

# Check CPU and memory consumption across worker nodes
kubectl top nodes

# Check live CPU and memory consumption across Pods
kubectl top pods -n apollo-airlines-apps

# Inspect Horizontal Pod Autoscalers (HPA)
kubectl get hpa -A
kubectl describe hpa search-hpa -n apollo-airlines-apps

# Inspect Vertical Pod Autoscaler (VPA) recommendations
kubectl get vpa -A -o yaml

# Query the raw Metrics API endpoint
kubectl get --raw /apis/metrics.k8s.io/v1beta1/namespaces/apollo-airlines-apps/pods

🐳 9. Docker & Docker Compose (Launchpad)​

# Build and launch Apollo Airlines in background
docker compose up --build -d

# Inspect running container status and health
docker compose ps

# Follow container logs
docker compose logs -f booking

# Inspect the bridge network and container IPs
docker network inspect launchpad_apollo-airlines

# Stop containers without removing persistent named volumes
docker compose down

# Stop containers and DESTROY all persistent volumes
docker compose down -v

🔬 10. Stage-specific one-liners​

# Which container runtime view does a node have of a Pod? (kind nodes are containers)
docker exec apollo11-worker crictl ps --name <container>

# Which component produced these events? (From column)
kubectl describe pod <pod> | sed -n '/^Events:/,$p'

# EndpointSlice readiness per address
kubectl get endpointslice -n <ns> -l kubernetes.io/service-name=<svc> \
-o jsonpath='{range .items[*].endpoints[*]}{.addresses[0]} ready={.conditions.ready}{"\n"}{end}'

# Voluntary eviction through the Eviction API (respects PDBs)
kubectl create --raw "/api/v1/namespaces/<ns>/pods/<pod>/eviction" -f - <<JSON
{"apiVersion":"policy/v1","kind":"Eviction","metadata":{"name":"<pod>","namespace":"<ns>"}}
JSON

# Redis cache inspection
kubectl exec -n apollo-airlines-apps redis-0 -- redis-cli keys 'search:*'
kubectl exec -n apollo-airlines-apps redis-0 -- redis-cli ttl "search:BOM:SIN:$(date -u +%F)"

# Helm: fail loudly and roll back automatically
helm upgrade <rel> <chart> -f values.yaml --atomic --timeout 60s

# Render without touching the cluster
helm template <rel> <chart> -f values.yaml | grep -E 'replicas|image:'
kubectl kustomize <overlay-dir>

# Cordon / uncordon to test volume-node pinning
kubectl cordon <node>; kubectl uncordon <node>

# Gateway API conditions
kubectl get httproute <name> -n <ns> -o jsonpath='{range .status.parents[0].conditions[*]}{.type}={.status}({.reason}) {end}{"\n"}'