Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions charts/network/charts/network-bootstrapper/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,15 @@ Accepts either a YAML string or a list of init container maps and indents output
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Resolve pod and container security contexts by layering chart values over global defaults.
*/}}
{{- define "network-bootstrapper.securityContexts" -}}
{{- $root := . -}}
{{- $globalValues := ($root.Values.global | default (dict)) -}}
{{- $globalSecurityContexts := dig "securityContexts" $globalValues (dict) -}}
{{- $pod := mergeOverwrite (deepCopy (dig "pod" $globalSecurityContexts (dict))) (default (dict) $root.Values.podSecurityContext) -}}
{{- $container := mergeOverwrite (deepCopy (dig "container" $globalSecurityContexts (dict))) (default (dict) $root.Values.securityContext) -}}
{{- dict "pod" $pod "container" $container | toYaml -}}
{{- end -}}
7 changes: 3 additions & 4 deletions charts/network/charts/network-bootstrapper/templates/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "network-bootstrapper.serviceAccountName" . }}
{{- $globalValues := (.Values.global | default (dict)) }}
{{- $globalSecurityContexts := dig "securityContexts" $globalValues (dict) }}
{{- $podSecurityContext := merge (deepCopy (default (dict) .Values.podSecurityContext)) (dig "pod" $globalSecurityContexts (dict)) }}
{{- $containerSecurityContext := merge (deepCopy (default (dict) .Values.securityContext)) (dig "container" $globalSecurityContexts (dict)) }}
{{- $securityContexts := include "network-bootstrapper.securityContexts" . | fromYaml }}
{{- $podSecurityContext := index $securityContexts "pod" }}
{{- $containerSecurityContext := index $securityContexts "container" }}
{{- if $podSecurityContext }}
securityContext:
{{- toYaml $podSecurityContext | nindent 8 }}
Expand Down
12 changes: 12 additions & 0 deletions charts/network/charts/network-nodes/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,15 @@ Accepts either a YAML string or a list of init container maps and indents output
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Resolve pod and container security contexts using global defaults plus chart overrides.
*/}}
{{- define "nodes.securityContexts" -}}
{{- $root := . -}}
{{- $globalValues := ($root.Values.global | default (dict)) -}}
{{- $globalSecurityContexts := dig "securityContexts" $globalValues (dict) -}}
{{- $pod := mergeOverwrite (deepCopy (dig "pod" $globalSecurityContexts (dict))) (default (dict) $root.Values.podSecurityContext) -}}
{{- $container := mergeOverwrite (deepCopy (dig "container" $globalSecurityContexts (dict))) (default (dict) $root.Values.securityContext) -}}
{{- dict "pod" $pod "container" $container | toYaml -}}
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ spec:
{{- $initContainers := .Values.initContainers | default (dict) }}
{{- $sharedInitContainers := get $initContainers "shared" }}
{{- $rpcInitContainers := get $initContainers "rpc" }}
{{- $globalValues := (.Values.global | default (dict)) }}
{{- $globalSecurityContexts := dig "securityContexts" $globalValues (dict) }}
{{- $podSecurityContext := merge (deepCopy (default (dict) .Values.podSecurityContext)) (dig "pod" $globalSecurityContexts (dict)) }}
{{- $containerSecurityContext := merge (deepCopy (default (dict) .Values.securityContext)) (dig "container" $globalSecurityContexts (dict)) }}
{{- $securityContexts := include "nodes.securityContexts" . | fromYaml }}
{{- $podSecurityContext := index $securityContexts "pod" }}
{{- $containerSecurityContext := index $securityContexts "container" }}
podManagementPolicy: Parallel
replicas: {{ .Values.rpcReplicaCount }}
serviceName: {{ include "nodes.fullname" . }}-rpc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ spec:
{{- $initContainers := .Values.initContainers | default (dict) }}
{{- $sharedInitContainers := get $initContainers "shared" }}
{{- $validatorInitContainers := get $initContainers "validator" }}
{{- $globalValues := (.Values.global | default (dict)) }}
{{- $globalSecurityContexts := dig "securityContexts" $globalValues (dict) }}
{{- $podSecurityContext := merge (deepCopy (default (dict) .Values.podSecurityContext)) (dig "pod" $globalSecurityContexts (dict)) }}
{{- $containerSecurityContext := merge (deepCopy (default (dict) .Values.securityContext)) (dig "container" $globalSecurityContexts (dict)) }}
{{- $securityContexts := include "nodes.securityContexts" . | fromYaml }}
{{- $podSecurityContext := index $securityContexts "pod" }}
{{- $containerSecurityContext := index $securityContexts "container" }}
podManagementPolicy: Parallel
replicas: {{ $validatorReplicaBudget }}
serviceName: {{ include "nodes.fullname" . }}
Expand Down