Skip to main content
This lesson walks through the solution for the namespaces lab. It shows how to list namespaces, count pods in a namespace, and create a Pod in a specific namespace. Use the commands and examples below to verify resources in your cluster. Quick answers

Question 1 — How many namespaces exist on the system?

List all namespaces with:
Example output:
Count the lines (excluding the header) — there are 10 namespaces in this example. For more on namespaces and how they partition cluster resources, see the Kubernetes docs: Namespaces.

Question 2 — How many pods exist in the research namespace?

To list pods in a specific namespace, use --namespace or the short -n flag:
Example output for the research namespace:
There are 2 pods in the research namespace: dna-1 and dna-2. Tip: use kubectl describe pod <pod-name> -n research and kubectl logs <pod-name> -n research to investigate CrashLoopBackOff or other pod issues.

Question 3 — Create a pod in the finance namespace using the given spec

To create a single Pod named redis from the redis image in the finance namespace, you can use kubectl run. Newer kubectl versions default to creating a Deployment unless you explicitly request a Pod object by setting --restart=Never:
Then verify the Pod exists:
kubectl run behavior changed in newer versions: without --restart=Never it may create a Deployment instead of a Pod. Use --restart=Never to ensure a Pod is created, or provide a Pod manifest and apply it with kubectl apply -f <pod-manifest.yaml>.

Additional verification examples

Below are example commands to show how to inspect resources in other namespaces. These help illustrate how Services and Pods appear when scoped to a namespace. Example: list pods in the marketing namespace
Example: list services in the marketing namespace
Example: list services in the dev namespace
Use these commands to verify and debug resources across namespaces. For quick reference, see:

Watch Video