Hi Guys need suggestion on one lab question: *question :* Create a pod called ` . . .

Mohit Tayal:
Hi Guys need suggestion on one lab question:
question :
Create a pod called my-busybox in the dev2406 namespace using the busybox image. The container should be called secret and should sleep for 3600 seconds.
The container should mount a read-only secret volume called secret-volume at the path /etc/secret-volume. The secret being mounted has already been created for you and is called dotfile-secret.
Make sure that the pod is scheduled on master/controlplane and no other node in the cluster.

yaml created : :point_down:

controlplane $ cat secret.yaml 
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  name: my-busybox
  namespace: dev2406
spec:
  nodeName: master
  containers:
  - command:
    - sleep 3600
    image: busybox
    name: secret
    volumeMounts:
    - name: secret-volume
      readOnly: true
      mountPath: "/etc/secret-volume"
  volumes:
  - name: secret-volume
    secret:
      secretName: dotfile-secret
  restartPolicy: Never

When i am creating it , its status is showing pending only not going into running mode and after sometime automatically exists.

controlplane $ kubectl get pods --all-namespaces | grep -i my-busybox
dev2406         my-busybox                                  0/1     Pending     0          28s
controlplane $ 
controlplane $ 
controlplane $ 
controlplane $ 
controlplane $ kubectl get pods --all-namespaces | grep -i my-busybox
dev2406         my-busybox                                  0/1     Pending     0          37s
controlplane $ 

Describe output of the created pod.

controlplane $ kubectl -n dev2406 describe pod my-busybox 
Name:         my-busybox
Namespace:    dev2406
Priority:     0
Node:         master/
Labels:       <none>
Annotations:  <none>
Status:       Pending
IP:           
IPs:          <none>
Containers:
  secret:
    Image:      busybox
    Port:       <none>
    Host Port:  <none>
    Command:
      sleep 3600
    Environment:  <none>
    Mounts:
      /etc/secret-volume from secret-volume (ro)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-5trqm (ro)
Volumes:
  secret-volume:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  dotfile-secret
    Optional:    false
  default-token-5trqm:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-5trqm
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     <http://node.kubernetes.io/not-ready:NoExecute|node.kubernetes.io/not-ready:NoExecute> op=Exists for 300s
                 <http://node.kubernetes.io/unreachable:NoExecute|node.kubernetes.io/unreachable:NoExecute> op=Exists for 300s
Events:          &lt;none&gt;
controlplane $ 
controlplane $ kubectl get pods --all-namespaces | grep -i my-busybox
controlplane $

Can someone please assist, what i am doing wrong here ??

Tej_Singh_Rana:
Hello, @Mohit Tayal
I think node name should be controlplane instead of master.
Even you can check through cmd line - kubectl get nodes

Mohit Tayal:
@Tej_Singh_Rana let me try it, also can you please suggest, the way i defined my command is correct ?

Tej_Singh_Rana:
Yeah, that’s correct.

Mohit Tayal:
@Tej_Singh_Rana after corrceting nodeName to controlplane pod now created by it is throwing error :

QoS Class:       BestEffort
Node-Selectors:  &lt;none&gt;
Tolerations:     <http://node.kubernetes.io/not-ready:NoExecute|node.kubernetes.io/not-ready:NoExecute> op=Exists for 300s
                 <http://node.kubernetes.io/unreachable:NoExecute|node.kubernetes.io/unreachable:NoExecute> op=Exists for 300s
Events:
  Type     Reason   Age   From                   Message
  ----     ------   ----  ----                   -------
  Normal   Pulling  33s   kubelet, controlplane  Pulling image "busybox"
  Normal   Pulled   32s   kubelet, controlplane  Successfully pulled image "busybox" in 989.087747ms
  Normal   Created  31s   kubelet, controlplane  Created container secret
  Warning  Failed   31s   kubelet, controlplane  Error: failed to start container "secret": Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"sleep 3600\": executable file not found in $PATH": unknown
controlplane $ 

Mohit Tayal:
seems command is not running

Mohit Tayal:
got the error :
command must contain execution path
/bin/sh -c

Pierpaolo P:
as @Mohit Tayal suggests try the pod/commad section as the following:

spec:
  nodeName: master
  containers:
  - command:
    - /bin/sh
    - -c
    - sleep 3600
    image: busybox
    ......

Raamkanna Saranathan:
should be
/bin/sh
-c
sleep
3600

different lines