2 ################################################################################
3 # Copyright (c) 2024 NYCU WINLab. #
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 #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
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 ################################################################################
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 }}
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 }}
43 {{- define "common.probePort" -}}
44 {{ default (first .Values.service.ports).targetPort .Values.service.probePort }}
47 {{- define "common.tcpsocketReadinessProbe" -}}
48 {{- $dot := default . .dot -}}
49 {{- $port := default (include "common.probePort" $dot) .port -}}
53 initialDelaySeconds: {{ $dot.Values.readiness.initialDelaySeconds }}
54 periodSeconds: {{ $dot.Values.readiness.periodSeconds }}
57 {{- define "common.tcpsocketLivenessProbe" -}}
58 {{- $dot := default . .dot -}}
59 {{- $port := default (include "common.probePort" $dot) .port -}}
63 initialDelaySeconds: {{ $dot.Values.liveness.initialDelaySeconds }}
64 periodSeconds: {{ $dot.Values.liveness.periodSeconds }}
67 {{- define "common.tcpsocketProbes" -}}
68 {{- include "common.tcpsocketReadinessProbe" . }}
69 {{ include "common.tcpsocketLivenessProbe" . }}
72 {{- define "common.httpLiveProbe" -}}
73 {{- $dot := default . .dot }}
74 {{- $path := default "/status" .path -}}
78 port: {{ include "common.probePort" . }}
79 initialDelaySeconds: {{ $dot.Values.liveness.initialDelaySeconds }}
80 periodSeconds: {{ $dot.Values.liveness.periodSeconds }}
83 {{- define "common.applicationConfigMountName" -}}
84 {{ include "common.name" . }}-application-config
87 {{- define "common.applicationConfigVolume" -}}
88 - name: {{ include "common.name" . }}-application-config
90 name: {{ include "common.name" . }}-application-configmap