Skip to content

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:

  1. Get all pod names from the kube-system namespace
  2. Output ONLY the pod names (no headers, no other columns)
  3. One name per line

Question 2: Count Running Pods

Task:

  1. Count how many pods are in Running state across ALL namespaces
  2. Output should be a single number

Question 3: Find Pods on Specific Node

Task:

  1. List all pod names running on node worker-1
  2. Show only pod names, one per line
  3. Search across all namespaces

Question 4: Extract Container Images

Task:

  1. Get all unique container images used across all pods in the cluster
  2. Remove duplicates
  3. Sort alphabetically

Question 5: Filter Pods by Label

Task:

  1. Get all pods with label app=nginx
  2. Extract ONLY the pod name and IP address
  3. Format: pod-name IP-address (space-separated)

Question 6: Decode Secret Value

Task:

  1. Given a secret named db-creds with key password
  2. Decode and display the actual password value
  3. Should show plain text, not base64

Question 7: Find Failed Pods

Task:

  1. List all pods that are NOT in Running or Completed state
  2. Show namespace, pod name, and status
  3. Format as a table with columns aligned

Question 8: Extract Node Internal IPs

Task:

  1. Get the Internal IP address of all nodes
  2. Output only IP addresses, one per line
  3. No headers or extra text

Question 9: Count Pods Per Namespace

Task:

  1. Show count of pods in each namespace
  2. Format: count namespace-name
  3. Sort by count (descending)

Question 10: Modify Deployment Replicas (File Edit)

Task:

  1. You have a file deployment.yaml with replicas: 3
  2. Change it to replicas: 5 using command-line tool
  3. Verify the change was made

Question 11: Extract Events for Failing Pod

Task:

  1. Get Events section from kubectl describe pod failing-pod
  2. Show only the last 10 events
  3. No other output

Question 12: Find Largest Log File

Task:

  1. Search /var/log directory
  2. Find the largest .log file
  3. Output filename and size

Question 13: Get Pod Resource Requests

Task:

  1. For pod web-app, extract CPU and Memory requests
  2. Output format: CPU: <value> Memory: <value>

Question 14: List Pods Sorted by Age

Task:

  1. Get all pods with their age
  2. Sort by age (oldest first)
  3. Show: namespace, name, age

Question 15: Batch Delete Pods by Pattern

Task:

  1. Delete all pods whose names start with test-
  2. Use a loop
  3. Confirm deletion

Question 16: Extract ConfigMap Keys

Task:

  1. Given ConfigMap app-config
  2. List all keys (not values) in the ConfigMap
  3. One key per line

Question 17: Find Pods Using Specific Image

Task:

  1. Find all pods using image nginx:1.19
  2. Show pod name and namespace
  3. Search across all namespaces

Question 18: Monitor Log File for Errors

Task:

  1. Continuously monitor file /var/log/app.log
  2. Show only lines containing "ERROR"
  3. Display in real-time as errors occur

Question 19: Export Running Pod YAML

Task:

  1. Get the YAML definition of running pod api-server
  2. Remove all status and metadata fields (clean export)
  3. Save to file api-server-clean.yaml

Question 20: Calculate Total CPU Requests

Task:

  1. Get CPU requests for all pods in namespace production
  2. Sum them up
  3. Display total in millicores

Quick Reference

TaskLikely Tools
Extract columnsawk, cut, custom-columns
Filter linesgrep, awk
Count occurrenceswc -l, uniq -c
JSON extractionjsonpath, jq
Text replacementsed
Sort/uniquesort, uniq
Loopsfor, while read
Real-time monitoringtail -f, kubectl logs -f

Released under the MIT License.