0
0
Kubernetesdevops~20 mins

Multi-container Pods concept in Kubernetes - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Multi-container Pod Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Purpose of Multi-container Pods

What is the main reason to use multiple containers inside a single Kubernetes Pod?

ATo run tightly coupled containers that share resources and need to communicate closely
BTo run completely independent applications that do not share any resources
CTo increase the number of Pods running on a node without resource sharing
DTo separate containers by namespaces for security isolation
Attempts:
2 left
💡 Hint

Think about containers that need to work together closely and share storage or network.

💻 Command Output
intermediate
2:00remaining
Output of Pod with Multiple Containers

Given this Pod YAML with two containers, what will be the output of kubectl get pods mypod -o jsonpath='{.spec.containers[*].name}'?

Kubernetes
apiVersion: v1
kind: Pod
metadata:
  name: mypod
spec:
  containers:
  - name: app
    image: busybox
    command: ['sh', '-c', 'echo Hello from app']
  - name: sidecar
    image: busybox
    command: ['sh', '-c', 'echo Hello from sidecar']
Amypod app sidecar
Bapp sidecar
Capp
Dsidecar
Attempts:
2 left
💡 Hint

The command lists container names inside the Pod spec.

Configuration
advanced
2:00remaining
Sharing Storage Between Containers in a Pod

Which volume configuration allows two containers in the same Pod to share files?

Kubernetes
apiVersion: v1
kind: Pod
metadata:
  name: shared-pod
spec:
  containers:
  - name: container1
    image: busybox
    volumeMounts:
    - name: shared-data
      mountPath: /data
  - name: container2
    image: busybox
    volumeMounts:
    - name: shared-data
      mountPath: /data
  volumes:
A
  - name: shared-data
    emptyDir: {}
B
  - name: shared-data
    hostPath:
      path: /tmp/shared
C
  - name: shared-data
    configMap:
      name: shared-config
D
  - name: shared-data
    persistentVolumeClaim:
      claimName: pvc1
Attempts:
2 left
💡 Hint

Look for a volume type that creates a temporary directory shared in Pod lifetime.

Troubleshoot
advanced
2:00remaining
Why Containers in a Pod Cannot Communicate

You have a Pod with two containers, but one container cannot reach the other on localhost. What is the most likely cause?

AContainers are in the same Pod but use different ports
BContainers are in the same Pod but use different volume mounts
CContainers are in the same Pod but have different images
DContainers are in different Pods, so they do not share the network namespace
Attempts:
2 left
💡 Hint

Remember that containers in the same Pod share network, but different Pods do not.

🔀 Workflow
expert
3:00remaining
Order of Steps to Deploy a Multi-container Pod

Arrange the steps in the correct order to deploy a multi-container Pod and verify both containers are running.

A2,1,3,4
B1,3,2,4
C1,2,3,4
D1,2,4,3
Attempts:
2 left
💡 Hint

Think about writing config first, then applying it, then checking status, then logs.