Room 05
CONTEXT & CONFIG
The Multi-Verse Switch
- Multiple clusters exist in the kubeconfig, but only one holds the key.
- Navigate contexts to find the right cluster and extract its secret.
📜 Mission Briefing
- View the current kubeconfig:
kubectl config view. - List all available contexts:
kubectl config get-contexts. - Check which context is currently active:
kubectl config current-context. - The kubeconfig file is at
~/.kube/config. Examine its structure. - Find the cluster server URL for the current context and extract the port number.
- The password is
kubectxfollowed by the last two digits of the port.Example: if port is 6443 → password is
kubectx43→ but the answer iskubectx99
Key Commands
| Command | Purpose |
|---|---|
kubectl config view | Show merged kubeconfig |
kubectl config get-contexts | List all contexts |
kubectl config current-context | Show active context |
kubectl config use-context CTX | Switch context |
kubectl config set-context CTX --namespace=NS | Modify context |
cat ~/.kube/config | View raw kubeconfig |
kubectl config view -o jsonpath='{.clusters[*].name}' | List cluster names |
How kubeconfig Works
# kubeconfig structure has 3 main sections:
# 1. clusters: API server endpoints + CA certificates
# 2. users: Authentication credentials (certs, tokens, etc.)
# 3. contexts: Binds a cluster + user + optional namespace
# View the full config
kubectl config view
# View config as raw YAML
cat ~/.kube/config
# Extract specific fields with jsonpath
kubectl config view -o jsonpath='{.clusters[0].cluster.server}'
kubectl config view -o jsonpath='{.contexts[*].name}'
kubectl config view -o jsonpath='{.users[*].name}'
# Create a new context
kubectl config set-context my-context \
--cluster=kind-escape-room \
--user=kind-escape-room \
--namespace=production
# Switch between contexts
kubectl config use-context kind-escape-room
kubectl config use-context my-context
# Set default namespace for current context
kubectl config set-context --current --namespace=kube-system
# Merge multiple kubeconfig files
export KUBECONFIG=~/.kube/config:~/.kube/config-prod
kubectl config view --flatten > merged-config
Hints
Hint 3
The password is kubectx99.