forked from ongres/stackgres
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoperator-deployment.yaml
More file actions
276 lines (274 loc) · 10.5 KB
/
operator-deployment.yaml
File metadata and controls
276 lines (274 loc) · 10.5 KB
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
{{- if .Values.deploy.operator }}
apiVersion: "apps/v1"
kind: "Deployment"
metadata:
{{- with .Values.operator.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
app: {{ .Release.Name }}
version: "{{ .Chart.Version }}"
group: stackgres.io
name: {{ .Release.Name }}
namespace: {{ .Release.Namespace }}
spec:
replicas: 1
selector:
matchLabels:
app: {{ .Release.Name }}
group: stackgres.io
template:
metadata:
labels:
app: {{ .Release.Name }}
group: stackgres.io
spec:
{{- with .Values.operator.affinity}}
affinity:
{{- toYaml . | nindent 8 }}
{{- end}}
serviceAccountName: {{ .Release.Name }}
{{- with .Values.operator.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end}}
{{- with .Values.operator.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- if or (not (.Capabilities.APIVersions.Has "project.openshift.io/v1")) .Values.developer.disableArbitraryUser }}
runAsNonRoot: true
{{- if .Values.operator.image.tag | hasSuffix "-jvm" }}
runAsUser: 185
runAsGroup: 185
fsGroup: 185
{{- else }}
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000
{{- end }}
{{- end }}
{{- with .Values.operator.hostNetwork }}
hostNetwork: {{ . }}
{{- end }}
containers:
{{- if not (and .Values.developer.externalOperatorIp .Values.developer.externalOperatorPort) }}
- name: {{ .Release.Name }}
image: "{{ include "operator-image" . }}"
imagePullPolicy: {{ .Values.operator.image.pullPolicy }}
env:
- name: OPERATOR_NAME
value: "{{ .Release.Name }}"
- name: OPERATOR_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: OPERATOR_IMAGE_VERSION
value: "{{ .Values.operator.image.tag }}"
- name: OPERATOR_JVM_IMAGE_VERSION
value: "{{ trimSuffix "-jvm" .Values.operator.image.tag }}-jvm"
- name: OPERATOR_NATIVE_IMAGE_VERSION
value: "{{ trimSuffix "-jvm" .Values.operator.image.tag }}"
- name: DISABLE_RECONCILIATION
value: "false"
# Remove after version 1.13 get out of support
{{- if not .Values.skipInstallConfig }}
- name: INSTALL_CONFIG
value: "true"
- name: SGCONFIG
value: |
apiVersion: stackgres.io/v1
kind: SGConfig
metadata:
name: {{ .Release.Name }}
namespace: {{ .Values.sgConfigNamespace | default .Release.Namespace }}
{{- $spec := dict }}
{{- range .Values.specFields }}
{{- $spec := set $spec . (index $.Values .) }}
{{- end }}
spec: {{ toJson $spec }}
{{- end }}
- name: INSTALL_CRDS
value: "{{ if or .Values.disableClusterRole .Values.disableCrdsAndWebhooksUpdate }}false{{ else }}true{{ end }}"
- name: WAIT_CRDS_UPGRADE
value: "{{ if or .Values.disableClusterRole .Values.disableCrdsAndWebhooksUpdate }}true{{ else }}false{{ end }}"
- name: INSTALL_WEBHOOKS
value: "{{ if or .Values.disableClusterRole .Values.disableCrdsAndWebhooksUpdate }}false{{ else }}true{{ end }}"
- name: INSTALL_CONVERSION_WEBHOOKS
value: "{{ if or .Values.allowedNamespaces .Values.allowedNamespaceLabelSelector .Values.disableClusterRole }}false{{ else }}true{{ end }}"
- name: ALLOWED_NAMESPACES
{{- $allowedNamespaces := regexSplit " " (include "allowedNamespaces" .) -1 }}
value: "{{ if not ($allowedNamespaces | has "_all_namespaces_placeholder") }}{{ range $index, $namespace := $allowedNamespaces }}{{ if $index }},{{ end }}{{ $namespace }}{{ end }}{{ end }}"
- name: CLUSTER_ROLE_DISABLED
value: "{{ if .Values.disableClusterRole }}true{{ else }}false{{ end }}"
{{- if not .Values.cert.certManager.autoConfigure }}
- name: INSTALL_CERTS
value: "true"
{{- end }}
- name: SGCONFIG_NAMESPACE
value: {{ .Values.sgConfigNamespace | default .Release.Namespace }}
- name: PROMETHEUS_AUTOBIND
value: "{{ or .Values.collector.prometheusOperator.allowDiscovery (gt (len .Values.collector.prometheusOperator.monitors) 0) }}"
{{- if and (.Capabilities.APIVersions.Has "project.openshift.io/v1") (not .Values.developer.disableArbitraryUser) }}
- name: USE_ARBITRARY_USER
value: "true"
{{- end }}
{{- if .Values.developer.logLevel }}
- name: OPERATOR_LOG_LEVEL
value: "{{ .Values.developer.logLevel }}"
{{- end }}
{{- if .Values.developer.showStackTraces }}
- name: OPERATOR_SHOW_STACK_TRACES
value: "{{ .Values.developer.showStackTraces }}"
{{- end }}
{{- if .Values.developer.extraOpts }}
- name: APP_OPTS
value: '{{ range .Values.developer.extraOpts }}{{ . }} {{ end }}'
{{- end }}
{{- if .Values.developer.extraOpts }}
- name: JAVA_OPTS
value: '{{ range .Values.developer.extraOpts }}{{ . }} {{ end }}'
{{- end }}
{{- if .Values.developer.enableJvmDebug }}
- name: DEBUG_OPERATOR
value: "{{ .Values.developer.enableJvmDebug }}"
{{- end }}
{{- if .Values.developer.enableJvmDebugSuspend }}
- name: DEBUG_OPERATOR_SUSPEND
value: "{{ .Values.developer.enableJvmDebugSuspend }}"
{{- end }}
{{- with .Values.operator.listenHttpPort }}
- name: OPERATOR_HTTP_PORT
value: {{ . }}
{{- end }}
{{- with .Values.operator.listenHttpsPort }}
- name: OPERATOR_HTTPS_PORT
value: {{ . }}
{{- end }}
- name: OPERATOR_SERVICE_ACCOUNT
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.serviceAccountName
- name: OPERATOR_POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
- name: OPERATOR_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
{{- if and .Values.grafana.url .Values.grafana.token .Values.grafana.webHost }}
- name: GRAFANA_EMBEDDED
value: "true"
{{ end }}
- name: SG_CONTAINER_REGISTRY
value: "{{ .Values.containerRegistry }}"
- name: SG_IMAGE_PULL_POLICY
value: "{{ .Values.imagePullPolicy }}"
{{- if .Values.extensions.cache.enabled }}
- name: EXTENSIONS_REPOSITORY_URLS
value: "{{ range $index, $element := .Values.extensions.repositoryUrls }}{{ if $index }},{{ end }}{{ $element := regexReplaceAll "([?&])proxyUrl=[^&]+[&]" $element "${1}" }}{{ $element := regexReplaceAll "([?&])proxyUrl=[^&]+$" $element "" }}{{ $element }}{{ if $element | contains "?" }}&{{ else }}?{{ end }}proxyUrl=http%3A%2F%2F{{ $.Release.Name }}-extensions-cache.{{ $.Release.Namespace }}%3FsetHttpScheme%3Dtrue&retry=3%3A5{{ end }}"
{{- else }}
- name: EXTENSIONS_REPOSITORY_URLS
value: "{{ range $index, $element := .Values.extensions.repositoryUrls }}{{ if $index }},{{ end }}{{ $element }}{{ end }}"
{{- end }}
{{- if .Values.developer.extraEnv }}
{{- range $name,$value := .Values.developer.extraEnv }}
- name: {{ $name }}
value: {{ $value }}
{{- end }}
{{- end }}
{{- with .Values.developer.version }}
- name: OPERATOR_VERSION
value: {{ . | quote }}
{{- end }}
ports:
- containerPort: 8080
name: "http"
protocol: "TCP"
- containerPort: 8443
name: "https"
protocol: "TCP"
livenessProbe:
httpGet:
path: "/q/health/live"
port: 8080
scheme: "HTTP"
initialDelaySeconds: 10
periodSeconds: 60
timeoutSeconds: 10
readinessProbe:
httpGet:
path: "/q/health/ready"
port: 8080
scheme: "HTTP"
initialDelaySeconds: 0
periodSeconds: 2
timeoutSeconds: 1
{{- with .Values.operator.resources }}
resources:
{{- toYaml . | nindent 10 }}
{{- end }}
volumeMounts:
- name: operator-certs
mountPath: /etc/operator/certs
readOnly: true
{{- with ((.Values.developer.patches).operator).volumeMounts }}
{{- toYaml . | nindent 10 }}
{{- end }}
{{- else }}
- name: {{ .Release.Name }}-nginx
image: "registry.access.redhat.com/ubi8/nginx-120:1-92"
imagePullPolicy: IfNotPresent
args:
- '/bin/sh'
- '-ec'
{{- if .Values.developer.showDebug }}
- '-x'
{{- end }}
- exec nginx -g 'daemon off;'
ports:
- containerPort: 9443
name: "proxyhttps"
protocol: "TCP"
volumeMounts:
- name: operator-certs
mountPath: /etc/operator/certs
readOnly: true
- name: operator-nginx-conf
mountPath: /etc/nginx/conf.d
readOnly: true
- name: operator-nginx
subPath: var/cache/nginx
mountPath: /var/cache/nginx
readOnly: false
- name: operator-nginx
subPath: var/run
mountPath: /var/run
readOnly: false
{{- end }}
volumes:
- name: operator-certs
secret:
secretName: {{ include "cert-name" . }}
optional: true
{{- if and .Values.developer.externalOperatorIp .Values.developer.externalOperatorPort }}
- name: operator-nginx-conf
configMap:
name: {{ .Release.Name }}-nginx
optional: false
items:
- key: stackgres-operator.conf
path: stackgres-operator.conf
- name: operator-nginx
emptyDir: {}
{{- end }}
{{- with ((.Values.developer.patches).operator).volumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}