Ulitimate CKA exam mock series exam 4: Q5

Hi Team,

Kindly assist me with Q5 of Mock exam 4 and let me know why the question is marked as wrong for teh point mentioned below:

Does the sidecar container use the correct mount?

Question5:

Solve this question on: ssh cluster1-controlplane


There is a requirement to share a volume between two containers that are running within the same pod. Use the following instructions to create the pod and related objects:


- Create a pod named grape-pod-cka06-str.

- The main container should use the nginx image and mount a volume called grape-vol-cka06-str at path /var/log/nginx.

- The sidecar container can use busybox image, you might need to add a sleep 7200 command to this container to keep it running. Next, mount the same volume called grape-vol-cka06-str at the path /usr/src.

- The volume should be of type emptyDir.

My solution:

student-node ~ ➜   ssh cluster1-controlplane
Welcome to Ubuntu 22.04.5 LTS (GNU/Linux 5.15.0-1083-gcp x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/pro

This system has been minimized by removing packages and content that are
not required on a system that users do not log into.

To restore this content, you can run the 'unminimize' command.
Last login: Tue Jul 29 03:44:58 2025 from 192.168.141.16

cluster1-controlplane ~ ➜  k get pods
NAME                                  READY   STATUS    RESTARTS   AGE
auto-cka11-arch                       1/1     Running   0          89m
check-time-cka03-trb                  1/1     Running   0          89m
curlme-cka01-svcn                     1/1     Running   0          78m
curlpod-cka01-svcn                    1/1     Running   0          78m
grape-pod-cka06-str                   2/2     Running   0          101m
nginx-dp-cka04-trb-5d7b97d7cc-xnpjd   1/1     Running   0          111m
red-probe-cka12-trb                   1/1     Running   0          107m

cluster1-controlplane ~ ➜  k describe pod grape-pod-cka06-str
Name:             grape-pod-cka06-str
Namespace:        default
Priority:         0
Service Account:  default
Node:             cluster1-node01/192.168.13.236
Start Time:       Tue, 29 Jul 2025 03:05:46 +0000
Labels:           run=grape-pod-cka06-str
Annotations:      cni.projectcalico.org/containerID: b82f3287f1d5ff4de7737f5cf1bbf8d35660ccef6da3595d65fc0fb54e1f7e40
                  cni.projectcalico.org/podIP: 172.17.1.3/32
                  cni.projectcalico.org/podIPs: 172.17.1.3/32
Status:           Running
IP:               172.17.1.3
IPs:
  IP:  172.17.1.3
Containers:
  nginx:
    Container ID:   containerd://aa8fd94c4527ac4398731d70f40c3a1b212c416ed3137cfa02bd44d1705ca717
    Image:          nginx
    Image ID:       docker.io/library/nginx@sha256:84ec966e61a8c7846f509da7eb081c55c1d56817448728924a87ab32f12a72fb
    Port:           <none>
    Host Port:      <none>
    State:          Running
      Started:      Tue, 29 Jul 2025 03:05:50 +0000
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/log/nginx from grape-vol-cka06-str (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-tsnx7 (ro)
  busybox:
    Container ID:  containerd://625458a78a3160a365b1f32cd85d75a3026adec8195844b416a8e59067c06856
    Image:         busybox
    Image ID:      docker.io/library/busybox@sha256:f9a104fddb33220ec80fc45a4e606c74aadf1ef7a3832eb0b05be9e90cd61f5f
    Port:          <none>
    Host Port:     <none>
    Command:
      sleep
      7200
    State:          Running
      Started:      Tue, 29 Jul 2025 03:05:51 +0000
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /usr/src from grape-vol-cka06-str (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-tsnx7 (ro)
Conditions:
  Type                        Status
  PodReadyToStartContainers   True 
  Initialized                 True 
  Ready                       True 
  ContainersReady             True 
  PodScheduled                True 
Volumes:
  grape-vol-cka06-str:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:     
    SizeLimit:  <unset>
  kube-api-access-tsnx7:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:                      <none>

--- POd YAML

cluster1-controlplane ~ ➜  k get  pod grape-pod-cka06-str -o yaml 
apiVersion: v1
kind: Pod
metadata:
  annotations:
    cni.projectcalico.org/containerID: b82f3287f1d5ff4de7737f5cf1bbf8d35660ccef6da3595d65fc0fb54e1f7e40
    cni.projectcalico.org/podIP: 172.17.1.3/32
    cni.projectcalico.org/podIPs: 172.17.1.3/32
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","kind":"Pod","metadata":{"annotations":{},"creationTimestamp":null,"labels":{"run":"grape-pod-cka06-str"},"name":"grape-pod-cka06-str","namespace":"default"},"spec":{"containers":[{"image":"nginx","name":"nginx","volumeMounts":[{"mountPath":"/var/log/nginx","name":"grape-vol-cka06-str"}]},{"command":["sleep","7200"],"image":"busybox","name":"busybox","volumeMounts":[{"mountPath":"/usr/src","name":"grape-vol-cka06-str"}]}],"volumes":[{"emptyDir":{},"name":"grape-vol-cka06-str"}]}}
  creationTimestamp: "2025-07-29T03:05:46Z"
  labels:
    run: grape-pod-cka06-str
  name: grape-pod-cka06-str
  namespace: default
  resourceVersion: "8450"
  uid: d25e1b3a-4c03-45c1-85a1-1dd93f751809
spec:
  containers:
  - image: nginx
    imagePullPolicy: Always
    name: nginx
    resources: {}
    terminationMessagePath: /dev/termination-log
    terminationMessagePolicy: File
    volumeMounts:
    - mountPath: /var/log/nginx
      name: grape-vol-cka06-str
    - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
      name: kube-api-access-tsnx7
      readOnly: true
  - command:
    - sleep
    - "7200"
    image: busybox
    imagePullPolicy: Always
    name: busybox
    resources: {}
    terminationMessagePath: /dev/termination-log
    terminationMessagePolicy: File
    volumeMounts:
    - mountPath: /usr/src
      name: grape-vol-cka06-str
    - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
      name: kube-api-access-tsnx7
      readOnly: true
  dnsPolicy: ClusterFirst
  enableServiceLinks: true
  nodeName: cluster1-node01
  preemptionPolicy: PreemptLowerPriority
  priority: 0
  restartPolicy: Always
  schedulerName: default-scheduler
  securityContext: {}
  serviceAccount: default
  serviceAccountName: default
  terminationGracePeriodSeconds: 30
  tolerations:
  - effect: NoExecute
    key: node.kubernetes.io/not-ready
    operator: Exists
    tolerationSeconds: 300
  - effect: NoExecute
    key: node.kubernetes.io/unreachable
    operator: Exists
    tolerationSeconds: 300
  volumes:
  - emptyDir: {}
    name: grape-vol-cka06-str
  - name: kube-api-access-tsnx7
    projected:
      defaultMode: 420
      sources:
      - serviceAccountToken:
          expirationSeconds: 3607
          path: token
      - configMap:
          items:
          - key: ca.crt
            path: ca.crt
          name: kube-root-ca.crt
      - downwardAPI:
          items:
          - fieldRef:
              apiVersion: v1
              fieldPath: metadata.namespace
            path: namespace
status:
  conditions:
  - lastProbeTime: null
    lastTransitionTime: "2025-07-29T03:05:52Z"
    status: "True"
    type: PodReadyToStartContainers
  - lastProbeTime: null
    lastTransitionTime: "2025-07-29T03:05:46Z"
    status: "True"
    type: Initialized
  - lastProbeTime: null
    lastTransitionTime: "2025-07-29T03:05:52Z"
    status: "True"
    type: Ready
  - lastProbeTime: null
    lastTransitionTime: "2025-07-29T03:05:52Z"
    status: "True"
    type: ContainersReady
  - lastProbeTime: null
    lastTransitionTime: "2025-07-29T03:05:46Z"
    status: "True"
    type: PodScheduled
  containerStatuses:
  - containerID: containerd://625458a78a3160a365b1f32cd85d75a3026adec8195844b416a8e59067c06856
    image: docker.io/library/busybox:latest
    imageID: docker.io/library/busybox@sha256:f9a104fddb33220ec80fc45a4e606c74aadf1ef7a3832eb0b05be9e90cd61f5f
    lastState: {}
    name: busybox
    ready: true
    restartCount: 0
    started: true
    state:
      running:
        startedAt: "2025-07-29T03:05:51Z"
    volumeMounts:
    - mountPath: /usr/src
      name: grape-vol-cka06-str
    - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
      name: kube-api-access-tsnx7
      readOnly: true
      recursiveReadOnly: Disabled
  - containerID: containerd://aa8fd94c4527ac4398731d70f40c3a1b212c416ed3137cfa02bd44d1705ca717
    image: docker.io/library/nginx:latest
    imageID: docker.io/library/nginx@sha256:84ec966e61a8c7846f509da7eb081c55c1d56817448728924a87ab32f12a72fb
    lastState: {}
    name: nginx
    ready: true
    restartCount: 0
    started: true
    state:
      running:
        startedAt: "2025-07-29T03:05:50Z"
    volumeMounts:
    - mountPath: /var/log/nginx
      name: grape-vol-cka06-str
    - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
      name: kube-api-access-tsnx7
      readOnly: true
      recursiveReadOnly: Disabled
  hostIP: 192.168.13.236
  hostIPs:
  - ip: 192.168.13.236
  phase: Running
  podIP: 172.17.1.3
  podIPs:
  - ip: 172.17.1.3
  qosClass: BestEffort
  startTime: "2025-07-29T03:05:46Z"





one point I noted that in question it asks to add sleep 7200 in the busybox container but in the solution that is reported in the exam awhen question is marked wrong sleep 7500s is set . I think due to this mismatch this is marked as wrong

Solution from Exam below:

Create a YAML file as below:
apiVersion: v1
kind: Pod
metadata:
  name: grape-pod-cka06-str
spec:
  initContainers:
  - name: busybox
    image: busybox
    restartPolicy: Always
    command:
        - "bin/sh"
        - "-c"
        **- "sleep 7500"**
    volumeMounts:
      - name: grape-vol-cka06-str
        mountPath: "/usr/src"
  containers:
  - name: nginx
    image: nginx
    volumeMounts:
      - name: grape-vol-cka06-str
        mountPath: "/var/log/nginx"
  volumes:
  - name: grape-vol-cka06-str
    emptyDir: {}

Apply the template:
kubectl apply -f <template-file-name>.yaml

Where is the sidecar container in your solution?

@Alistair_KodeKloud Do you mean we need to create a sidecar container as an init container, not as a normal container ?

In some mock exams I have seen when a question says craete a sidecar container it’s created not as init container but as na ormal container.

Also my rest of critera related to side car container are marked as correct except "Mount of side car container is not correct "

The mock exams now follow the official definition of “sidecar” as published by Linux Foundation, as do the real exams

Linux Foundation says

Our engineers have already noticed the change in the definitions and made the necessary changes to the exams accordingly.
This means that whenever we want candidates to create a sidecar container, it is aligned with the official doc’s definition of sidecar, and if we want candidates to create a co-located container (the old way), we ask for a co-located container.

The official doc is here.

There should be something about this in the course but I can’t see it right now. I have a meeting with the course team in 10 minutes. I will check

It is there.

See this video (KodeKloud platform) (Udemy)

The rest of your solution should be OK if you move the sidecar correctly to initcontainers

Thanks @Alistair_KodeKloud for explaining this

Please mark this issue as resolved. Thanks for the help regarding this.