Room 02
KUBECTL BASICS
The Command Center
- You’ve entered the K8s command center, but the controls are locked.
- To unlock them, you must prove you can navigate the cluster using
kubectl. - A secret message has been hidden across multiple resources - find it!
📜 Mission Briefing
- List all namespaces in the cluster.
- A special namespace called
escape-datacontains hidden pods. - Describe the pod named
secret-carrierin theescape-datanamespace. - Look at the pod’s labels - find the label with key
password. - The label value is your password for the next room.
hint:
kubectl describe podshows all labels in the metadata section
Key Commands
| Command | Purpose |
|---|---|
kubectl get namespaces |
List all namespaces |
kubectl get ns |
Short form for namespaces |
kubectl get pods -n NAMESPACE |
List pods in a namespace |
kubectl describe pod NAME -n NS |
Detailed pod info |
kubectl get pod NAME -o yaml |
Pod manifest as YAML |
kubectl get pod NAME -o json |
Pod manifest as JSON |
kubectl get pod NAME -o jsonpath='{.metadata.labels}' |
Extract labels |
kubectl explain pod |
API docs for pod resource |
kubectl api-resources |
List all resource types |
kubectl get all -n NS |
List common resources |
How kubectl Works
# kubectl follows the pattern: kubectl <verb> <resource> [name] [flags]
# Verbs: get, describe, create, apply, delete, edit, logs, exec, port-forward
# GET: List resources
kubectl get pods # pods in current namespace
kubectl get pods -n kube-system # pods in specific namespace
kubectl get pods -A # pods in ALL namespaces
kubectl get pods -o wide # extra columns (IP, node, etc.)
kubectl get pods -o yaml # full YAML output
kubectl get pods -o json # full JSON output
kubectl get pods --show-labels # show all labels
kubectl get pods -l app=nginx # filter by label
kubectl get pods --sort-by=.status.startTime # sort output
# DESCRIBE: Detailed info about a resource
kubectl describe pod my-pod # events, conditions, volumes
kubectl describe node my-node # node capacity, allocations
kubectl describe svc my-service # endpoints, ports
# OUTPUT FORMATTING
kubectl get pods -o name # just resource names
kubectl get pods -o jsonpath='{.items[*].metadata.name}' # jsonpath query
kubectl get pods -o custom-columns=NAME:.metadata.name,STATUS:.status.phase
# EXPLAIN: Built-in API documentation
kubectl explain pod # top-level fields
kubectl explain pod.spec # spec fields
kubectl explain pod.spec.containers # container spec
Hints
Hint 2
Get the pod in the escape-data namespace:
Hint 3
Extract the password label directly: