Basic Bash – CKA Practice Questions
20 hands-on scenarios testing essential bash skills for the CKA exam.
Question 1: Extract Pod Names from Specific Namespace
Task:
- Get all pod names from the
kube-systemnamespace - Output ONLY the pod names (no headers, no other columns)
- One name per line
Question 2: Count Running Pods
Task:
- Count how many pods are in
Runningstate across ALL namespaces - Output should be a single number
Question 3: Find Pods on Specific Node
Task:
- List all pod names running on node
worker-1 - Show only pod names, one per line
- Search across all namespaces
Question 4: Extract Container Images
Task:
- Get all unique container images used across all pods in the cluster
- Remove duplicates
- Sort alphabetically
Question 5: Filter Pods by Label
Task:
- Get all pods with label
app=nginx - Extract ONLY the pod name and IP address
- Format:
pod-name IP-address(space-separated)
Question 6: Decode Secret Value
Task:
- Given a secret named
db-credswith keypassword - Decode and display the actual password value
- Should show plain text, not base64
Question 7: Find Failed Pods
Task:
- List all pods that are NOT in
RunningorCompletedstate - Show namespace, pod name, and status
- Format as a table with columns aligned
Question 8: Extract Node Internal IPs
Task:
- Get the Internal IP address of all nodes
- Output only IP addresses, one per line
- No headers or extra text
Question 9: Count Pods Per Namespace
Task:
- Show count of pods in each namespace
- Format:
count namespace-name - Sort by count (descending)
Question 10: Modify Deployment Replicas (File Edit)
Task:
- You have a file
deployment.yamlwithreplicas: 3 - Change it to
replicas: 5using command-line tool - Verify the change was made
Question 11: Extract Events for Failing Pod
Task:
- Get Events section from
kubectl describe pod failing-pod - Show only the last 10 events
- No other output
Question 12: Find Largest Log File
Task:
- Search
/var/logdirectory - Find the largest
.logfile - Output filename and size
Question 13: Get Pod Resource Requests
Task:
- For pod
web-app, extract CPU and Memory requests - Output format:
CPU: <value> Memory: <value>
Question 14: List Pods Sorted by Age
Task:
- Get all pods with their age
- Sort by age (oldest first)
- Show: namespace, name, age
Question 15: Batch Delete Pods by Pattern
Task:
- Delete all pods whose names start with
test- - Use a loop
- Confirm deletion
Question 16: Extract ConfigMap Keys
Task:
- Given ConfigMap
app-config - List all keys (not values) in the ConfigMap
- One key per line
Question 17: Find Pods Using Specific Image
Task:
- Find all pods using image
nginx:1.19 - Show pod name and namespace
- Search across all namespaces
Question 18: Monitor Log File for Errors
Task:
- Continuously monitor file
/var/log/app.log - Show only lines containing "ERROR"
- Display in real-time as errors occur
Question 19: Export Running Pod YAML
Task:
- Get the YAML definition of running pod
api-server - Remove all status and metadata fields (clean export)
- Save to file
api-server-clean.yaml
Question 20: Calculate Total CPU Requests
Task:
- Get CPU requests for all pods in namespace
production - Sum them up
- Display total in millicores
Quick Reference
| Task | Likely Tools |
|---|---|
| Extract columns | awk, cut, custom-columns |
| Filter lines | grep, awk |
| Count occurrences | wc -l, uniq -c |
| JSON extraction | jsonpath, jq |
| Text replacement | sed |
| Sort/unique | sort, uniq |
| Loops | for, while read |
| Real-time monitoring | tail -f, kubectl logs -f |