Open alankan-finocomp opened 4 months ago
~This function is not intended to merge with the default kubeconfig. That's why there is an explicit check~ This seems to be an error with the if statement, it should be reversed. https://github.com/k3s-io/k3s-ansible/blob/master/roles/k3s_server/tasks/main.yml#L160
The intention is that if supply a dedicated kubeconfig location for the k3s-ansible controlled clusters, we don't do any merging or overriding.
There is also the block which can cause a full overwrite.
Changes
Since the existing config file was not in scope, the commands did not perform anything.
To fix it, I include the existing kubeconfig path in KUBECONFIG variable such that the YAML contents are merged when it prints out via
kubectl config view --flatten
Also, replacing keyword "default" with ansible variable
kube_config
can also help replace thecurrent-context
in the kubeconfig file.Linked Issues
https://github.com/k3s-io/k3s-ansible/issues/350