Skip to main content
Bumped by Community user
added 7207 characters in body
Source Link

Output from get:

apiVersion: v1
kind: Pod
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","kind":"Pod","metadata":{"annotations":{},"name":"time-check","namespace":"default"},"spec":{"containers":[{"args":["-c","while true; do date; sleep ;done \u003e\u003e /opt/data/time/time-check.log"],"command":["/bin/sh"],"env":[{"name":"TIME_FREQ","valueFrom":{"configMapKeyRef":{"key":"TIME_FREQ","name":"time-config"}}}],"image":"busybox:latest","name":"time-check","volumeMounts":[{"mountPath":"/opt/data/time","name":"log-volume"}]}],"volumes":[{"emptyDir":{},"name":"log-volume"}]}}
  creationTimestamp: "2024-09-01T12:07:41Z"
  name: time-check
  namespace: default
  resourceVersion: "28228"
  uid: 281e2819-df90-41c0-a5c4-b7203ed2ebec
spec:
  containers:
  - args:
    - -c
    - while true; do date; sleep ;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: /opt/data/time
      name: log-volume
    - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
      name: kube-api-access-bm6wc
      readOnly: true
  dnsPolicy: ClusterFirst
  enableServiceLinks: true
  nodeName: minikube
  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: log-volume
  - name: kube-api-access-bm6wc
    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: "2024-09-01T12:07:49Z"
    status: "True"
    type: PodReadyToStartContainers
  - lastProbeTime: null
    lastTransitionTime: "2024-09-01T12:07:41Z"
    status: "True"
    type: Initialized
  - lastProbeTime: null
    lastTransitionTime: "2024-09-01T12:07:49Z"
    status: "True"
    type: Ready
  - lastProbeTime: null
    lastTransitionTime: "2024-09-01T12:07:49Z"
    status: "True"
    type: ContainersReady
  - lastProbeTime: null
    lastTransitionTime: "2024-09-01T12:07:41Z"
    status: "True"
    type: PodScheduled
  containerStatuses:
  - containerID: docker://abd378ce0519222c43fc194ba6952475176fba2bb37ee71a5ac9f6838239d2cb
    image: busybox:latest
    imageID: docker-pullable://busybox@sha256:82742949a3709938cbeb9cec79f5eaf3e48b255389f2dcedf2de29ef96fd841c
    lastState: {}
    name: time-check
    ready: true
    restartCount: 0
    started: true
    state:
      running:
        startedAt: "2024-09-01T12:07:49Z"
  hostIP: 192.168.49.2
  hostIPs:
  - ip: 192.168.49.2
  phase: Running
  podIP: 10.244.0.6
  podIPs:
  - ip: 10.244.0.6
  qosClass: BestEffort
  startTime: "2024-09-01T12:07:41Z"

And describe:

Name:             time-check
Namespace:        default
Priority:         0
Service Account:  default
Node:             minikube/192.168.49.2
Start Time:       Sun, 01 Sep 2024 14:07:41 +0200
Labels:           <none>
Annotations:      <none>
Status:           Running
IP:               10.244.0.6
IPs:
  IP:  10.244.0.6
