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: add namespace for applicable helm chart resources #2040

Closed

Conversation

rasmusdencker
Copy link

@rasmusdencker rasmusdencker commented Jun 7, 2022

What this PR does

Adds namespace to all Helm resources.

Note: I also removed parts with with .namespace to normalize namespace declarations.

{{- with .namespace }}
  namespace: {{ . }}
  {{- end }}

This is probably considered a breaking change, so let me know if I should reintroduce them and fall back to .Release.Namespace instead. It's noteworthy that this convention was also very inconsistent, so I'm finding it hard to believe that it's used 'in the wild'.

Which issue(s) this PR fixes or relates to

Fixes #2045

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Contributor

@krajorama krajorama left a comment

Choose a reason for hiding this comment

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

Hi , thank you for the PR,

What problem does adding the namespace solve? We used to have some namespace definitions, but then we removed them because they are redundant, implied by helm -n anyway.

Also, the ServiceMonitoring needs the current setup. Please see my comment on that inline.

regards, krajo

{{- with .namespace }}
namespace: {{ . }}
{{- end }}
namespace: {{ .Release.Namespace | quote }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually here we may want to place this custom resource into the namespace of prometheus operator , and not into the release namespace, hence we used .Values.serviceMonitor.namespace, instead of the Release namespace. I actually have it running with my Mimir being in dev and Prom monitoring in the monitoring namespace:

serviceMonitor:
  enabled: true
  namespace: monitoring
  namespaceSelector:
    matchNames:
      - dev

Copy link
Author

Choose a reason for hiding this comment

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

Yup, that does make sense. I'll fix this in my next iteration.

Copy link
Contributor

Choose a reason for hiding this comment

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

it might still make sense to default to the .Release.Namespace

@dimitarvdimitrov
Copy link
Contributor

Hey @krajorama, there was some prior discussion in the community slack: thread. And I created an issue #2045 to give slightly more context. Basically, not having an explicit namespace makes applying via helm template --namespace foo ... | kubectl apply -f - possible; similar use-case is GitOps. Without explicit namespace resources are created in the current context namespace.

This is probably considered a breaking change

@rasmusdencker not sure if we should worry about this. It seems like the behaviour was mostly consistent, but I don't think it was consistent enough to work without additional tweaks. And I don't think these tweaks will be broken by this change.

@dimitarvdimitrov
Copy link
Contributor

I think you need to rebase this PR to make the CI pass. A fix was merged in #2051

@rasmusdencker
Copy link
Author

Got it @dimitarvdimitrov - I'll rebase it in my next iteration.

@krajorama krajorama added the helm label Jun 15, 2022
@krajorama
Copy link
Contributor

Sorry for the long delay, was busy with other things. I see your point. I'll re-review when rebased.

Note: we now have more people working on the chart, so there are rapid changes going on. In particular I think you'll need to run make check-helm-tests after rebase to update the generated manifests we store now in the repo.

@krajorama krajorama mentioned this pull request Jun 17, 2022
2 tasks
@krajorama
Copy link
Contributor

Hi,

I've got an updated version of this fix going in #2123 . @rasmusdencker indicated as co-author.

@rasmusdencker
Copy link
Author

rasmusdencker commented Jun 18, 2022

Oh, thanks @krajorama. I'll close this one. Sorry for not following up earlier.

@rasmusdencker rasmusdencker deleted the fix/helm-chart-namespace branch June 21, 2022 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

helm: Not all resources respect the release namespace
5 participants