Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix kubeconfig merge with existing config #351

Merged
merged 3 commits into from
Feb 6, 2025

Conversation

alankan-finocomp
Copy link
Contributor

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 the current-context in the kubeconfig file.

Linked Issues

#350

@dereknola
Copy link
Member

dereknola commented Jul 26, 2024

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.

Copy link
Member

@dereknola dereknola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order for this to not affect user defined kubeconfigs, we need to check and see if the kubeconfig is still equal to our variable default.

roles/k3s_server/tasks/main.yml Outdated Show resolved Hide resolved
roles/k3s_server/tasks/main.yml Outdated Show resolved Hide resolved
Copy link
Member

@dereknola dereknola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need to override the default kubeconfig at the end

roles/k3s_server/tasks/main.yml Outdated Show resolved Hide resolved
@joaogbcravo
Copy link

There is also the block which can cause a full overwrite.

@rpressiani
Copy link

This was a good PR, any chance we can accept the changes and merge it? @dereknola @alankan-finocomp

@dereknola
Copy link
Member

I can take it over and fix it up, likely sometime next week when I have free time.

@dereknola dereknola merged commit 978bc50 into k3s-io:master Feb 6, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants