0
0
Kubernetesdevops~10 mins

Sidecar container pattern in Kubernetes - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to add a sidecar container named 'logger' to the pod spec.

Kubernetes
containers:
  - name: app
    image: myapp:latest
  - name: [1]
    image: busybox
    command: ['sh', '-c', 'tail -f /var/log/app.log']
Drag options to blanks, or click blank then click option'
Amain
Blogger
Csidecar
Dhelper
Attempts:
3 left
💡 Hint
Common Mistakes
Using generic names like 'main' or 'helper' which don't clarify the container's role.
2fill in blank
medium

Complete the code to mount a shared volume named 'shared-logs' to both containers.

Kubernetes
volumes:
  - name: shared-logs
    emptyDir: {}
containers:
  - name: app
    image: myapp:latest
    volumeMounts:
      - name: shared-logs
        mountPath: [1]
  - name: logger
    image: busybox
    volumeMounts:
      - name: shared-logs
        mountPath: /var/log
Drag options to blanks, or click blank then click option'
A/tmp
B/var/log
C/data
D/app/logs
Attempts:
3 left
💡 Hint
Common Mistakes
Using different or unrelated paths that do not align between containers.
3fill in blank
hard

Fix the error in the sidecar container's command to continuously output logs.

Kubernetes
containers:
  - name: logger
    image: busybox
    command: ['sh', '-c', [1]]
Drag options to blanks, or click blank then click option'
A'head -f /var/log/app.log'
B'cat /var/log/app.log'
C'tail -f /var/log/app.log'
D'tail /var/log/app.log'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'cat' which exits immediately, stopping the container.
Using 'head -f' which is invalid.
4fill in blank
hard

Fill both blanks to define a pod with a main and sidecar container sharing a volume.

Kubernetes
apiVersion: v1
kind: Pod
metadata:
  name: example-pod
spec:
  containers:
  - name: main-app
    image: myapp:latest
    volumeMounts:
    - name: [1]
      mountPath: /app/logs
  - name: sidecar-logger
    image: busybox
    volumeMounts:
    - name: [2]
      mountPath: /var/log
  volumes:
  - name: shared-logs
    emptyDir: {}
Drag options to blanks, or click blank then click option'
Ashared-logs
Bapp-logs
Clogs
Ddata
Attempts:
3 left
💡 Hint
Common Mistakes
Using different volume names for each container, breaking sharing.
5fill in blank
hard

Fill all three blanks to complete the sidecar container spec with proper image, command, and volume mount.

Kubernetes
containers:
  - name: sidecar-logger
    image: [1]
    command: ['sh', '-c', [2]]
    volumeMounts:
      - name: shared-logs
        mountPath: [3]
Drag options to blanks, or click blank then click option'
Abusybox
B'tail -f /var/log/app.log'
C/var/log
Dnginx
Attempts:
3 left
💡 Hint
Common Mistakes
Using a web server image like 'nginx' which is not suitable for logging.
Using a command that exits immediately.