helm-charts icon indicating copy to clipboard operation
helm-charts copied to clipboard

[kube-prometheus-stack] pre-upgrade helm hook hinders namespaceOverride ns. creation

Open yellowmegaman opened this issue 3 years ago • 0 comments

Describe the bug a clear and concise description of what the bug is.

When upgrading (installing) kube-prometheus-stack with namespaceOverride, I'm defining namespace in umbrella chart's templates directory.

What's your helm version?

version.BuildInfo{Version:"v3.9.0", GitCommit:"7ceeda6c585217a19a1131663d8cd1f7d641b2a7", GitTreeState:"clean", GoVersion:"go1.17.5"}

What's your kubectl version?

Client Version: version.Info{Major:"1", Minor:"24", GitVersion:"v1.24.4+k3s1", GitCommit:"c3f830e9b9ed8a4d9d0e2aa663b4591b923a296e", GitTreeState:"clean", BuildDate:"2022-08-25T03:45:26Z", GoVersion:"go1.18.1", Compiler:"gc", Platform:"linux/amd64"} Kustomize Version: v4.5.4

Which chart?

kube-prometheus-stack

What's the chart version?

v39.11.0

What happened?

Getting error:

Error: UPGRADE FAILED: pre-upgrade hooks failed: warning: Hook pre-upgrade wft/charts/kube-prometheus-stack/templates/prometheus-operator/admission-webhooks/job-patch/serviceaccount.yaml failed: namespaces "monitoring" not found

What you expected to happen?

ServiceAccount to be created after namespace is created from templates directory

How to reproduce it?

This is happening because resources in templates/prometheus-operator/admission-webhooks/job-patch have "helm.sh/hook": pre-install,pre-upgrade,post-install,post-upgrade annotation.

Enter the changed values of values.yaml?

kube-prometheus-stack:
  installCRDs: true
  namespaceOverride: "monitoring"
  fullnameOverride: "kube-prometheus-stack"
  alertmanager:
    enabled: false
  grafana:
    namespaceOverride: "monitoring"
    admin:
      existingSecret: "grafana"
    grafana.ini:
      server:
        serve_from_sub_path: "true"
        domain: *domain
    ingress:
      enabled: true
      hosts: [*domain]
    plugins: "grafana-piechart-panel"
    extraObjects:
    - apiVersion: 'kubernetes-client.io/v1'
      kind: ExternalSecret
      metadata:
        labels:
          service: grafana
          type: secret
        name: grafana
        namespace: monitoring
      spec:
        backendType: vault
        vaultRole: external-secrets
        kvVersion: 1
        data:
          - name: admin-user
            key: kv/grafana
            property: admin-user
          - name: admin-password
            key: kv/grafana
            property: admin-password
          - name: ldap-toml
            key: kv/grafana
            property: ldap-toml
  prometheus-node-exporter:
    namespaceOverride: "monitoring"
  kube-state-metrics:
    namespaceOverride: "monitoring"
  admissionWebhooks:
    failurePolicy: "Ignore"

Enter the command that you execute and failing/misfunctioning.

helm upgrade --dependency-update --install umbrella -n umbrella --create-namespace

Anything else we need to know?

Question - do we absolutely need it there? Right now kube-prometheus-stack chart is perfectly ready to act as a dependency in umbrella chart, but we need to run additional apply/command to create namespace before installing it.

yellowmegaman avatar Sep 04 '22 21:09 yellowmegaman