2 # Copyright © 2019 Orange
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
18 Generate the container port list.
19 Will use first ".Values.service.ports" list.
20 Will append ports from ".Values.service.headlessPorts" only if port number is
21 not already in port list.
22 Will add tls port AND plain port if both_tls_and_plain is set to true
24 {{- define "common.containerPorts" -}}
25 {{- $ports := default (list) .Values.service.ports }}
26 {{- $portsNumber := list }}
27 {{- $both_tls_and_plain:= default false .Values.service.both_tls_and_plain }}
28 {{- range $index, $port := $ports }}
29 {{- $portsNumber = append $portsNumber $port.port }}
31 {{- range $index, $port := .Values.service.headlessPorts }}
32 {{- if not (has $port.port $portsNumber) }}
33 {{- $ports = append $ports $port }}
37 {{- range $index, $port := $ports }}
38 {{- if (include "common.needTLS" $global) }}
39 - containerPort: {{ $port.port }}
41 - containerPort: {{ default $port.port $port.plain_port }}
43 name: {{ $port.name }}
44 {{- if (and $port.plain_port (and (include "common.needTLS" $global) $both_tls_and_plain)) }}
45 - containerPort: {{ $port.plain_port }}
46 name: {{ $port.name }}-plain
52 Generate securityContext for pod
54 {{- define "common.podSecurityContext" -}}
56 runAsUser: {{ .Values.securityContext.user_id }}
57 runAsGroup: {{ .Values.securityContext.group_id }}
58 fsGroup: {{ .Values.securityContext.group_id }}
62 Generate securityContext for container
64 {{- define "common.containerSecurityContext" -}}
66 readOnlyRootFilesystem: true
68 allowPrivilegeEscalation: false