Merge "[AAI] Add model-loader tracing config"
[oom.git] / kubernetes / common / common / templates / _pod.tpl
1 {{/*
2 # Copyright © 2019 Orange
3 #
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
7 #
8 #       http://www.apache.org/licenses/LICENSE-2.0
9 #
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.
15 */}}
16
17 {{/*
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
23 */}}
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 }}
30 {{-   end }}
31 {{-   range $index, $port := .Values.service.headlessPorts }}
32 {{-     if not (has $port.port $portsNumber) }}
33 {{-       $ports = append $ports $port }}
34 {{-     end }}
35 {{-   end }}
36 {{- $global := . }}
37 {{-   range $index, $port := $ports }}
38 {{-     if (include "common.needTLS" $global) }}
39 - containerPort: {{ default $port.port $port.internal_port }}
40 {{-     else }}
41 - containerPort: {{ default (default $port.port $port.internal_port) (default $port.plain_port $port.internal_plain_port) }}
42 {{-     end }}
43   name: {{ $port.name }}
44 {{-     if (and $port.plain_port (and (include "common.needTLS" $global) $both_tls_and_plain))  }}
45 - containerPort: {{ default $port.plain_port $port.internal_plain_port }}
46   name: {{ $port.name }}-plain
47 {{-     end }}
48 {{-     if $port.l4_protocol }}
49   protocol: {{ $port.l4_protocol }}
50 {{-     end }}
51 {{-   end }}
52 {{- end -}}
53
54 {{/*
55    Generate securityContext for pod
56 */}}
57 {{- define "common.podSecurityContext" -}}
58 securityContext:
59   runAsUser: {{ .Values.securityContext.user_id }}
60   runAsGroup: {{ .Values.securityContext.group_id }}
61   fsGroup: {{ .Values.securityContext.group_id }}
62 {{- end }}
63
64 {{/*
65    Generate securityContext for container
66 */}}
67 {{- define "common.containerSecurityContext" -}}
68 securityContext:
69   readOnlyRootFilesystem: true
70   privileged: false
71   allowPrivilegeEscalation: false
72 {{- end }}