Select `kubectl` context with environment variable?

Hello!

Is there a way to ask kubectl to use a specific context via environment variable, rather than through --context?

That is, instead of: kubectl --context foo ...
I’d like to be able to do: KUBECTL_CONTEXT=foo kubectl ...

(Or whatever – the name of the environment variable isn’t important.)

Similar to both Helm (HELM_KUBECONTEXT) and other tools, e.g., aws-cli (AWS_PROFILE vs. --profile).

Apologies if I missed an existing feature, but it looks like there are only 4 documented environment variables ?

(There’s KUBECONFIG which can be used for something similar (by copying content from the shared config file and specifying the current context). But that involves creating a separate config file, when all I need in the current case is to use a specific context out of the existing shared ~/.kube/config file.)

Thank you!

I think to achieve the desired behavior of specifying a specific context for kubectl without using the --context flag.
The KUBECONFIG environment variable allows you to define the path to the Kubernetes configuration file that kubectl should use. By default, kubectl looks for the configuration file at ~/.kube/config. However, you can override this by setting the KUBECONFIG environment variable.
Trying to outsource technical support services in this case may be a good idea)