Could somebody help please? I need some help in resolving Lightning Test 1, Q3. . . .

Anish Nagaraj:
Could somebody help please? I need some help in resolving Lightning Test 1, Q3. My pod never starts when I write the result of the given command to the location /opt/time/time-check.log

apiVersion: v1
kind: Pod
metadata:
  name: time-check
  namespace: dvl1987
  labels:
    env: test
spec:
  containers:
    - name: time-check
      image: busybox
      command: [ /bin/sh, -c, 'while true; do date; sleep 10;done > /opt/time/time-check.log' ]
  restartPolicy: Never

Tej_Singh_Rana:
Hello, @Anish Nagaraj
Did you check the logs?

$ kubectl logs time-check -n dvl1987

Tej_Singh_Rana:
It’s happening due to time directory because it’s not available inside the pod’s container.

Tej_Singh_Rana:
This one will work.

apiVersion: v1
kind: Pod
metadata:
  name: time-check
  namespace: dvl1987
  labels:
    env: test
spec:
  volumes:
   - name: test
     emptyDir: {}
  containers:
    - name: time-check
      image: busybox
      command: [ /bin/sh, -c, 'while true; do date; sleep 10;done > /opt/time/time-check.log' ]
      volumeMounts:
      - name: test
        mountPath: /opt/time
  restartPolicy: Never

Tej_Singh_Rana:
then see the logs by cat command.

$ kubectl exec time-check -n dvl1987 -- cat /opt/time/time-check.log

Anish Nagaraj:
Thank you Tej!

Anish Nagaraj:
However, I my pod now says that config_map not found, though I have one

Anish Nagaraj:

Anish Nagaraj:
However, no worries, I will try to debug it myself

Neel:
CM should be the same namespace

Basavraj Nilkanthe:
@Tej_Singh_Rana why you have suggest emptyDir volume options to fix this path issue and cant we change path of log location to /tmp/time-check.log and redirect logs there rather adding more complexity in YAML definition using volume… I may be missing here … help me to correct…

Tej_Singh_Rana:
We can but I suggested according to his yaml file.