What command is used to create a Pod named "my-pod" from an nginx image?

  1. kubectl apply -f my-pod.yaml
  2. kubectl new pod my-pod nginx
  3. kubectl run my-pod --image=nginx ✓
  4. kubectl create pod my-pod --image=nginx

Correct answer: kubectl run my-pod --image=nginx

Option C is correct because the imperative command to create a pod directly from a container image is kubectl run, and the syntax kubectl run my-pod --image=nginx creates a pod named my-pod running the nginx image. Option A uses kubectl apply -f, which requires a pre-existing YAML manifest file; it is declarative and will not work without that file. Option B is not a valid kubectl command; the subcommand new does not exist in kubectl. Option D uses kubectl create pod, which is not a supported form of the create subcommand for pods in the way shown; kubectl run is the correct imperative command for pod creation.

Topic: · kubernetes, kubectl, pod creation, ckad

Practice Certified Kubernetes App Developer (CKAD) Questions Free