312-97 practice question 10 of 35

(Jason Wylie has been working as a DevSecOps engineer in an IT company located in Sacramento, Californi a. He would like to use Jenkins for CI and…

Full set: 100 questions
(Jason Wylie has been working as a DevSecOps engineer in an IT company located in Sacramento, Californi a. He would like to use Jenkins for CI and Azure Pipelines for CD to deploy a Spring Boot app to an Azure Container Service (AKS) Kubernetes cluster. He created a namespace for deploying the Jenkins in AKS, and then deployed the Jenkins app to the Pod. Which of the following commands should Jason run to see the pods that have been spun up and running?)
Answer options
A: kubectl get pods -k Jenkins.
B: kubectl get pods -s jenkins.
C: kubectl get pods -n jenkins. Correct answer
D: kubectl get pods -p jenkins.
Correct Answer:
C. kubectl get pods -n jenkins.
Explanation

The kubectl get pods command is used to list one or more pods. To view resources within a specific namespace, the --namespace or its shorthand -n flag must be used. Since the Jenkins application was deployed into a namespace named "jenkins," the command kubectl get pods -n jenkins correctly targets that namespace and lists the pods running within it. This is the standard and correct procedure for querying namespaced resources in Kubernetes.

Why Incorrect

A. The -k flag is used for kustomize, which manages Kubernetes configuration, not for specifying a namespace in a get command.
B. The -s or --server flag is used to specify the address and port of the Kubernetes API server, not to filter resources by namespace.
D. The -p or --prune flag is an option for the kubectl apply command to remove resources and is not a valid flag for kubectl get pods.

References

- Kubernetes Documentation, kubectl get command. "Display one or many resources... Use the --namespace flag to specify the namespace." (kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#get)

- Kubernetes Documentation, Namespaces. "kubectl supports a --namespace flag for most commands to specify the namespace for the request." (kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/)

Scroll to Top