diff --git a/library/common/1.0.0/templates/lib/container/_ports.tpl b/library/common/1.0.0/templates/lib/container/_ports.tpl index 42cb92a6..f521d6c1 100644 --- a/library/common/1.0.0/templates/lib/container/_ports.tpl +++ b/library/common/1.0.0/templates/lib/container/_ports.tpl @@ -7,6 +7,7 @@ can be dynamically configured via an env var. {{- define "ix.v1.common.container.ports" -}} {{- $defaultPortProtocol := .Values.global.defaults.portProtocol -}} {{- $ports := list -}} + {{- range $svcName, $svc := .Values.service -}} {{- if $svc.enabled -}} {{- if not $svc.ports -}} @@ -50,6 +51,7 @@ can be dynamically configured via an env var. {{- end -}} {{- end -}} +{{/* This is called by init/install/upgrade/additional containers only */}} {{- define "ix.v1.common.container.extraContainerPorts" -}} {{- $containerName := .containerName -}} {{- $ports := .ports -}} diff --git a/library/common/1.0.0/templates/lib/container/_volumeMounts.tpl b/library/common/1.0.0/templates/lib/container/_volumeMounts.tpl index 4d816afa..c5cee76c 100644 --- a/library/common/1.0.0/templates/lib/container/_volumeMounts.tpl +++ b/library/common/1.0.0/templates/lib/container/_volumeMounts.tpl @@ -1,18 +1,26 @@ {{/* Volume Mounts included by the container. */}} {{- define "ix.v1.common.container.volumeMounts" -}} - {{- range $name, $item := .Values.persistence -}} - {{- if $item.enabled -}} - {{- if not $item.noMount -}} - {{- include "ix.v1.common.container.volumeMount" (dict "root" $ "item" $item "name" $name) | nindent 0 -}} + {{- $isMainContainer := .isMainContainer -}} + {{- $root := .root -}} + {{- $extraContainerVolMounts := .extraContainerVolMouts -}} + + {{- if $isMainContainer -}} + {{- range $name, $item := $root.Values.persistence -}} + {{- if $item.enabled -}} + {{- if not $item.noMount -}} + {{- include "ix.v1.common.container.volumeMount" (dict "root" $root "item" $item "name" $name) | nindent 0 -}} + {{- end -}} {{- end -}} {{- end -}} - {{- end -}} -{{/* TODO: write tests when statefulset is ready */}} - {{- if eq .Values.controller.type "statefulset" -}} - {{- range $index, $vct := .Values.volumeClaimTemplates -}} - {{- include "ix.v1.common.container.volumeMount" (dict "root" $ "item" $vct "name" (toString $index)) | nindent 0 -}} + {{/* TODO: write tests when statefulset is ready */}} + {{- if eq $root.Values.controller.type "statefulset" -}} + {{- range $index, $vct := $root.Values.volumeClaimTemplates -}} + {{- include "ix.v1.common.container.volumeMount" (dict "root" $root "item" $vct "name" (toString $index)) | nindent 0 -}} + {{- end -}} {{- end -}} + {{- else if not $isMainContainer -}} + {{/* range themounts of extra contaienrs */}} {{- end -}} {{- end -}} diff --git a/library/common/1.0.0/templates/lib/pod/_extraContainers.tpl b/library/common/1.0.0/templates/lib/pod/_extraContainers.tpl index 9e82198a..c833967a 100644 --- a/library/common/1.0.0/templates/lib/pod/_extraContainers.tpl +++ b/library/common/1.0.0/templates/lib/pod/_extraContainers.tpl @@ -90,6 +90,12 @@ ports: {{- . | nindent 4 }} {{- end -}} + {{- with (include "ix.v1.common.container.volumeMounts" (dict "root" $root + "extraContaienrVolMounts" $container.volumeMounts + "isMainContainer" false) | trim) }} + volumeMounts: + {{- . | nindent 4 }} + {{- end -}} {{- with (include "ix.v1.common.container.resources" (dict "resources" $container.resources "gpu" $container.scaleGPU "isMainContainer" false diff --git a/library/common/1.0.0/templates/lib/pod/_mainContainer.tpl b/library/common/1.0.0/templates/lib/pod/_mainContainer.tpl index 3b10c59c..4bc8b242 100644 --- a/library/common/1.0.0/templates/lib/pod/_mainContainer.tpl +++ b/library/common/1.0.0/templates/lib/pod/_mainContainer.tpl @@ -54,7 +54,8 @@ So it can work on multiple places, like additional containers and not only the m ports: {{- . | nindent 4 }} {{- end -}} - {{- with (include "ix.v1.common.container.volumeMounts" . | trim) }} + {{- with (include "ix.v1.common.container.volumeMounts" (dict "root" . + "isMainContainer" true) | trim) }} volumeMounts: {{- . | nindent 4 }} {{- end -}}