The default k8s config file is in ~/.kube/config Is it possible to specify the config explicitly when using kubectl command ? Thanks
kubectl can use the KUBECONFIG in three different ways:
Using the KUBECONFIG present in ~/.kube/config if nothing is specified in kubectl command.
Using the KUBECONFIG defined by using the KUBECONFIG environment variable if nothing is specified in kubectl command.
Passing the KUBECONFIG as part of the kubectl command using the --kubeconfig flag as:
kubectl --kubeconfig=<KUBECONFIG_PATH>
Further, the order of precedence is as follows:
KUBECONFIG if explicitly passed in the kubectl commandKUBECONFIG from the environment variable if --kubeconfig flag is not specified but the environment variable is set.KUBECONFIG from ~/.kube/config if both --kubeconfig and KUBECONFIG are not specified.Use KUBECONFIG env for using custom kubeconfig file with kubectl:
$ export KUBECONFIG=/path/to/config
Yes you can specify like this
kubectl config --kubeconfig=your_kubeconfi_file_path <YOUR_OPERATION>