Bird
0
0

Which of the following YAML snippets correctly specifies two containers within a single Kubernetes Pod?

easy📝 Syntax Q3 of 15
Kubernetes - Pods
Which of the following YAML snippets correctly specifies two containers within a single Kubernetes Pod?
Aspec: containers: - name: app image: nginx - name: sidecar image: busybox
Bspec: container: - name: app image: nginx - name: sidecar image: busybox
Cspec: containers: name: app image: nginx name: sidecar image: busybox
Dspec: containers: - app: nginx - sidecar: busybox
Step-by-Step Solution
Solution:
  1. Step 1: Review Pod spec syntax

    The 'containers' field is a list of container definitions.
  2. Step 2: Identify correct YAML structure

    spec: containers: - name: app image: nginx - name: sidecar image: busybox correctly uses a list under 'containers' with each container having 'name' and 'image'.
  3. Final Answer:

    spec: containers: - name: app image: nginx - name: sidecar image: busybox is the correct YAML snippet.
  4. Quick Check:

    Containers must be under 'containers' as a list [OK]
Quick Trick: 'containers' is a list of container specs [OK]
Common Mistakes:
  • Using 'container' instead of 'containers'
  • Not using a list for multiple containers
  • Incorrect indentation or missing keys

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes