Practice CKAD Exam Question #1: Create two pods in a namespace in Kubernetes
In this post, we’ll dive into a mock Kubernetes practice exam question that requires you to create two pods within a specific namespace in Kubernetes (k8s).
The following is the first CKAD Questions and Answers example is taken from the Practice Exam for Certified Kubernetes Application Developer (CKAD) Certification on Matthew Palmer’s website and reads as follows:
Create a namespace called ggckad-s0 in your cluster.
Run the following pods in this namespace.
1. A pod called pod-a with a single container running the kubegoldenguide/simple-http-server image
2. A pod called pod-b that has one container running the kubegoldenguide/alpine-spin:1.0.0 image, and one container running nginx:1.7.9
Write down the output of kubectl get pods for the ggckad-s0 namespace.
Note that I’m running minikube locally and rely on minikube to answer this question in the next section.
Creating pods in a namespace is a foundational skill for deploying Kubernetes Microservices, as demonstrated in this Kubernetes practice question.
This article was last updated on June 17, 2025.
Want to restart a pod in k8s the right way?
Learn how to use k8s to create a pod in a namespace
We can create a new pod in a namespace in Kubernetes in two steps, which we’ll cover below.
The third step is optional and involves testing our solution.
Article Prerequisites
Refer to the article prerequisites for details about technology and setup instructions required to answer this question.
Step One: Autogenerate the Kubernetes pod configuration files
We can hack together a pod by hand or we can autogenerate the Kubernetes pod configuration files, which should be the preferred option as we don’t want to waste time with this if we can avoid it.
The following commands can be used to autogenerate each pod configuration file: one for the kubegoldenguide/simple-http-server container, one for the kubegoldenguide/alpine-spin:1.0.0 container, and one for the nginx:1.7.9 container.
kubectl run nginx --image=kubegoldenguide/simple-http-server --dry-run=client -o yaml > simple-http-server.yaml
kubectl run nginx --image=kubegoldenguide/alpine-spin:1.0.0 --dry-run=client -o yaml > alpine-spin.yaml
kubectl run nginx --image=nginx:1.7.9 --dry-run=client -o yaml > nginx.yaml
When these commands are executed successfully we should end up with three files being created — this is demonstrated in the next image.
Step Two: Modify the autogenerated Kubernetes pod configuration files
We can use these files to create the pod-a and pod-b pod configuration files, which are required for this question.
The Kubernetes pod configuration file for pod-a appears as follows (see: q1_dot_1_pod-a_configuration.yaml):
apiVersion: v1
kind: Pod
metadata:
name: pod-a
labels:
role: myrole
spec:
containers:
- name: web
image: kubegoldenguide/simple-http-server
ports:
- name: web
containerPort: 80
protocol: TCP
And the k8s pod configuration file for pod-b appears below (see: q1_dot_2_configuration.yaml):
apiVersion: v1
kind: Pod
metadata:
name: pod-b
labels:
role: myrole
spec:
containers:
- name: alpine-spin-container
image: kubegoldenguide/alpine-spin:1.0.0
ports:
- name: web
containerPort: 80
protocol: TCP
- name: nginx-container
image: nginx:1.7.9
ports:
- name: web
containerPort: 80
protocol: TCP
We need to first create the namespace as per the instructions:
k create namespace ggckad-s0
Next, we can apply this configuration:
kubectl apply -f pod-[a or b].yaml --namespace ggckad-s0
The final instruction for this question indicates that we need to “[w]rite down the output of kubectl get pods for the ggckad-s0 namespace.” — this is accomplished as follows:
k get pods --namespace ggckad-s0
which yields the following:
Step Three: Verify the solution by checking K8s logs and K8s events
Below we have the entire script that we use in this example.
We check the logs for all containers in order to see that they’re running correctly.
k create namespace ggckad-s0
k apply -f pod-a.yaml --namespace ggckad-s0
k logs pod-a --namespace ggckad-s0
k apply -f pod-b.yaml --namespace ggckad-s0
k logs pod-b alpine-spin-container --namespace ggckad-s0
k logs pod-b nginx-container --namespace ggckad-s0
Running this script should yield the following output:
We can use the get events command to see the events that were collected.
k get events --namespace ggckad-s0
Running this command should yield the following output:
Notice that the nginx-container has started however there are no messages in the log that indicate that it’s actually running so we’ll check this by mapping port 19999 on the local machine to port 80 in the pod-b pod, which should point to the nginx-container which has the Nginx web server running on port 80.
kubectl port-forward pods/pod-b 19999:80 --namespace ggckad-s0
When we execute the line above, the output should look like what we have below:
Finally, we can now test that Nginx is running by browsing localhost:19999.
And that’s it for this question.
Tutorial Conclusion
I hope this guide has been helpful in understanding the process of creating two pods within a specific namespace in minikube and/or k8s.
See Also
Other tutorials focusing on aspects of Kubernetes can be found below.
- Learn how to use kubectl to get the cluster name in this guide.
- Tutorial: Learn how to quickly install the minikube Metrics Server in five easy steps!
- Learn how to mount a local directory in minikube by exploring three possible solutions.
- Example Two: Learn how to create a ConfigMap in Kubernetes with two environment variables.
- Example Three: Set user IDs and file system group IDs in containers using the Kubernetes SecurityContext.
- Example Four: Learn how to configure Kubernetes liveness and readiness probes.
- Example Five: Learn How To Create A Deployment With Kubernetes Replicas Now!











