Kubernetes Time Check Pod - Task failed error

Hey,

I have successfully completed this task.
However, it argues my mount path is incorrect, despite it is exactly configured as the instructions.

Here is the configuration of the pod:

apiVersion: v1
kind: Pod
metadata:
creationTimestamp: “2023-12-22T16:48:07Z”
labels:
run: time-check
name: time-check
namespace: nautilus
resourceVersion: “6232”
uid: e9345b2a-7846-431f-abf5-c71931f49fa4
spec:
containers:

  • args:
    • -c
    • while true; do date; sleep $TIME_FREQ;done >> /opt/data/time/time-check.log
      command:
    • /bin/sh
      env:
    • name: TIME_FREQ
      valueFrom:
      configMapKeyRef:
      key: TIME_FREQ
      name: time-config
      image: busybox:latest
      imagePullPolicy: Always
      name: time-check
      resources: {}
      terminationMessagePath: /dev/termination-log
      terminationMessagePolicy: File
      volumeMounts:
    • mountPath: /var/run/secrets/kubernetes.io/serviceaccount
      name: kube-api-access-sxxbh
      readOnly: true
    • mountPath: /opt/data/time
      name: log-volume
      dnsPolicy: ClusterFirst
      enableServiceLinks: true
      nodeName: kodekloud-control-plane
      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:
  • name: kube-api-access-sxxbh
    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
  • emptyDir: {}
    name: log-volume
    status:
    conditions:
  • lastProbeTime: null
    lastTransitionTime: “2023-12-22T16:48:07Z”
    status: “True”
    type: Initialized
  • lastProbeTime: null
    lastTransitionTime: “2023-12-22T16:48:09Z”
    status: “True”
    type: Ready
  • lastProbeTime: null
    lastTransitionTime: “2023-12-22T16:48:09Z”
    status: “True”
    type: ContainersReady
  • lastProbeTime: null
    lastTransitionTime: “2023-12-22T16:48:07Z”
    status: “True”
    type: PodScheduled
    containerStatuses:
  • containerID: containerd://6509714d14cc1c3389b1ad041b7eeec0fa48698a579becca5040c838528fc86d
    image: Docker
    imageID: Docker
    lastState: {}
    name: time-check
    ready: true
    restartCount: 0
    started: true
    state:
    running:
    startedAt: “2023-12-22T16:48:08Z”
    hostIP: 172.17.0.2
    phase: Running
    podIP: 10.244.0.7
    podIPs:
  • ip: 10.244.0.7
    qosClass: BestEffort
    startTime: “2023-12-22T16:48:07Z”

Please post YAML in

code blocks

as all the formatting is broken when you paste as plain text and we cannot validate it.

type ``` on a line by itself, paste the YAML, and type that again below the YAML to code block it.

1 Like
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: "2023-12-22T16:48:07Z"
  labels:
    run: time-check
  name: time-check
  namespace: nautilus
  resourceVersion: "6232"
  uid: e9345b2a-7846-431f-abf5-c71931f49fa4
spec:
  containers:
  - args:
    - -c
    - while true; do date; sleep $TIME_FREQ; done >> /opt/data/time/time-check.log
    command:
    - /bin/sh
    env:
    - name: TIME_FREQ
      valueFrom:
        configMapKeyRef:
          key: TIME_FREQ
          name: time-config
    image: busybox:latest
    imagePullPolicy: Always
    name: time-check
    resources: {}
    terminationMessagePath: /dev/termination-log
    terminationMessagePolicy: File
    volumeMounts:
    - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
      name: kube-api-access-sxxbh
      readOnly: true
    - mountPath: /opt/data/time
      name: log-volume
  dnsPolicy: ClusterFirst
  enableServiceLinks: true
  nodeName: kodekloud-control-plane
  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:
  - name: kube-api-access-sxxbh
    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
  - name: log-volume
    emptyDir: {}
status:
  conditions:
  - lastProbeTime: null
    lastTransitionTime: "2023-12-22T16:48:07Z"
    status: "True"
    type: Initialized
  - lastProbeTime: null
    lastTransitionTime: "2023-12-22T16:48:09Z"
    status: "True"
    type: Ready
  - lastProbeTime: null
    lastTransitionTime: "2023-12-22T16:48:09Z"
    status: "True"
    type: ContainersReady
  - lastProbeTime: null
    lastTransitionTime: "2023-12-22T16:48:07Z"
    status: "True"
    type: PodScheduled
  containerStatuses:
  - containerID: containerd://6509714d14cc1c3389b1ad041b7eeec0fa48698a579becca5040c838528fc86d
    image: Docker
    imageID: Docker
    lastState: {}
    name: time-check
    ready: true
    restartCount: 0
    started: true
    state:
      running:
        startedAt: "2023-12-22T16:48:08Z"
    hostIP: 172.17.0.2
    phase: Running
    podIP: 10.244.0.7
    podIPs:
    - ip: 10.244.0.7
    qosClass: BestEffort
    startTime: "2023-12-22T16:48:07Z"

I just did that lab and it works for me. Remember that each time you retry the lab, it may state different values for namespace, pod name, config map name, value of TIME_FREQ, mount path for the log-volume, so you cannot save the manifest you created for a previous attempt and paste it back in next time without carefully editing it first.

apiVersion: v1
kind: Pod
metadata:
  labels:
    run: time-check
  name: time-check
  namespace: devops
spec:
  volumes:
  - name: log-volume
    emptyDir: {}
  containers:
  - command:
    - sh
    - -c
    - while true; do date >> /opt/sysops/time/time-check.log ; sleep $TIME_FREQ ;done
    env:
    - name: TIME_FREQ
      valueFrom:
        configMapKeyRef:
          key: TIME_FREQ
          name: time-check
    image: busybox:latest
    name: time-check
    volumeMounts:
    - name: log-volume
      mountPath: /opt/sysops/time