Improve oran_oom helm charts
[it/dep.git] / smo-install / oran_oom / nonrtric-common / templates / _pods.tpl
1 {{/*
2 ################################################################################
3 #   Copyright (c) 2024 NYCU WINLab.                                            #
4 #                                                                              #
5 #   Licensed under the Apache License, Version 2.0 (the "License");            #
6 #   you may not use this file except in compliance with the License.           #
7 #   You may obtain a copy of the License at                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
11 #   Unless required by applicable law or agreed to in writing, software        #
12 #   distributed under the License is distributed on an "AS IS" BASIS,          #
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
14 #   See the License for the specific language governing permissions and        #
15 #   limitations under the License.                                             #
16 ################################################################################
17 */}}
18
19 {{- define "common.containerPorts" -}}
20 {{-   $ports := default (list) .Values.service.ports }}
21 {{-   range $index, $port := $ports }}
22 {{-   if $port.targetPort -}}
23 - containerPort: {{ $port.targetPort }}
24   name: {{ $port.name }}
25 {{-       if $port.l4_protocol }}
26   protocol: {{ $port.l4_protocol }}
27 {{-       else }}
28   protocol: TCP
29 {{-       end }}
30 {{-     end }}
31 {{- if $port.targetPort_tls }}
32 - containerPort: {{ $port.targetPort_tls }}
33   name: {{ $port.name_tls }}
34 {{-       if $port.l4_protocol }}
35   protocol: {{ $port.l4_protocol }}
36 {{-       else }}
37   protocol: TCP
38 {{-       end }}
39 {{-     end }}
40 {{-   end }}
41 {{- end -}}
42
43 {{- define "common.probePort" -}}
44 {{ default (first .Values.service.ports).targetPort .Values.service.probePort }}
45 {{- end -}}
46
47 {{- define "common.tcpsocketReadinessProbe" -}}
48 {{- $dot := default . .dot -}}
49 {{- $port := default (include "common.probePort" $dot) .port -}}
50 readinessProbe:
51   tcpSocket:
52     port: {{ $port }}
53   initialDelaySeconds: {{ $dot.Values.readiness.initialDelaySeconds }}
54   periodSeconds: {{ $dot.Values.readiness.periodSeconds }}
55 {{- end -}}
56
57 {{- define "common.tcpsocketLivenessProbe" -}}
58 {{- $dot := default . .dot -}}
59 {{- $port := default (include "common.probePort" $dot) .port -}}
60 livenessProbe:
61   tcpSocket:
62     port: {{ $port }}
63   initialDelaySeconds: {{ $dot.Values.liveness.initialDelaySeconds }}
64   periodSeconds: {{ $dot.Values.liveness.periodSeconds }}
65 {{- end -}}
66
67 {{- define "common.tcpsocketProbes" -}}
68 {{- include "common.tcpsocketReadinessProbe" . }}
69 {{ include "common.tcpsocketLivenessProbe" . }}
70 {{- end -}}
71
72 {{- define "common.httpLiveProbe" -}}
73 {{- $dot := default . .dot }}
74 {{- $path := default "/status" .path -}}
75 livenessProbe:
76   httpGet:
77     path: {{ $path }}
78     port: {{ include "common.probePort" . }}
79   initialDelaySeconds: {{ $dot.Values.liveness.initialDelaySeconds }}
80   periodSeconds: {{ $dot.Values.liveness.periodSeconds }}
81 {{- end -}}
82
83 {{- define "common.applicationConfigMountName" -}}
84 {{ include "common.name" . }}-application-config
85 {{- end -}}
86
87 {{- define "common.applicationConfigVolume" -}}
88 - name: {{ include "common.name" . }}-application-config
89   configMap:
90     name: {{ include "common.name" . }}-application-configmap
91 {{- end -}}
92