0

I have taken a helm chart : grafana directly from helm-repository. Now i need to copy a file inside grafana-pod at a specific location. I can do it by :

kubectl cp <file-to-be-copied> <pod-name>:<target-location-inside-pod>

But i need to automate it, so i was looking for volumeMount but i couldn't find any deployment.yaml/templates to add it into. Let me know if there's any provision/method to automate this operation via kubernetes or grafana.

medgai
  • 82
  • 4
  • 13
  • Usually Charts expose a extraVolumeMounts in their values which can help you doing exactly what you want. Maybe even better, if the file is just a configuration file, would be to use extraConfigmapMounts if available. But that depends from the Chart you are using – AndD Feb 05 '21 at 07:23
  • thanks for suggestion @AndD, I needed to copy a json file inside the pod. I have dropped the idea of taking chart from helm-repo, instead cloned it and modified templates for the same. And it's working now. – medgai Feb 05 '21 at 08:57
  • That also works for sure, it's just slightly uncomfy because should you want to update your chart, you need to do it manually, but I do that as well when necessary. – AndD Feb 05 '21 at 08:59
  • 1
    Can you combine the examples from Helm's [Accessing Files Inside Templates](https://docs.helm.sh/docs/chart_template_guide/accessing_files/) to create a ConfigMap from the file, and Kubernetes [Add ConfigMap data to a Volume](https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#add-configmap-data-to-a-volume) to mount that into the pod? – David Maze Feb 05 '21 at 11:47
  • Do you use this [grafana](https://github.com/grafana/helm-charts/tree/main/charts/grafana) Helm chart ? You can create `ConfigMap` from your json file and then mount it using `extraConfigmapMounts`. – matt_j Feb 05 '21 at 15:00
  • Thanks @DavidMaze, as i have already checked-in the code, I'll try it very next time. – medgai Feb 06 '21 at 18:29
  • @mac_55 any progress ? Did you solve your problem? – matt_j Feb 15 '21 at 09:20

0 Answers0