CKAD · Question #9
Anytime a team needs to run a container on Kubernetes they will need to define a pod within which to run the container. Please complete the following: Create a YAML formatted pod manifest…
This question tests the ability to create a Kubernetes pod manifest in YAML, apply it with kubectl, and capture pod status output in JSON format - core skills for the CKA/CKAD exam.
Question
- Create a YAML formatted pod manifest /opt/KDPD00101/pod1.yml to create a pod named app1 that runs a container named app1cont using image lfconf/arg-output with these command line arguments: -lines 56 -f
- Create the pod with the kubectl command using the YAML file created in the previous step
- When the pod is running,display summary data about the pod in JSON format using the kubectl command and redirect the output to a file named /opt/KDPD00101/out1.json
Explanation
This question tests the ability to create a Kubernetes pod manifest in YAML, apply it with kubectl, and capture pod status output in JSON format - core skills for the CKA/CKAD exam.
Approach. Step 1: Create /opt/KDPD00101/pod1.yml with apiVersion: v1, kind: Pod, metadata.name: app1, and a container named app1cont using image lfconf/arg-output with args: ["-lines", "56", "-f"]. Step 2: Apply the manifest with 'kubectl apply -f /opt/KDPD00101/pod1.yml'. Step 3: Wait for the pod to reach Running state (use 'kubectl get pod app1 --watch' or 'kubectl wait --for=condition=Ready pod/app1'). Step 4: Capture summary data with 'kubectl get pod app1 -o json > /opt/KDPD00101/out1.json' - the '-o json' flag outputs full pod metadata, spec, and status in JSON, and '>' redirects it to the target file.
Concept tested. Kubernetes Pod manifest authoring (YAML structure, container args vs command), imperative vs declarative kubectl usage, and kubectl output formatting (-o json) with shell redirection.
Reference. https://kubernetes.io/docs/concepts/workloads/pods/ - see 'Defining a Pod' and 'kubectl get' output options.
Topics
Community Discussion
No community discussion yet for this question.