How to pass an argument to kuttl test and make use of it

3/27/2021

One basic kuttl test is :

apiVersion: v1
kind: Pod
metadata:
  name: my-pod
status:
  phase: Successful

But the pod name gets some random Id at the end. For example, if I am creating a pod: hello, it gets generated as hello-gdha123-67as. In this case, I am not aware of the pod name since it gets Generated randomly. I want to pass the variable in place or name in the above test. Any suggestions? I know the command to get only the pod name. If I put it in some YAML, how can we pass it to the test?

-- sujatha rathod
kubernetes

1 Answer

3/27/2021

You can use the option --overrides

example: Start a nginx pod, but overload the spec with a partial set of values parsed from JSON.

  kubectl run nginx --image=nginx --overrides='{ "apiVersion": "v1", "spec": { ... } }'

ref: https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands

-- Girdhar Singh Rathore
Source: StackOverflow