I'm using rke to generate a Kubernetes cluster in a private cloud. It produces a kube_config_cluster.yml file. Is there a way to add this config to my $HOME/.kube/config file?
Without having the .kube/config set, when using kubectl, I have to pass the argument:
kubectl --kubeconfig kube_config_cluster.yml <command>Or set the KUBECONFIG environment variable.
export KUBECONFIG=kube_config_cluster.ymlkubectl config merge command is not yet available. But you can achieve a config merge by running:
Command format:
KUBECONFIG=config1:config2 kubectl config view --flattenExample:
Merge a config to ~/.kube/config and write back to ~/.kube/config-new.yaml.
KUBECONFIG=~/.kube/config:/path/to/another/config.yml kubectl config view --flatten > ~/.kube/config-new.yamlcp ~/.kube/config-new.yaml ~/.kube/config
If kubectl can read that as a valid config file, you can just use that as your kubeconfig. So cp kube_config_cluster.yaml $HOME/.kube/config should work fine. From there it'll read that config file by default and you won't have to specify it.
I generally use the below commands to see and change context, not too cluttered and easy to fire
**kubectl config current-context** #show the current context in use
**kubectl config use-context _context-name-you-want-to-use_**