_pvc.tpl 1.2 KB

1234567891011121314151617181920212223242526272829
  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. {{- $size := $objectData.size | default $rootCtx.Values.fallbackDefaults.pvcSize -}}
  16. {{- $hashValues := (printf "%s-%s-%s" $size $objectData.server $objectData.share) -}}
  17. {{- if $objectData.domain -}}
  18. {{- $hashValues = (printf "%s-%s" $hashValues $objectData.domain) -}}
  19. {{- end -}}
  20. {{/* Generate the unique claim name */}}
  21. {{- $hash := adler32sum $hashValues -}}
  22. {{- $pvcName = (printf "%s-%v" $pvcName $hash) -}}
  23. {{- end }}
  24. - name: {{ $objectData.shortName }}
  25. persistentVolumeClaim:
  26. claimName: {{ $pvcName }}
  27. {{- end -}}