Practice Test Persistent Volume Claims.

Practice Test Persistent Volume Claims.

Q) Configure a volume to store these logs at /var/log/webapp on the host
Use the spec given on the right.

Name: webapp
Image Name: kodekloud/event-simulator
Volume HostPath: /var/log/webapp
Volume Mount: /log

Issue: Pod is not getting created and it is on "ContainerCreating " status. I could see below error on events section:-

“Unable to attach or mount volumes: unmounted volumes=[log-volume], unattached volumes=[log-volume default-token-n7x2m]:
timed out waiting for the condition”

could you please help?

what is your yaml file? can you write here?

according to me :—

kind: Pod
metadata:
     name: webapp
     labels:
        app: webapp
spec:
   volumes:
       - name: xyz
         hostPath:
            path: /var/log/webapp
   containers:
         image:  kodekloud/event-simulator
         name: webapp
         volumeMounts:
               - name: xyz
                 mountPath: /log

Hi,

I have managed to find out the issue. I have mentioned type as Directory and the mentioned directory was not existed which causes the issue.
It got resolved when I changed the type to DirectoryOrCreate