Browse Source

Add common method to specify container/volume mounts

Waqar Ahmed 4 năm trước cách đây
mục cha
commit
9167d97343

+ 44 - 0
library/common/2101.0.0/templates/lib/storage/_appStorage.tpl

@@ -0,0 +1,44 @@
+{{/*
+Define appVolumeMounts for container
+*/}}
+{{- define "common.storage.configureAppVolumeMountsInContainer" -}}
+{{- if and .Values.appVolumesEnabled .Values.appVolumeMounts }}
+{{- range $name, $avm := .Values.appVolumeMounts -}}
+{{- if (default true $avm.enabled) }}
+{{- if $avm.containerNameOverride -}}
+{{- $name = $avm.containerNameOverride -}}
+{{- end -}}
+- name: {{ $name }}
+  mountPath: {{ $avm.mountPath }}
+  {{- if $avm.subPath }}
+  subPath: {{ $avm.subPath }}
+  {{- end }}
+{{- end }}
+{{- end }}
+{{- end }}
+{{- end -}}
+
+
+{{/*
+Define hostPath for appVolumes
+*/}}
+{{- define "common.storage.configureAppVolumes" -}}
+{{- if .Values.appVolumeMounts }}
+{{- range $name, $av := .Values.appVolumeMounts -}}
+{{- if (default true $av.enabled) }}
+- name: {{ $name }}
+  {{- if or $av.emptyDir $.Values.emptyDirVolumes }}
+  emptyDir: {}
+  {{- else }}
+  hostPath:
+    {{ if $av.hostPathEnabled }}
+    path: {{ required "hostPath not set" $av.hostPath }}
+    {{- else }}
+    {{- $volDict := dict "datasetName" $av.datasetName "ixVolumes" $.Values.ixVolumes -}}
+    path: {{ include "common.storage.retrieveHostPathFromiXVolume" $volDict }}
+    {{- end }}
+  {{- end }}
+{{- end }}
+{{- end }}
+{{- end }}
+{{- end -}}