45077121a0becc38584629142486e555032b375d
[demo.git] / tutorials / ApacheCNF / templates / cba / Templates / k8s-configs / deployment-config / templates / deployment.yaml
1 apiVersion: apps/v1
2 kind: Deployment
3 metadata:
4   name: {{ include "apache.fullname" . }}
5   labels: {{- include "apache.labels" . | nindent 4 }}
6 spec:
7   selector:
8     matchLabels: {{- include "apache.matchLabels" . | nindent 6 }}
9   replicas: {{ .Values.replicaCount }}
10   template:
11     metadata:
12       labels: {{- include "apache.labels" . | nindent 8 }}
13       {{- if or .Values.podAnnotations (and .Values.metrics.enabled .Values.metrics.podAnnotations) }}
14       annotations:
15         {{- if .Values.podAnnotations }}
16         {{- include "apache.tplValue" (dict "value" .Values.podAnnotations "context" $) | nindent 8 }}
17         {{- end }}
18         {{- if and .Values.metrics.enabled .Values.metrics.podAnnotations }}
19         {{- include "apache.tplValue" (dict "value" .Values.metrics.podAnnotations "context" $) | nindent 8 }}
20         {{- end }}
21       {{- end }}
22     spec:
23 {{- include "apache.imagePullSecrets" . | nindent 6 }}
24       hostAliases:
25         - ip: "127.0.0.1"
26           hostnames:
27             - "status.localhost"
28       {{- if .Values.affinity }}
29       affinity: {{- include "apache.tplValue" (dict "value" .Values.affinity "context" $) | nindent 8 }}
30       {{- else }}
31       affinity:
32         podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.podAffinityPreset "context" $) | nindent 10 }}
33         podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.podAntiAffinityPreset "context" $) | nindent 10 }}
34         nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.nodeAffinityPreset.type "key" .Values.nodeAffinityPreset.key "values" .Values.nodeAffinityPreset.values) | nindent 10 }}
35       {{- end }}
36       {{- if .Values.nodeSelector }}
37       nodeSelector: {{- include "apache.tplValue" (dict "value" .Values.nodeSelector "context" $) | nindent 8 }}
38       {{- end }}
39       {{- if .Values.tolerations }}
40       tolerations: {{- include "apache.tplValue" (dict "value" .Values.tolerations "context" $) | nindent 8 }}
41       {{- end }}
42       {{- if .Values.cloneHtdocsFromGit.enabled }}
43       initContainers:
44         - name: git-clone-repository
45           image: {{ include "git.image" . }}
46           imagePullPolicy: {{ .Values.git.pullPolicy | quote }}
47           command:
48             - /bin/bash
49             - -ec
50             - |
51               git clone {{ .Values.cloneHtdocsFromGit.repository }} --branch {{ .Values.cloneHtdocsFromGit.branch }} /app
52           resources: {{- toYaml .Values.cloneHtdocsFromGit.resources | nindent 12 }}
53           volumeMounts:
54             - name: htdocs
55               mountPath: /app
56       containers:
57         - name: git-repo-syncer
58           image: {{ include "git.image" . }}
59           imagePullPolicy: {{ .Values.git.pullPolicy | quote }}
60           command:
61             - /bin/bash
62             - -ec
63             - |
64               while true; do
65                   cd /app && git pull origin {{ .Values.cloneHtdocsFromGit.branch }}
66                   sleep {{ .Values.cloneHtdocsFromGit.interval }}
67               done
68           resources: {{- toYaml .Values.cloneHtdocsFromGit.resources | nindent 12 }}
69           volumeMounts:
70             - name: htdocs
71               mountPath: /app
72       {{- else }}
73       containers:
74       {{- end }}
75         - name: apache
76           image: {{ include "apache.image" . }}
77           imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
78           env:
79             - name: BITNAMI_DEBUG
80               value: {{ ternary "true" "false" .Values.image.debug | quote }}
81             {{- if .Values.extraEnvVars }}
82               {{- include "apache.tplValue" (dict "value" .Values.extraEnvVars "context" $) | nindent 12 }}
83             {{- end }}
84           ports:
85             - name: http
86               containerPort: 8080
87             - name: https
88               containerPort: 8443
89           {{- if .Values.livenessProbe.enabled }}
90           livenessProbe:
91             httpGet:
92               path: {{ .Values.livenessProbe.path }}
93               port: http
94             initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
95             periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
96             timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
97             successThreshold: {{ .Values.livenessProbe.successThreshold }}
98             failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
99           {{- end }}
100           {{- if .Values.readinessProbe.enabled }}
101           readinessProbe:
102             httpGet:
103               path: {{ .Values.readinessProbe.path }}
104               port: http
105             initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
106             periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
107             timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
108             successThreshold: {{ .Values.readinessProbe.successThreshold }}
109             failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
110           {{- end }}
111           {{- if .Values.resources }}
112           resources: {{- toYaml .Values.resources | nindent 12 }}
113           {{- end }}
114           volumeMounts:
115             {{- if (include "apache.useHtdocs" .) }}
116             - name: htdocs
117               mountPath: /app
118             {{- end }}
119             {{- if or (.Files.Glob "files/vhosts/*.conf") (.Values.vhostsConfigMap) }}
120             - name: vhosts
121               mountPath: /vhosts
122             {{- end }}
123             {{- if or (.Files.Glob "files/httpd.conf") (.Values.httpdConfConfigMap) }}
124             - name: httpd-conf
125               mountPath: /opt/bitnami/apache/conf/httpd.conf
126               subPath: httpd.conf
127             {{- end }}
128             {{- if .Values.extraVolumeMounts }}
129             {{- include "common.tplvalues.render" ( dict "value" .Values.extraVolumeMounts "context" $) | nindent 12 }}
130             {{- end }}
131         {{- if .Values.metrics.enabled }}
132         - name: metrics
133           image: {{ template "apache.metrics.image" . }}
134           imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }}
135           command: ['/bin/apache_exporter', '--scrape_uri', 'http://status.localhost:8080/server-status/?auto']
136           ports:
137             - name: metrics
138               containerPort: 9117
139           livenessProbe:
140             httpGet:
141               path: /metrics
142               port: metrics
143             initialDelaySeconds: 15
144             timeoutSeconds: 5
145           readinessProbe:
146             httpGet:
147               path: /metrics
148               port: metrics
149             initialDelaySeconds: 5
150             timeoutSeconds: 1
151           {{- if .Values.metrics.resources }}
152           resources: {{- toYaml .Values.metrics.resources | nindent 12 }}
153           {{- end }}
154         {{- end }}
155       volumes:
156         {{- if (include "apache.useHtdocs" .) }}
157         - name: htdocs
158           {{- include "apache.htdocsVolume" . | nindent 10 }}
159         {{- end }}
160         {{- if or (.Files.Glob "files/vhosts/*.conf") (.Values.vhostsConfigMap) }}
161         - name: vhosts
162           configMap:
163             name: {{ include "apache.vhostsConfigMap" . }}
164         {{- end }}
165         {{- if or (.Files.Glob "files/httpd.conf") (.Values.httpdConfConfigMap) }}
166         - name: httpd-conf
167           configMap:
168             name: {{ include "apache.httpdConfConfigMap" . }}
169         {{- end }}
170         {{- if .Values.extraVolumes }}
171         {{- include "common.tplvalues.render" ( dict "value" .Values.extraVolumes "context" $) | nindent 8 }}
172         {{- end }}