operator-deployment.yaml 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. {{- if .Values.deploy.operator }}
  2. apiVersion: "apps/v1"
  3. kind: "Deployment"
  4. metadata:
  5. {{- with .Values.operator.annotations }}
  6. annotations:
  7. {{- toYaml . | nindent 4 }}
  8. {{- end }}
  9. labels:
  10. app: {{ .Release.Name }}
  11. version: "{{ .Chart.Version }}"
  12. group: stackgres.io
  13. name: {{ .Release.Name }}
  14. namespace: {{ .Release.Namespace }}
  15. spec:
  16. replicas: 1
  17. selector:
  18. matchLabels:
  19. app: {{ .Release.Name }}
  20. group: stackgres.io
  21. template:
  22. metadata:
  23. labels:
  24. app: {{ .Release.Name }}
  25. group: stackgres.io
  26. spec:
  27. {{- with .Values.operator.affinity}}
  28. affinity:
  29. {{- toYaml . | nindent 8 }}
  30. {{- end}}
  31. serviceAccountName: {{ .Release.Name }}
  32. {{- with .Values.operator.affinity}}
  33. affinity:
  34. {{- toYaml . | nindent 8 }}
  35. {{- end}}
  36. {{- with .Values.operator.nodeSelector }}
  37. nodeSelector:
  38. {{- toYaml . | nindent 8 }}
  39. {{- end}}
  40. {{- with .Values.operator.tolerations }}
  41. tolerations:
  42. {{- toYaml . | nindent 8 }}
  43. {{- end }}
  44. securityContext:
  45. {{- if or (not (.Capabilities.APIVersions.Has "project.openshift.io/v1")) .Values.developer.disableArbitraryUser }}
  46. runAsNonRoot: true
  47. {{- if .Values.operator.image.tag | hasSuffix "-jvm" }}
  48. runAsUser: 185
  49. runAsGroup: 185
  50. fsGroup: 185
  51. {{- else }}
  52. runAsUser: 1000
  53. runAsGroup: 1000
  54. fsGroup: 1000
  55. {{- end }}
  56. {{- end }}
  57. containers:
  58. {{- if not (and .Values.developer.externalOperatorIp .Values.developer.externalOperatorPort) }}
  59. - name: {{ .Release.Name }}
  60. image: "{{ include "operator-image" . }}"
  61. imagePullPolicy: {{ .Values.operator.image.pullPolicy }}
  62. env:
  63. - name: OPERATOR_NAME
  64. value: "{{ .Release.Name }}"
  65. - name: OPERATOR_NAMESPACE
  66. valueFrom:
  67. fieldRef:
  68. apiVersion: v1
  69. fieldPath: metadata.namespace
  70. - name: OPERATOR_IMAGE_VERSION
  71. value: "{{ .Values.operator.image.tag }}"
  72. - name: OPERATOR_JVM_IMAGE_VERSION
  73. value: "{{ trimSuffix "-jvm" .Values.operator.image.tag }}-jvm"
  74. - name: OPERATOR_NATIVE_IMAGE_VERSION
  75. value: "{{ trimSuffix "-jvm" .Values.operator.image.tag }}"
  76. - name: DISABLE_RECONCILIATION
  77. value: "false"
  78. - name: INSTALL_CRDS
  79. value: "{{ if or .Values.disableClusterRole .Values.disableCrdsAndWebhooksUpdate }}false{{ else }}true{{ end }}"
  80. - name: WAIT_CRDS_UPGRADE
  81. value: "{{ if or .Values.disableClusterRole .Values.disableCrdsAndWebhooksUpdate }}true{{ else }}false{{ end }}"
  82. - name: INSTALL_WEBHOOKS
  83. value: "{{ if or .Values.disableClusterRole .Values.disableCrdsAndWebhooksUpdate }}false{{ else }}true{{ end }}"
  84. - name: INSTALL_CONVERSION_WEBHOOKS
  85. value: "{{ if or .Values.allowedNamespaces .Values.allowedNamespaceLabelSelector .Values.disableClusterRole }}false{{ else }}true{{ end }}"
  86. - name: ALLOWED_NAMESPACES
  87. {{- $allowedNamespaces := regexSplit " " (include "allowedNamespaces" .) -1 }}
  88. value: "{{ if not ($allowedNamespaces | has "_all_namespaces_placeholder") }}{{ range $index, $namespace := $allowedNamespaces }}{{ if $index }},{{ end }}{{ $namespace }}{{ end }}{{ end }}"
  89. - name: CLUSTER_ROLE_DISABLED
  90. value: "{{ if .Values.disableClusterRole }}true{{ else }}false{{ end }}"
  91. {{- if not .Values.cert.certManager.autoConfigure }}
  92. - name: INSTALL_CERTS
  93. value: "true"
  94. {{- end }}
  95. - name: SGCONFIG_NAMESPACE
  96. value: {{ .Values.sgConfigNamespace | default .Release.Namespace }}
  97. - name: PROMETHEUS_AUTOBIND
  98. value: "{{ or .Values.collector.prometheusOperator.allowDiscovery (gt (len .Values.collector.prometheusOperator.monitors) 0) }}"
  99. {{- if and (.Capabilities.APIVersions.Has "project.openshift.io/v1") (not .Values.developer.disableArbitraryUser) }}
  100. - name: USE_ARBITRARY_USER
  101. value: "true"
  102. {{- end }}
  103. {{- if .Values.developer.logLevel }}
  104. - name: OPERATOR_LOG_LEVEL
  105. value: "{{ .Values.developer.logLevel }}"
  106. {{- end }}
  107. {{- if .Values.developer.showStackTraces }}
  108. - name: OPERATOR_SHOW_STACK_TRACES
  109. value: "{{ .Values.developer.showStackTraces }}"
  110. {{- end }}
  111. {{- if .Values.developer.extraOpts }}
  112. - name: APP_OPTS
  113. value: '{{ range .Values.developer.extraOpts }}{{ . }} {{ end }}'
  114. {{- end }}
  115. {{- if .Values.developer.extraOpts }}
  116. - name: JAVA_OPTS
  117. value: '{{ range .Values.developer.extraOpts }}{{ . }} {{ end }}'
  118. {{- end }}
  119. {{- if .Values.developer.enableJvmDebug }}
  120. - name: DEBUG_OPERATOR
  121. value: "{{ .Values.developer.enableJvmDebug }}"
  122. {{- end }}
  123. {{- if .Values.developer.enableJvmDebugSuspend }}
  124. - name: DEBUG_OPERATOR_SUSPEND
  125. value: "{{ .Values.developer.enableJvmDebugSuspend }}"
  126. {{- end }}
  127. - name: OPERATOR_SERVICE_ACCOUNT
  128. valueFrom:
  129. fieldRef:
  130. apiVersion: v1
  131. fieldPath: spec.serviceAccountName
  132. - name: OPERATOR_POD_NAME
  133. valueFrom:
  134. fieldRef:
  135. apiVersion: v1
  136. fieldPath: metadata.name
  137. - name: OPERATOR_IP
  138. valueFrom:
  139. fieldRef:
  140. fieldPath: status.podIP
  141. {{- if and .Values.grafana.url .Values.grafana.token .Values.grafana.webHost }}
  142. - name: GRAFANA_EMBEDDED
  143. value: "true"
  144. {{ end }}
  145. - name: SG_CONTAINER_REGISTRY
  146. value: "{{ .Values.containerRegistry }}"
  147. - name: SG_IMAGE_PULL_POLICY
  148. value: "{{ .Values.imagePullPolicy }}"
  149. {{- if .Values.extensions.cache.enabled }}
  150. - name: EXTENSIONS_REPOSITORY_URLS
  151. 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 }}"
  152. {{- else }}
  153. - name: EXTENSIONS_REPOSITORY_URLS
  154. value: "{{ range $index, $element := .Values.extensions.repositoryUrls }}{{ if $index }},{{ end }}{{ $element }}{{ end }}"
  155. {{- end }}
  156. {{- if .Values.developer.extraEnv }}
  157. {{- range $name,$value := .Values.developer.extraEnv }}
  158. - name: {{ $name }}
  159. value: {{ $value }}
  160. {{- end }}
  161. {{- end }}
  162. {{- with .Values.developer.version }}
  163. - name: OPERATOR_VERSION
  164. value: {{ . | quote }}
  165. {{- end }}
  166. ports:
  167. - containerPort: 8080
  168. name: "http"
  169. protocol: "TCP"
  170. - containerPort: 8443
  171. name: "https"
  172. protocol: "TCP"
  173. livenessProbe:
  174. httpGet:
  175. path: "/q/health/live"
  176. port: 8080
  177. scheme: "HTTP"
  178. initialDelaySeconds: 10
  179. periodSeconds: 60
  180. timeoutSeconds: 10
  181. readinessProbe:
  182. httpGet:
  183. path: "/q/health/ready"
  184. port: 8080
  185. scheme: "HTTP"
  186. initialDelaySeconds: 0
  187. periodSeconds: 2
  188. timeoutSeconds: 1
  189. {{- with .Values.operator.resources }}
  190. resources:
  191. {{- toYaml . | nindent 10 }}
  192. {{- end }}
  193. volumeMounts:
  194. - name: operator-certs
  195. mountPath: /etc/operator/certs
  196. readOnly: true
  197. {{- with ((.Values.developer.patches).operator).volumeMounts }}
  198. {{- toYaml . | nindent 10 }}
  199. {{- end }}
  200. {{- else }}
  201. - name: {{ .Release.Name }}-nginx
  202. image: "registry.access.redhat.com/ubi8/nginx-120:1-92"
  203. imagePullPolicy: IfNotPresent
  204. args:
  205. - '/bin/sh'
  206. - '-ec'
  207. {{- if .Values.developer.showDebug }}
  208. - '-x'
  209. {{- end }}
  210. - exec nginx -g 'daemon off;'
  211. ports:
  212. - containerPort: 9443
  213. name: "proxyhttps"
  214. protocol: "TCP"
  215. volumeMounts:
  216. - name: operator-certs
  217. mountPath: /etc/operator/certs
  218. readOnly: true
  219. - name: operator-nginx-conf
  220. mountPath: /etc/nginx/conf.d
  221. readOnly: true
  222. - name: operator-nginx
  223. subPath: var/cache/nginx
  224. mountPath: /var/cache/nginx
  225. readOnly: false
  226. - name: operator-nginx
  227. subPath: var/run
  228. mountPath: /var/run
  229. readOnly: false
  230. {{- end }}
  231. volumes:
  232. - name: operator-certs
  233. secret:
  234. secretName: {{ include "cert-name" . }}
  235. optional: true
  236. {{- if and .Values.developer.externalOperatorIp .Values.developer.externalOperatorPort }}
  237. - name: operator-nginx-conf
  238. configMap:
  239. name: {{ .Release.Name }}-nginx
  240. optional: false
  241. items:
  242. - key: stackgres-operator.conf
  243. path: stackgres-operator.conf
  244. - name: operator-nginx
  245. emptyDir: {}
  246. {{- end }}
  247. {{- with ((.Values.developer.patches).operator).volumes }}
  248. {{- toYaml . | nindent 8 }}
  249. {{- end }}
  250. {{- end }}