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

'~/.kube/config` incorrectly being a directory, changes the template results of some helm charts, and produces no warnings/errors. #5472

Closed
spkane opened this issue Dec 4, 2023 · 5 comments
Labels
area/helm kind/bug Categorizes issue or PR as related to a bug. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. triage/out-of-scope Indicates an issue or PR is not a fit for Kustomize's scope and/or principles

Comments

@spkane
Copy link

spkane commented Dec 4, 2023

What happened?

When kustomize build --enable-helm is run with a Kubeconfig that is actually a directory, the value of {{ .Release.Namespace }} is changing in some templates.

I was seeing some very strange results when doing testing, and after a lot of troubleshooting, I realized that an error in the test container had caused /root/.kube/config to be created as a directory inside the container, and this then triggered the template results to change without any errors or warning.

I am not 100% sure if the underlying issue handling this situation is in kustomize or helm. I got this far with my testing, but I have not tried to figure out if this reproduces with helm directly.

Also submitted here: helm/helm#12611

What did you expect to happen?

I would either expect the tool to produce an error or warning regarding the kube config issues while either rendering the helm templates exactly the same way as it normally would or quitting completely.

How can we reproduce it (as minimally and precisely as possible)?

Create a new directory with these two files:

  • kustomization.yaml
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

helmCharts:
  - name: testkube
    repo: https://kubeshop.github.io/helm-charts
    releaseName: testkube
    namespace: testkube
    version: 1.16.11
    valuesFile: helm-values.yaml
  • helm-values.yaml
---
mongodb:
  enabled: true

testkube-api:
  nats:
    enabled: true

testkube-dashboard:
  enabled: true

testkube-operator:
  enabled: true
  namespace: testkube-system
  • Test a build on a local system
$helm version
version.BuildInfo{Version:"v3.13.2", GitCommit:"2a2fb3b98829f1e0be6fb18af2f6599e0f4e8243", GitTreeState:"clean", GoVersion:"go1.21.4"}

$ kustomize version
v5.2.1

$ kustomize build --enable-helm | grep "namespace: default"
$

This output appears correct, as there are NO namespaces set to default.

But if we replace the kube config with a directory, the namespaces change and there are no errors, warnings, etc.

$ mv ~/.kube/config ~/.kube/config.bak
$ mkdir ~/.kube/config

$ kustomize build --enable-helm | grep "namespace: default"
  namespace: default
  namespace: default
  namespace: default
  namespace: default
  namespace: default
  namespace: default
  namespace: default
...

$ rmdir ~/.kube/config
$ mv ~/.kube/config.bak ~/.kube/config

Expected output

  • A warning or error and no templates should have their namespace set to default.

Actual output

  • There is no warning or error, and many templates have their namespace set to default.

Kustomize version

v5.2.1

Helm version

version.BuildInfo{Version:"v3.13.2", GitCommit:"2a2fb3b98829f1e0be6fb18af2f6599e0f4e8243", GitTreeState:"clean", GoVersion:"go1.21.4"}

Kubectl Version

Client Version: v1.28.4
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3

Operating system

MacOS

@spkane spkane added the kind/bug Categorizes issue or PR as related to a bug. label Dec 4, 2023
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Dec 4, 2023
@koba1t
Copy link
Member

koba1t commented Feb 11, 2024

I can reproduce this problem, But I believe this problem is caused by the helm binary according to the comment below.
helm/helm#12611 (comment)

I think we need to wait for resolve at the helm.

/area helm
/triage out-of-scope

@k8s-ci-robot k8s-ci-robot added area/helm triage/out-of-scope Indicates an issue or PR is not a fit for Kustomize's scope and/or principles and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Feb 11, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 11, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle rotten
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jun 10, 2024
@koba1t
Copy link
Member

koba1t commented Jun 11, 2024

Please feel free to reopen this issue if you have any problems now!

/close

@k8s-ci-robot
Copy link
Contributor

@koba1t: Closing this issue.

In response to this:

Please feel free to reopen this issue if you have any problems now!

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/helm kind/bug Categorizes issue or PR as related to a bug. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. triage/out-of-scope Indicates an issue or PR is not a fit for Kustomize's scope and/or principles
Projects
None yet
Development

No branches or pull requests

4 participants