Containers:
  time-check:
    Container ID:  docker://abd378ce0519222c43fc194ba6952475176fba2bb37ee71a5ac9f6838239d2cb
    Image:         busybox:latest
    Image ID:      docker-pullable://busybox@sha256:82742949a3709938cbeb9cec79f5eaf3e48b255389f2dcedf2de29ef96fd841c
    Port:          <none>
    Host Port:     <none>
    Command:
      /bin/sh
    Args:
      -c
      while true; do date; sleep ;done >> /opt/data/time/time-check.log
    State:          Running
      Started:      Sun, 01 Sep 2024 14:07:49 +0200
    Ready:          True
    Restart Count:  0
    Environment:
      TIME_FREQ:  <set to the key 'TIME_FREQ' of config map 'time-config'>  Optional: false
    Mounts:
      /opt/data/time from log-volume (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-bm6wc (ro)
Conditions:
  Type                        Status
  PodReadyToStartContainers   True 
  Initialized                 True 
  Ready                       True 
  ContainersReady             True 
  PodScheduled                True 
Volumes:
  log-volume:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:     
    SizeLimit:  <unset>
  kube-api-access-bm6wc:
    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:
  Type    Reason     Age   From               Message
  ----    ------     ----  ----               -------
  Normal  Scheduled  22m   default-scheduler  Successfully assigned default/time-check to minikube
  Normal  Pulling    22m   kubelet            Pulling image "busybox:latest"
  Normal  Pulled     22m   kubelet            Successfully pulled image "busybox:latest" in 7.077s (7.077s including waiting). Image size: 4261574 bytes.
  Normal  Created    22m   kubelet            Created container time-check
  Normal  Started    22m   kubelet            Started container time-check

Output from get:

apiVersion: v1
kind: Pod
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","kind":"Pod","metadata":{"annotations":{},"name":"time-check","namespace":"default"},"spec":{"containers":[{"args":["-c","while true; do date; sleep ;done \u003e\u003e /opt/data/time/time-check.log"],"command":["/bin/sh"],"env":[{"name":"TIME_FREQ","valueFrom":{"configMapKeyRef":{"key":"TIME_FREQ","name":"time-config"}}}],"image":"busybox:latest","name":"time-check","volumeMounts":[{"mountPath":"/opt/data/time","name":"log-volume"}]}],"volumes":[{"emptyDir":{},"name":"log-volume"}]}}
  creationTimestamp: "2024-09-01T12:07:41Z"
  name: time-check
  namespace: default
  resourceVersion: "28228"
  uid: 281e2819-df90-41c0-a5c4-b7203ed2ebec
spec:
  containers:
  - args:
    - -c
    - while true; do date; sleep ;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: /opt/data/time
      name: log-volume
    - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
      name: kube-api-access-bm6wc
      readOnly: true
  dnsPolicy: ClusterFirst
  enableServiceLinks: true
  nodeName: minikube
  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: log-volume
  - name: kube-api-access-bm6wc
    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: "2024-09-01T12:07:49Z"
    status: "True"
    type: PodReadyToStartContainers
  - lastProbeTime: null
    lastTransitionTime: "2024-09-01T12:07:41Z"
    status: "True"
    type: Initialized
  - lastProbeTime: null
    lastTransitionTime: "2024-09-01T12:07:49Z"
    status: "True"
    type: Ready
  - lastProbeTime: null
    lastTransitionTime: "2024-09-01T12:07:49Z"
    status: "True"
    type: ContainersReady
  - lastProbeTime: null
    lastTransitionTime: "2024-09-01T12:07:41Z"
    status: "True"
    type: PodScheduled
  containerStatuses:
  - containerID: docker://abd378ce0519222c43fc194ba6952475176fba2bb37ee71a5ac9f6838239d2cb
    image: busybox:latest
    imageID: docker-pullable://busybox@sha256:82742949a3709938cbeb9cec79f5eaf3e48b255389f2dcedf2de29ef96fd841c
    lastState: {}
    name: time-check
    ready: true
    restartCount: 0
    started: true
    state:
      running:
        startedAt: "2024-09-01T12:07:49Z"
  hostIP: 192.168.49.2
  hostIPs:
  - ip: 192.168.49.2
  phase: Running
  podIP: 10.244.0.6
  podIPs:
  - ip: 10.244.0.6
  qosClass: BestEffort
  startTime: "2024-09-01T12:07:41Z"

And describe:

Name:             time-check
Namespace:        default
Priority:         0
Service Account:  default
Node:             minikube/192.168.49.2
Start Time:       Sun, 01 Sep 2024 14:07:41 +0200
Labels:           <none>
Annotations:      <none>
Status:           Running
IP:               10.244.0.6
IPs:
  IP:  10.244.0.6
Containers:
  time-check:
    Container ID:  docker://abd378ce0519222c43fc194ba6952475176fba2bb37ee71a5ac9f6838239d2cb
    Image:         busybox:latest
    Image ID:      docker-pullable://busybox@sha256:82742949a3709938cbeb9cec79f5eaf3e48b255389f2dcedf2de29ef96fd841c
    Port:          <none>
    Host Port:     <none>
    Command:
      /bin/sh
    Args:
      -c
      while true; do date; sleep ;done >> /opt/data/time/time-check.log
    State:          Running
      Started:      Sun, 01 Sep 2024 14:07:49 +0200
    Ready:          True
    Restart Count:  0
    Environment:
      TIME_FREQ:  <set to the key 'TIME_FREQ' of config map 'time-config'>  Optional: false
    Mounts:
      /opt/data/time from log-volume (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-bm6wc (ro)
Conditions:
  Type                        Status
  PodReadyToStartContainers   True 
  Initialized                 True 
  Ready                       True 
  ContainersReady             True 
  PodScheduled                True 
Volumes:
  log-volume:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:     
    SizeLimit:  <unset>
  kube-api-access-bm6wc:
    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:
  Type    Reason     Age   From               Message
  ----    ------     ----  ----               -------
  Normal  Scheduled  22m   default-scheduler  Successfully assigned default/time-check to minikube
  Normal  Pulling    22m   kubelet            Pulling image "busybox:latest"
  Normal  Pulled     22m   kubelet            Successfully pulled image "busybox:latest" in 7.077s (7.077s including waiting). Image size: 4261574 bytes.
  Normal  Created    22m   kubelet            Created container time-check
  Normal  Started    22m   kubelet            Started container time-check
added 2 characters in body
Source Link
apiVersion: v1
kind: ConfigMap
metadata:
  name: time-config
data:
  TIME_FREQ: 6"6"
---
apiVersion: v1
kind: Pod
metadata:
  name: time-check
spec:
  containers:
  - name: time-check
    image: busybox:latest
    command: ["/bin/sh"]
    args: ["-c","while true; do date; sleep $TIME_FREQ;done >> /opt/data/time/time-check.log"]
    env:
      - name: TIME_FREQ
        valueFrom:
          configMapKeyRef:
            name: time-config
            key: TIME_FREQ
    volumeMounts:
      - name: log-volume
        mountPath: /opt/data/time
  volumes:
  - name: log-volume
    emptyDir: {}

According to documentation, to use variable you should put it in parentheses, however, that gives me:

TIME_FREQ: command not found
sleep: missing operand

If I use only $TIME_FREQ, the variable does not expand at all and sleep only complains about missing operand. I've tried curly braces, but didn't work, too.

If I set the variable locally, the config will accept it and the command runs ok, with variable defined as $TIME_FREQ.

Why does it not work?

apiVersion: v1
kind: ConfigMap
metadata:
  name: time-config
data:
  TIME_FREQ: 6
---
apiVersion: v1
kind: Pod
metadata:
  name: time-check
spec:
  containers:
  - name: time-check
    image: busybox:latest
    command: ["/bin/sh"]
    args: ["-c","while true; do date; sleep $TIME_FREQ;done >> /opt/data/time/time-check.log"]
    env:
      - name: TIME_FREQ
        valueFrom:
          configMapKeyRef:
            name: time-config
            key: TIME_FREQ
    volumeMounts:
      - name: log-volume
        mountPath: /opt/data/time
  volumes:
  - name: log-volume
    emptyDir: {}

According to documentation, to use variable you should put it in parentheses, however, that gives me:

TIME_FREQ: command not found
sleep: missing operand

If I use only $TIME_FREQ, the variable does not expand at all and sleep only complains about missing operand. I've tried curly braces, but didn't work, too.

If I set the variable locally, the config will accept it and the command runs ok, with variable defined as $TIME_FREQ.

Why does it not work?

apiVersion: v1
kind: ConfigMap
metadata:
  name: time-config
data:
  TIME_FREQ: "6"
---
apiVersion: v1
kind: Pod
metadata:
  name: time-check
spec:
  containers:
  - name: time-check
    image: busybox:latest
    command: ["/bin/sh"]
    args: ["-c","while true; do date; sleep $TIME_FREQ;done >> /opt/data/time/time-check.log"]
    env:
      - name: TIME_FREQ
        valueFrom:
          configMapKeyRef:
            name: time-config
            key: TIME_FREQ
    volumeMounts:
      - name: log-volume
        mountPath: /opt/data/time
  volumes:
  - name: log-volume
    emptyDir: {}

According to documentation, to use variable you should put it in parentheses, however, that gives me:

TIME_FREQ: command not found
sleep: missing operand

If I use only $TIME_FREQ, the variable does not expand at all and sleep only complains about missing operand. I've tried curly braces, but didn't work, too.

If I set the variable locally, the config will accept it and the command runs ok, with variable defined as $TIME_FREQ.

Why does it not work?

Source Link

Passing ENV VAR via ConfigMap does not work

apiVersion: v1
kind: ConfigMap
metadata:
  name: time-config
data:
  TIME_FREQ: 6
---
apiVersion: v1
kind: Pod
metadata:
  name: time-check
spec:
  containers:
  - name: time-check
    image: busybox:latest
    command: ["/bin/sh"]
    args: ["-c","while true; do date; sleep $TIME_FREQ;done >> /opt/data/time/time-check.log"]
    env:
      - name: TIME_FREQ
        valueFrom:
          configMapKeyRef:
            name: time-config
            key: TIME_FREQ
    volumeMounts:
      - name: log-volume
        mountPath: /opt/data/time
  volumes:
  - name: log-volume
    emptyDir: {}

According to documentation, to use variable you should put it in parentheses, however, that gives me:

TIME_FREQ: command not found
sleep: missing operand

If I use only $TIME_FREQ, the variable does not expand at all and sleep only complains about missing operand. I've tried curly braces, but didn't work, too.

If I set the variable locally, the config will accept it and the command runs ok, with variable defined as $TIME_FREQ.

Why does it not work?