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

Helm chart is not utilizing helms create_namespace #514

Open
mariuskimmina opened this issue Jan 6, 2025 · 0 comments
Open

Helm chart is not utilizing helms create_namespace #514

mariuskimmina opened this issue Jan 6, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@mariuskimmina
Copy link

mariuskimmina commented Jan 6, 2025

We are using the helm chart from terraform as follows:

resource "kubernetes_namespace" "k6" {
  metadata {
    name = var.namespace
  }
}

resource "helm_release" "k6_operator" {
  name        = "k6-operator"
  repository  = "https://grafana.github.io/helm-charts"
  chart       = "k6-operator"
  namespace   = var.namespace
  version     = var.operator_chart_version
  max_history = var.helm_release_max_history
  depends_on  = [kubernetes_namespace.k6]
  create_namespace = false
}

Now this fails with

│ Error: Unable to continue with install: Namespace "k6-testing" in namespace "" exists and cannot be imported into the current release: invalid ownership metadata; label validation error: missing key "app.kubernetes.io/managed-by": must be set to "Helm"; annotation validation error: missing key "meta.helm.sh/release-name": must be set to "k6-operator"; annotation validation error: missing key "meta.helm.sh/release-namespace": must be set to "k6-testing"
│
│   with module.k6.helm_release.k6_operator,
│   on ../../modules/k6/main.tf line 7, in resource "helm_release" "k6_operator":
│    7: resource "helm_release" "k6_operator" {

The reason for this is that the helm chart currently doesn't utilize create_namespace provided by Helm but instead it creates it's own Namespace object

{{- if .Values.namespace.create }}
apiVersion: v1
kind: Namespace
metadata:
  name: {{- include "k6-operator.namespace" . }}
  labels:
    app.kubernetes.io/name: {{ include "k6-operator.fullname" . }}
    control-plane: "controller-manager"
    {{- with .Values.customLabels }}
      {{- toYaml . | nindent 4 }}
    {{- end }}
  annotations:
    {{- include "k6-operator.customAnnotations" . | default "" | nindent 4 }}
{{- end }}

This can of course be worked around by setting

set {
    name  = "namespace.create"
    value = "false"
}

It would be nice if the helm standard 'create_namespace` could be used instead tho.

Somewhat related: helm/helm#2853

Helm chart version (if applicable)

3.10.1

@mariuskimmina mariuskimmina added the bug Something isn't working label Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant