Skip to content

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

  1. List all namespaces in the cluster.
  2. A special namespace called escape-data contains hidden pods.
  3. Describe the pod named secret-carrier in the escape-data namespace.
  4. Look at the pod’s labels - find the label with key password.
  5. The label value is your password for the next room.

    hint: kubectl describe pod shows 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 1

First, list namespaces to find escape-data:

kubectl get namespaces

Hint 2

Get the pod in the escape-data namespace:

kubectl get pods -n escape-data
kubectl describe pod secret-carrier -n escape-data

Hint 3

Extract the password label directly:

kubectl get pod secret-carrier -n escape-data -o jsonpath='{.metadata.labels.password}'


🔓 Unlock Room 03

Once you have the password, decrypt the next room’s README:

openssl enc -aes-256-cbc -d -a -pbkdf2 \
        -in ../room_03/README             \
        -out ../room_03/README.txt        \
        -pass pass:PASSWORD

cat ../room_03/README.txt