grafana / helm-charts

Apache License 2.0
1.62k stars 2.24k forks source link

Issue in dynamiclly set volume name by Azure #3156

Open tyagivasu opened 4 months ago

tyagivasu commented 4 months ago

Hi, In my helm diff I am seeing below changes for a dynamically created volume by Azure.

# Source: kube-prometheus-stack/charts/grafana/templates/pvc.yaml
  apiVersion: v1
  kind: PersistentVolumeClaim
  metadata:
    name: grafana
    namespace: <namespace>
    labels:
      helm.sh/chart: grafana-7.3.9
      app.kubernetes.io/name: grafana
      app.kubernetes.io/instance: grafana
      app.kubernetes.io/version: "10.4.1"
      app.kubernetes.io/managed-by: Helm
    finalizers:
      - kubernetes.io/pvc-protection
  spec:
    accessModes:
      - "ReadWriteOnce"
    resources:
      requests:
        storage: "<n>Gi"
-   volumeName: pvc-<dynamic_id_number>
    storageClassName: managed-premium-extensible

Further when I look into this issue, identified that below logic causing it.

{{- if (lookup "v1" "PersistentVolumeClaim" (include "grafana.namespace" .) (include "grafana.fullname" .)) }} volumeName: {{ (lookup "v1" "PersistentVolumeClaim" (include "grafana.namespace" .) (include "grafana.fullname" .)).spec.volumeName }} {{- end }} refer link for more detail.

Can I have some fix to resolve this diff change happeing everytime? Also I would like to understand why this logic needed, and introduced?

Ross-Duckworth-Pharos commented 3 months ago

Yes, we have the same issue with a false diff being reported when using an AWS PVC. The problem appears to be caused by the Helm lookup function not executing during the diff.

tyagivasu commented 3 months ago

Yes, we have the same issue with a false diff being reported when using an AWS PVC. The problem appears to be caused by the Helm lookup function not executing during the diff.

@Ross-Duckworth-Pharos is this resolve in your case? do you have any suggestion here?

Ross-Duckworth-Pharos commented 3 months ago

Yes, we have the same issue with a false diff being reported when using an AWS PVC. The problem appears to be caused by the Helm lookup function not executing during the diff.

@Ross-Duckworth-Pharos is this resolve in your case? do you have any suggestion here?

No, unfortunately. We just have to ignore the diff, which isn't ideal.

Rohlik commented 3 months ago

We have the same issue as @Ross-Duckworth-Pharos when we run the Grafana Helm chart on EKS with PVC. A fix would be nice, as this also breaks a rollback; see https://github.com/grafana/helm-charts/issues/3125.

dimaslv commented 2 months ago

Workaround is to run helm diff --dry-run=server. helm diff --help has this snippet: --dry-run=server enables the cluster access with helm-get and the lookup template function. But it still doesn't fix helm install. To fix it globally use environmental variable HELM_DIFF_USE_UPGRADE_DRY_RUN=true.