123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- {{/*
- Check if workload type is a deployment
- */}}
- {{- define "workloadIsDeployment" }}
- {{- if eq .Values.workloadType "Deployment" }}
- {{- true -}}
- {{- else }}
- {{- false -}}
- {{- end }}
- {{- end }}
- {{/*
- Check if workload type is a cronjob
- */}}
- {{- define "workloadIsCronJob" }}
- {{- if eq .Values.workloadType "CronJob" }}
- {{- true -}}
- {{- else }}
- {{- false -}}
- {{- end }}
- {{- end }}
- {{/*
- Get API Version based on workload type
- */}}
- {{- define "apiVersion" -}}
- {{- if eq (include "workloadIsDeployment" .) "true" }}
- {{- printf "apps/v1" }}
- {{- else if eq (include "workloadIsCronJob" .) "true" }}
- {{- printf "batch/v1beta1" }}
- {{- else }}
- {{- printf "batch/v1" }}
- {{- end }}
- {{- end }}
- {{/*
- Get Restart policy based on workload type
- */}}
- {{- define "restartPolicy" -}}
- {{- if eq (include "workloadIsDeployment" .) "true" }}
- {{- print "Always" }}
- {{- else }}
- {{- printf "%s" .Values.jobRestartPolicy }}
- {{- end }}
- {{- end }}
- {{/*
- Pod specification
- */}}
- {{- define "podSepc" }}
- restartPolicy: {{ template "restartPolicy" . }}
- hostNetwork: {{ template "hostNetworkingConfiguration" . }}
- containers:
- - name: {{ .Chart.Name }}
- {{ include "common.resources.limitation" . | nindent 2 }}
- {{- include "volumeMountsConfiguration" . | indent 2}}
- tty: {{ .Values.tty }}
- stdin: {{ .Values.stdin }}
- securityContext:
- privileged: {{ .Values.securityContext.privileged }}
- {{ if .Values.securityContext.enableRunAsUser }}
- runAsUser: {{ .Values.securityContext.runAsUser }}
- runAsGroup: {{ .Values.securityContext.runAsGroup }}
- {{ end }}
- {{ if .Values.securityContext.capabilities }}
- capabilities:
- add: {{ toYaml .Values.securityContext.capabilities | nindent 8 }}
- {{ end }}
- {{ if .Values.ci }}
- livenessProbe:
- httpGet:
- path: /
- port: 80
- initialDelaySeconds: 10
- periodSeconds: 10
- timeoutSeconds: 5
- failureThreshold: 5
- successThreshold: 1
- readinessProbe:
- httpGet:
- path: /
- port: 80
- initialDelaySeconds: 10
- periodSeconds: 10
- timeoutSeconds: 5
- failureThreshold: 5
- successThreshold: 2
- startupProbe:
- httpGet:
- path: /
- port: 80
- initialDelaySeconds: 10
- periodSeconds: 5
- timeoutSeconds: 2
- failureThreshold: 60
- successThreshold: 1
- {{ end }}
- image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default "latest" }}"
- imagePullPolicy: {{ .Values.image.pullPolicy }}
- {{- include "containerCommand" . | indent 2 }}
- {{- include "containerArgs" . | indent 2 }}
- {{- include "containerEnvVariables" . | indent 2 }}
- {{- include "containerLivenssProbe" . | indent 2 }}
- {{- include "containerPorts" . | indent 2 }}
- {{- include "containerResourceConfiguration" . | indent 2 }}
- {{- include "volumeConfiguration" . }}
- {{- include "dnsConfiguration" . }}
- {{- end }}
- {{/*
- Annotations for workload
- */}}
- {{- define "workloadAnnotations" }}
- rollme: {{ randAlphaNum 5 | quote }}
- {{- if .Values.ixExternalInterfacesConfigurationNames }}
- k8s.v1.cni.cncf.io/networks: {{ join ", " .Values.ixExternalInterfacesConfigurationNames }}
- {{- end }}
- {{- end }}
- {{/*
- Metadata for workload
- */}}
- {{- define "commonMetadataWorkload" }}
- labels:
- {{- include "ix-chart.selectorLabels" . | nindent 2 }}
- annotations:
- {{- include "workloadAnnotations" . | nindent 2 }}
- {{- end }}
- {{/*
- Deployment Spec
- */}}
- {{- define "deploymentSpec" }}
- strategy:
- {{- if and (eq .Values.updateStrategy "RollingUpdate") .Values.hostPortsList }}
- {{- fail "RollingUpdate is not allowed when host ports are specified" }}
- {{- else if and (eq .Values.updateStrategy "RollingUpdate") .Values.hostNetwork }}
- {{- fail "RollingUpdate is not allowed when host network is enabled" }}
- {{- end }}
- type: {{ .Values.updateStrategy }}
- selector:
- matchLabels:
- {{- include "ix-chart.selectorLabels" . | nindent 4 }}
- template:
- metadata:
- {{ include "commonMetadataWorkload" . | nindent 4 }}
- spec:
- {{- include "podSepc" . | indent 4 }}
- {{- end }}
- {{/*
- Job Spec Common
- */}}
- {{- define "jobSpecCommon" }}
- metadata:
- {{ include "commonMetadataWorkload" . | nindent 4 }}
- spec:
- {{- include "podSepc" . | indent 2 }}
- {{- end }}
- {{/*
- Job Spec
- */}}
- {{- define "jobSpec" }}
- template:
- {{ include "jobSpecCommon" . | nindent 2 }}
- {{- end }}
- {{/*
- CronJob Spec
- */}}
- {{- define "cronJobSpec" }}
- schedule: {{ include "cronExpression" .Values.cronSchedule | quote }}
- jobTemplate:
- spec:
- {{ include "jobSpec" . | nindent 4 }}
- {{- end }}
|