_pvc.tpl 1.1 KB

12345678910111213141516171819202122232425262728
  1. {{/* Returns PVC Volume */}}
  2. {{/* Call this template:
  3. {{ include "ix.v1.common.lib.pod.volume.pvc" (dict "rootCtx" $ "objectData" $objectData) }}
  4. rootCtx: The root context of the chart.
  5. objectData: The object data to be used to render the volume.
  6. */}}
  7. {{- define "ix.v1.common.lib.pod.volume.pvc" -}}
  8. {{- $rootCtx := .rootCtx -}}
  9. {{- $objectData := .objectData -}}
  10. {{- $pvcName := (printf "%s-%s" (include "ix.v1.common.lib.chart.names.fullname" $rootCtx) $objectData.shortName) -}}
  11. {{- with $objectData.existingClaim -}}
  12. {{- $pvcName = tpl . $rootCtx -}}
  13. {{- end -}}
  14. {{- if mustHas $objectData.type (list "nfs-pv-pvc" "smb-pv-pvc") -}}
  15. {{- $hashValues := (printf "%s-%s" $objectData.server $objectData.share) -}}
  16. {{- if $objectData.domain -}}
  17. {{- $hashValues = (printf "%s-%s" $hashValues $objectData.domain) -}}
  18. {{- end -}}
  19. {{/* Generate the unique claim name */}}
  20. {{- $hash := adler32sum $hashValues -}}
  21. {{- $pvcName = (printf "%s-%v" $pvcName $hash) -}}
  22. {{- end }}
  23. - name: {{ $objectData.shortName }}
  24. persistentVolumeClaim:
  25. claimName: {{ $pvcName }}
  26. {{- end -}}