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?

Discover several reliable ways to restart a pod in Kubernetes using kubectl -- even though there's no direct kubectl restart pod command.

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.

Command line output of three examples where various yaml files are created using the kubectl run command.
Example where the kubectl run command is used to redirect output to various yaml files.

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:

User enters "k get pods --namespace ggckad -s0" and the output indicates both pod-a and pod-b are both running.
The result of executing the "k get pods --namespace ggckad-s0" command.

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:

Question 1.1 complete output demonstrating creating a namespace, applying the pod-a and pod-b definitions, and checking the log for pod-b which demonstrates that it is spinning.
Terminal output where we use k8s to create a pod in a namespace and log its 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:

Kubernetes command line event output for the namespace ggckad-s0 showing that pod-a (a web container), and pod-b (an nginx container) have both been created and started.
The output for events collected in the Kubernetes namespace ggckad-s0 when setting up pod-a and pod-b.

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:

Practice exam for Certified Kubernetes Application Developer CKAD Certification question 1.1 port forward from 80 to 19999 for pod-b.
Mock CKAD Certification question 1.1 port forward from 80 to 19999 for pod-b.

Finally, we can now test that Nginx is running by browsing localhost:19999.

The nginx web server welcome page is available on localhost port 19999.
The welcome page for the nginx web server which is available on localhost port 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.

  1. Learn how to use kubectl to get the cluster name in this guide.
  2. Tutorial: Learn how to quickly install the minikube Metrics Server in five easy steps!
  3. Learn how to mount a local directory in minikube by exploring three possible solutions.
  4. Example Two: Learn how to create a ConfigMap in Kubernetes with two environment variables.
  5. Example Three: Set user IDs and file system group IDs in containers using the Kubernetes SecurityContext.
  6. Example Four: Learn how to configure Kubernetes liveness and readiness probes.
  7. Example Five: Learn How To Create A Deployment With Kubernetes Replicas Now!
author avatar
ThosPFuller
I am a software engineer based in Northern Virginia (USA) and this website focuses on content engineering, web development, Technical SEO, Search Engine Optimization (SEO).

Leave a Reply