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

kapp uses wrong default namespace when run in-cluster (with explicit KUBECONFIG env var) #728

Closed
hojerst opened this issue Mar 24, 2023 · 1 comment
Labels
bug This issue describes a defect or unexpected behavior

Comments

@hojerst
Copy link

hojerst commented Mar 24, 2023

What steps did you take:

  • Prepare kapp/kctrl in a Pod of a Kubernetes cluster
  • set KUBECONFIG (and/or KAPP_KUBECONFIG) to another cluster where no default namespace is set
  • execute kapp ls or kapp deploy without a explicit namespace

What happened:
kapp will default to the namespace of the execution environment (pod it is running in), although the KUBECONFIG might point to a completely different cluster which doesn't have this namespace

What did you expect:
kapp will install the manifests into default namespace or the one explicitly configured inside the KUBECONFIG

Anything else you would like to add:
As a workaround it seems to explicitly unsetting KUBERNETES_SERVICE_HOST or KUBERNETES_SERVICE_PORT seems to fix this behaviour as https://github.com/kubernetes/client-go/blob/1517ffb8d37c99e6a3a2842bcdee0aa271f0332b/tools/clientcmd/client_config.go#L604-L609 seems to check for that (thanks to @cppforlife for pointing this out in Slack)

Environment:

  • kapp version (use kapp --version): kapp version 0.54.1
  • OS (e.g. from /etc/os-release): Debian 11 (doesn't seem to matter)
  • Kubernetes version (use kubectl version): not relevant

Vote on this request

This is an invitation to the community to vote on issues, to help us prioritize our backlog. Use the "smiley face" up to the right of this comment to vote.

👍 "I would like to see this addressed as soon as possible"
👎 "There are other more important things to focus on right now"

We are also happy to receive and review Pull Requests if you want to help working on this issue.

@hojerst hojerst added bug This issue describes a defect or unexpected behavior carvel triage This issue has not yet been reviewed for validity labels Mar 24, 2023
@hojerst hojerst changed the title kapp prioritizes in-cluster kubeconfig over explicit KUBECONFIG env var kapp uses wrong default namespace when run in-cluster (with explicit KUBECONFIG env var) Mar 27, 2023
@hojerst
Copy link
Author

hojerst commented Mar 29, 2023

After some discussion in slack, it seems this is a behaviour introduced by the upstream k8s go client. kubectl shows the same behaviour as well. I'll close this as it is not really a problem of kapp

kubernetes/client-go#1241

@hojerst hojerst closed this as completed Mar 29, 2023
@github-actions github-actions bot removed the carvel triage This issue has not yet been reviewed for validity label Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue describes a defect or unexpected behavior
Projects
Archived in project
Development

No branches or pull requests

1 participant