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

[Grafana] Suggest adding a persistence.volumeName Helm value setting to allow reusing an existing PV #3538

Open
hyukjuns opened this issue Jan 22, 2025 · 1 comment

Comments

@hyukjuns
Copy link

hyukjuns commented Jan 22, 2025

Chart Info and Environment
Chart Name: grafana/grafana
Chart Version: 8.8.2
App Version: 11.4.0
Kubernetes: AKS v1.28.x
Parent Chart: kube-prometheus-stack (chart version: 67.10.0, app version: v0.79.2)

I encountered this issue while using the Grafana Helm chart as a dependency of the kube-prometheus-stack Helm chart, which led me to write this post.

Why is this needed

Currently, when using Grafana as a StatefulSet, we may need to delete the existing Grafana and reinstall it. Even if the PV's Reclaim Policy is set to 'Retain' and we manually restore the PV, we cannot reuse the recovered PV because the volumeName field is missing in the statefulset.yaml

What would you like to be added

I worked around the issue and solved it as follows.

First, I revised the chart myself.
In charts/grafana/templates/statefulset.yaml, add the volumeName entry as follows.

volumeClaimTemplates:
  - apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: storage
    spec:
      accessModes: {{ .Values.persistence.accessModes }}
      storageClassName: {{ .Values.persistence.storageClassName }}
      volumeName: {{ .Values.persistence.volumeName | quote }} # This is an added new line
      ...

Then, I specified the existing PV name in the user values and reinstalled the chart.

  # StatefulSet Setting
  persistence:
    enabled: true
    type: sts
    storageClassName: azuredisk-ssd-lrs
    accessModes:
      - ReadWriteOnce
    size: 8Gi
    finalizers:
      - kubernetes.io/pvc-protection
    volumeName: restore-grafana-pv # Restored PV Name

This allowed me to successfully reuse the existing PV.

Who is this feature for?
If this is added, I think it will make it easier for those who run Grafana with StatefulSet and have created custom dashboards but have to delete and reinstall Grafana due to unavoidable circumstances to preserve existing dashboards.


If I have misunderstood something or if the feature already exists but I have overlooked it, I would appreciate it if you could let me know.

@hyukjuns hyukjuns changed the title [Grafana] Suggest adding persistence.volumeName helm value setting item to reuse existing PV [Grafana] Suggest adding a persistence.volumeName Helm value setting to allow reusing an existing PV Jan 22, 2025
@hyukjuns
Copy link
Author

If there are no issues with this approach, I would like to ask if it's okay to create a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant