Q.8
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
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:
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: grape-pod-cka06-str
name: grape-pod-cka06-str
spec:
volumes:
- name: grape-vol-cka06-str
emptyDir: {}
containers:
- image: busybox
name: busybox
command: [“sleep”,“3600”]
volumeMounts:
- mountPath: /usr/src
name: grape-vol-cka06-str
- image: nginx
name: grape-pod-cka06-str
volumeMounts:
- mountPath: /var/log/nginx
name: grape-vol-cka06-str
grape-pod-cka06-str 2/2 Running 0 35m
I don’t know why it was marked as incorrect and reason given:
main container and side car container mounts are not correct
Container inside pods are running fine but still. Not sure…
Hi @sarvo1777
Could you please share the Pod manifests in a
code-block
That’ll help preserve the indentation and evaluate the manifest.

Hi
@Santosh_KodeKloud can you pls check the attached images
It looks like the double quotes have been corrupted and turned into “smart quotes”, which will prevent the YAML from being valid.
BTW: it’s always better to post text in code blocks rather than images, since we can’t actually try to run an image. Use the </>
button to create a block, and then paste into that block.
but in k8s documentation also double-quotes have been used…in command…
Those aren’t real double quotes. They are matching “smart quotes”, which are different characters. You likely edited the YAML in MS Word or something like that. Which you really should not do; it alters the characters to things that the YAML parser does not accept. Per Google Search:
The Unicode for “smart double quotes” are: " (left double quotation mark - U+201C) and " (right double quotation mark - U+201D).
Below is the yaml by kodekloud:
apiVersion: v1
kind: Pod
metadata:
name: grape-pod-cka06-str
spec:
containers:
- name: nginx
image: nginx
volumeMounts:
- name: grape-vol-cka06-str
mountPath: "/var/log/nginx"
- name: busybox
image: busybox
command:
- "bin/sh"
- "-c"
- "sleep 10000"
volumeMounts:
- name: grape-vol-cka06-str
mountPath: "/usr/src"
volumes:
- name: grape-vol-cka06-str
emptyDir: {}
This is my Yaml:
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: grape-pod-cka06-str
name: grape-pod-cka06-str
spec:
volumes:
- name: grape-vol-cka06-str
emptyDir: {}
containers:
- name: busybox
image: busybox
command: ["/bin/sh","-c","sleep 10000"]
volumeMounts:
# a mount for site-data
- name: grape-vol-cka06-str
mountPath: /usr/src
- image: nginx
name: grape-pod-cka06-str
volumeMounts:
# a mount for site-data
- name: grape-vol-cka06-str
mountPath: /var/log/nginx
because i haven’t applied double quotes on mountPath…this question was marked as incorrect for me…so just wanted to confirm if double quotes are necessary in case of volume mount…can you pls check and confirm
I don’t think that’s your problem. I’d guess that the grader is a bit strict, and would prefer your command block be as the solution is, or
command:
- "bin/sh"
- "-c"
- "sleep 10000"
I don’t think that not using quote marks on a string will bother a YAML parser; the underlying type will still be string
, which is all the golang code will care about. But command blocks seem to have some subtle difference that does make them distinguishable.
but in the question it was not mentioned the time for which container should sleep…
Count to think, the more likely cause is that the grader is looking at the order of the containers; yours is reversed from the solution. The question says:
- 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
command to this container to keep it running. Next, mount the same volume called grape-vol-cka06-str
at the path /usr/src
.
It doesn’t explicitly say that it cares about order, but the solution is in that order. Given how the grader works, it might care.
i don’t think so order is the issue because when i ended the exam, in the details section it was mentioned that mount paths are not correct…
Still, knowing something about how the YAML parser works, the quoting will be irrelevant. Did you try reversing the order?
not yet…but even if i reverse it and suppose it gets right…does it mean in exam also i have to attempt in a specific order according to what is being asked in question…?