-
Notifications
You must be signed in to change notification settings - Fork 214
/
nginx-deployment.yaml
156 lines (156 loc) · 5.72 KB
/
nginx-deployment.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# Copyright (c) 2023 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0
#
# SPDX-License-Identifier: EPL-2.0
{{- if .Values.nginx.enabled -}}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "ditto.fullname" . }}-nginx
labels:
app.kubernetes.io/name: {{ include "ditto.name" . }}-nginx
{{ include "ditto.labels" . | indent 4 }}
spec:
replicas: {{ .Values.nginx.replicaCount }}
strategy:
{{- with .Values.nginx.updateStrategy }}
{{- toYaml . | nindent 4 }}
{{- end }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "ditto.name" . }}-nginx
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "ditto.name" . }}-nginx
app.kubernetes.io/instance: {{ .Release.Name }}
{{- with .Values.nginx.additionalLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
annotations:
checksum/nginx-conf: {{ include (print $.Template.BasePath "/nginx-configmap.yaml") . | sha256sum }}
checksum/nginx-config: {{ include (print $.Template.BasePath "/nginx-config.yaml") . | sha256sum }}
checksum/nginx-auth: {{ include (print $.Template.BasePath "/nginx-auth.yaml") . | sha256sum }}
{{- with .Values.nginx.additionalAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.global.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.nginx.initContainers.waitForGateway.enabled }}
initContainers:
- name: {{ .Values.nginx.initContainers.waitForGateway.name }}
image: {{ .Values.nginx.initContainers.waitForGateway.image }}
args:
- /bin/sh
- -c
- >
set -x;
while [[ "$(curl -sL -w "%{http_code}\n" http://{{ include "ditto.fullname" . }}-gateway:8080/health -o /dev/null)" != "200" ]]; do
echo '.'
sleep 1;
done
{{- end }}
topologySpreadConstraints:
- maxSkew: {{ .Values.nginx.topologySpreadConstraints.maxSkew }}
topologyKey: {{ .Values.nginx.topologySpreadConstraints.topologyKey }}
whenUnsatisfiable: {{ .Values.nginx.topologySpreadConstraints.whenUnsatisfiable }}
labelSelector:
matchLabels:
app.kubernetes.io/name: {{ include "ditto.name" . }}-nginx
containers:
- name: {{ .Chart.Name }}-nginx
image: "{{ .Values.nginx.image.repository }}:{{ .Values.nginx.image.tag }}"
imagePullPolicy: {{ .Values.nginx.image.pullPolicy }}
env:
{{- if .Values.nginx.extraEnv }}
{{- toYaml .Values.nginx.extraEnv | nindent 12 }}
{{- end }}
ports:
- name: http
containerPort: 8080
protocol: TCP
{{- if .Values.nginx.readinessProbe }}
readinessProbe:
{{- toYaml .Values.nginx.readinessProbe | nindent 12 }}
{{- end }}
{{- if .Values.nginx.livenessProbe }}
livenessProbe:
{{- toYaml .Values.nginx.livenessProbe | nindent 12 }}
{{- end }}
resources:
requests:
cpu: {{ mulf .Values.nginx.resources.cpu 1000 }}m
memory: {{ .Values.nginx.resources.memoryMi }}Mi
limits:
# cpu: ""
memory: {{ .Values.nginx.resources.memoryMi }}Mi
volumeMounts:
- name: nginx-conf
mountPath: /etc/nginx/nginx.conf
subPath: nginx.conf
- name: nginx-htpasswd
mountPath: /etc/nginx/nginx.htpasswd
subPath: nginx.htpasswd
- name: nginx-cors
mountPath: /etc/nginx/nginx-cors.conf
subPath: nginx-cors.conf
- name: nginx-index
mountPath: /etc/nginx/html/index.html
subPath: index.html
- name: nginx-ditto-down
mountPath: /etc/nginx/html/ditto-down.svg
subPath: ditto-down.svg
- name: nginx-ditto-up
mountPath: /etc/nginx/html/ditto-up.svg
subPath: ditto-up.svg
- name: nginx-cache
mountPath: /var/cache/nginx
- name: nginx-run
mountPath: /run/nginx
volumes:
- name: nginx-conf
configMap:
name: {{ .Release.Name }}-nginx-conf
- name: nginx-htpasswd
secret:
secretName: {{ .Release.Name }}-nginx-config-nginx-htpasswd
- name: nginx-cors
configMap:
name: {{ .Release.Name }}-nginx-config-nginx-cors-conf
- name: nginx-index
configMap:
name: {{ .Release.Name }}-nginx-config-index-html
- name: nginx-ditto-down
configMap:
name: {{ .Release.Name }}-nginx-config-ditto-down-svg
- name: nginx-ditto-up
configMap:
name: {{ .Release.Name }}-nginx-config-ditto-up-svg
- name: nginx-cache
emptyDir: {}
- name: nginx-run
emptyDir: {}
{{- with .Values.nginx.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.nginx.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.nginx.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}