I have a question about the pod command and args - I’m trying to understand what . . .

Phani M:
I have a question about the pod command and args - I’m trying to understand what is the difference in these two manifests. Both will bring up a pod successfully in Running status, but the Lightning Lab question#7 is failed even though the busybox pod is running.

apiVersion: v1
kind: Pod
metadata:
  labels:
    run: secret-1401
  name: secret-1401
  namespace: admin1401
spec:
  containers:
  - command:
    - sleep
    - "4800"
    image: busybox
    name: secret-1401
    volumeMounts:
    - name: secret-volume
      mountPath: "/etc/secret-volume"
      readOnly: true
  volumes:
  - name: secret-volume
    secret:
      secretName: dotfile-secret

The above Pod is created using

k run secret-1401 --image=busybox -n admin1401 --restart=Never --command sleep 4800 $do > pod.yaml

Referring to the Solutions of Lightning Lab, Question #7 states to use this manifest:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: secret-1401
  name: secret-1401
  namespace: admin1401
spec:
  volumes:
  - name: secret-volume
    secret:
      secretName: dotfile-secret
  containers:
  - command:
    - sleep
    args:
    - "4800"
    image: busybox
    name: secret-admin
    volumeMounts:
    - name: secret-volume
      readOnly: true
      mountPath: "/etc/secret-volume"     

The only difference I see is mention of args in second one, but when given

--command sleep 4800

there is no args being auto created.
I believe in the exam, it shouldn’t matter, ultimately the Pod should be in Running status in the right namespace. May be @Tej_Singh_Rana please modify the criteria of validating the question/answer before grading the test.

controlplane $ kgp -n admin1401
NAME          READY   STATUS    RESTARTS   AGE
secret-1401   1/1     Running   0          96s
controlplane $ 

Fernando Jimenez:
For the given comparison, the following produces the same results at the container level.

  - command:
    - sleep
    - "4800"

or

- command: ["sleep", "4800"]

and

  - command:
    - sleep
    args:
    - "4800"

However, at the pod level, there is a subtle distinction between the first and the second form.
The first example is crafting a command that supplies an argument along side the command itself. In second example, the command is a bared command where the argument (if any) is given or appended to the command.
Things starts to get interesting when you do the following.

  - command:
    - sleep
    - "4800"
    args:
    - "3800"

I encourage you to exec into a pod with that last example and do a ps auxw to see the result.
My suggestion, for the purpose of the exam, unless specified explicitly, stick with the first one.

Nitin:
@Phani M what does the failure message says?

Tej_Singh_Rana:
Hello, @Phani M
Technically both solutions are correct but validation is looking for 1 method at a time. which is

- command:
   - sleep
  args:
  - "4800"

In the official exam, both will work. If there are no specific instructions given in the question then you can use either the first solution or second.

Malayamanas Panda:

- command:
   - sleep
  args:
  - "4800"

YAML’s - command: , translates to container’s ENTRYPOINT and YAML’s arg: , translates to container’s CMD . It overrides image’s default ENTRYPOINT and CMD .