I want to execute set
in a pod, to analyze the environment variables:
kubectl exec my-pod -- set
But I get this error:
OCI runtime exec failed: exec failed: container_linux.go:370: starting container process caused: exec: "set": executable file not found in $PATH: unknown
I think, this is a special case, because there's no executable set
like there's for example an execute ls
.
Remarks
set
there.kubectl exec
with other commands, for example ls
, I get no error.kubectl exec
. But these do not apply to my question, because my problem is about executing set
.set
is not a binary but instead a shell command that sets the environment variable.
If you want to set an environment variable before executing a follow up command consider using env
kubectl exec mypod -- env NAME=value123 script01
# or
kubectl exec mypod -- /bin/sh -c 'NAME=value123 script01'
see https://stackoverflow.com/a/55894599/93105 for more information
if you want to set the environment variable for the lifetime of the pod then you probably want to set it in the yaml manifest of the pod itself before creating it.
you can also run set
if you first run the shell
kubectl exec mypod -- /bin/sh -c 'set'