🎯 CKA Practice Questions: Pods, Services & Ingress¶
Each question mimics real CKA exam scenarios. If you want, I can also verify your YAML or solution attempts.
📦 PODS¶
✅ Q1: Basic Pod Creation¶
Create a pod named
web-podin thedefaultnamespace using the imagenginx:alpine. Expose port 80 in the pod.
✅ Bonus: Ensure it's running and accessible using kubectl exec.
✅ Q2: Pod with Commands¶
Create a pod named
counter-podthat uses thebusyboximage and runs this command on start:
while true; do echo "CKA Ready"; sleep 5; done
✅ Verify logs show CKA Ready.
✅ Q3: Pod in Custom Namespace¶
Create a new namespace
ckanamespace, then deploy a pod namedmypodin it with imagehttpd.
🌐 SERVICES¶
✅ Q4: Expose a Pod with ClusterIP¶
Use
kubectl runto create a podnginx-podusing imagenginx, then expose it on port 80 using a ClusterIP service namednginx-service.
✅ Verify the service is reachable from inside a test pod.
✅ Q5: Create a NodePort Service¶
You already have a pod
amorin namespaceamor. Create a NodePort serviceamor-accessexposing it on target port 8081 and node port 30001.
✅ Confirm external access using curl from outside the cluster.
✅ Q6: Service with Custom Labels¶
Deploy a pod with:
labels:
tier: backend
env: staging
Then, create a service backend-svc that only targets this pod using the appropriate label selectors.
🚪 INGRESS¶
✅ Q7: Simple Ingress Rule¶
You already have a deployment
amorwith serviceamorin namespaceamor. Create an Ingress resource:
- Host:
demo.ckatest.com - Path:
/amor - Service:
amor - Port:
80
✅ Add demo.ckatest.com to your /etc/hosts pointing to the node IP if testing from local laptop.
✅ Q8: Multi-path Ingress¶
Create 2 deployments and services in namespace
webapp:
frontend: imagenginxbackend: imagehttpd
Then create an Ingress:
/frontend→ servicefrontend, port 80/backend→ servicebackend, port 80
✅ Test using curl with path-based routing.
✅ Q9: Ingress with TLS (Advanced)¶
You have cert-manager and an IngressController installed. Create a secret named
tls-secretin namespacedefaultcontaining TLS cert+key. Then:
- Create an Ingress for host
secure.ckatest.com - Attach the TLS secret
- Route
/path to a service calledsecure-svcon port 443
✅ Test with:
curl https://secure.ckatest.com --resolve secure.ckatest.com:<port>:<node-ip> --insecure
✅ Pods – Hands-on Questions¶
- Create a pod named
nginx-podusing thenginximage. - Create a pod that runs a
busyboxcontainer and sleeps for 3600 seconds. - Create a pod with two containers:
nginxandbusybox(runningsleep 3600). - Create a pod with a specific label
app=web, and verify it usingkubectl get pods --show-labels. - Create a pod with a volume mounted at
/datausingemptyDir. - Run a pod with environment variables set (e.g.,
ENV=prod,DEBUG=true). - Create a pod that uses a config map as environment variables.
- Create a pod with a command override that runs
echo Hello Kubernetes && sleep 3600. - Create a pod with a liveness probe that checks
/healthon port 80 every 5 seconds. - Create a pod with a readiness probe using
execto check file existence. - Create a pod and limit its CPU to 500m and memory to 128Mi.
- Create a pod that mounts a secret to
/etc/secret-data.
✅ Services – Hands-on Questions¶
- Create a service of type ClusterIP that exposes
nginx-podon port 80. - Create a service of type NodePort for a
httpddeployment. - Create a headless service for a StatefulSet.
- Create a service with
app=backendselector that points to port 8080 on pods. - Create a service with multiple ports exposed (e.g., 80 and 443).
- Expose a deployment as a ClusterIP service named
web-service. - Expose a pod directly using a service (without a deployment).
- Create an ExternalName service pointing to
my.external.com. - Verify service endpoints and understand why they may be empty.
- Create a service using YAML with explicit
targetPort,port, andnodePort.
✅ Ingress – Hands-on Questions¶
- Deploy ingress-nginx controller using the official YAML.
-
Create an Ingress resource routing:
/frontend→ servicefrontend:80/backend→ servicebackend:80- Create an Ingress with host
myapp.compointing/to serviceweb. - Create an Ingress resource with TLS using a Kubernetes Secret.
- Use pathType:
PrefixandExactin two different rules and explain the difference. - Configure multiple hosts in a single Ingress:
api.domain.com,admin.domain.com. - Debug an Ingress showing 404 — how to identify whether the issue is with rules, service, or ingress controller.
- Use annotations to enable HTTPS redirect in Ingress.
- Add custom headers in an Ingress using annotations.
- Configure Ingress to use a default backend.