Can you please tell me how to pass arguments via imperative command ? below com . . .

Ravi Paragi:
Can you please tell me how to pass arguments via imperative command ? below command adds the command

"kubectl run webapp-green --image=kodekloud/webapp-color --command color=green --dry-run=client -o yaml"

image.png

Alicio Cerqueira:
if this “–command color=green” is the cvommand …
then,… should be

--command color green

Alicio Cerqueira:
it will generate this at yaml
command:

  • color
  • green

Ravi Paragi:
I would like to pass like this.

- args: ["--color", "green"]

Alicio Cerqueira:
as this doc… seems that you should use COMMAND
https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#run

Alicio Cerqueira:
maybe you you will need to output it into a file and edit it

Ravi Paragi:
@Alicio Cerqueira thank you. let me take a look and explore . I came across the practice test were just need to pass arguments without command.

Tej_Singh_Rana:

$ kubectl run webapp-green --image=kodekloud/webapp-color --dry-run=client -oyaml -- color=green

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: webapp-green
  name: webapp-green
spec:
  containers:
  - args:
    - color=green
    image: kodekloud/webapp-color
    name: webapp-green
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Always
status: {}

Tej_Singh_Rana:

$ kubectl run webapp-green --image=kodekloud/webapp-color --dry-run=client -oyaml -- --color green

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: webapp-green
  name: webapp-green
spec:
  containers:
  - args:
    - --color
    - green
    image: kodekloud/webapp-color
    name: webapp-green

Ravi Paragi:
@Tej_Singh_Rana - Thank you so much… :+1: