initialize-operator.yaml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. {{- if or .Values.disableClusterRole .Values.disableCrdsAndWebhooksUpdate }}
  2. apiVersion: batch/v1
  3. kind: Job
  4. metadata:
  5. namespace: {{ .Release.Namespace }}
  6. name: "{{ .Release.Name }}-initialize-operator"
  7. labels:
  8. app: stackgres-operator-init
  9. job: initialize-operator
  10. annotations:
  11. "helm.sh/hook": post-install,post-upgrade
  12. "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
  13. "helm.sh/hook-weight": "10"
  14. {{- with .Values.jobs.annotations }}
  15. {{- toYaml . | nindent 4 }}
  16. {{- end }}
  17. spec:
  18. ttlSecondsAfterFinished: 3600
  19. template:
  20. metadata:
  21. labels:
  22. app: stackgres-operator-init
  23. job: initialize-operator
  24. spec:
  25. serviceAccountName: {{ .Release.Name }}-init
  26. restartPolicy: OnFailure
  27. terminationGracePeriodSeconds: 0
  28. {{- with .Values.operator.affinity}}
  29. affinity:
  30. {{- toYaml . | nindent 8 }}
  31. {{- end}}
  32. {{- with .Values.operator.nodeSelector }}
  33. nodeSelector:
  34. {{- toYaml . | nindent 8 }}
  35. {{- end}}
  36. {{- with .Values.operator.tolerations }}
  37. tolerations:
  38. {{- toYaml . | nindent 8 }}
  39. {{- end }}
  40. securityContext:
  41. {{- if or (not (.Capabilities.APIVersions.Has "project.openshift.io/v1")) .Values.developer.disableArbitraryUser }}
  42. runAsNonRoot: true
  43. {{- if .Values.operator.image.tag | hasSuffix "-jvm" }}
  44. runAsUser: 185
  45. runAsGroup: 185
  46. fsGroup: 185
  47. {{- else }}
  48. runAsUser: 1000
  49. runAsGroup: 1000
  50. fsGroup: 1000
  51. {{- end }}
  52. {{- end }}
  53. containers:
  54. - name: {{ .Release.Name }}
  55. image: "{{ include "operator-image" . }}"
  56. imagePullPolicy: {{ .Values.operator.image.pullPolicy }}
  57. env:
  58. - name: OPERATOR_NAME
  59. value: "{{ .Release.Name }}"
  60. - name: OPERATOR_NAMESPACE
  61. valueFrom:
  62. fieldRef:
  63. apiVersion: v1
  64. fieldPath: metadata.namespace
  65. - name: OPERATOR_IMAGE_VERSION
  66. value: "{{ .Values.operator.image.tag }}"
  67. - name: OPERATOR_JVM_IMAGE_VERSION
  68. value: "{{ trimSuffix "-jvm" .Values.operator.image.tag }}-jvm"
  69. - name: OPERATOR_NATIVE_IMAGE_VERSION
  70. value: "{{ trimSuffix "-jvm" .Values.operator.image.tag }}"
  71. - name: DISABLE_RECONCILIATION
  72. value: "true"
  73. - name: INSTALL_CRDS
  74. value: "true"
  75. - name: WAIT_CRDS_UPGRADE
  76. value: "false"
  77. - name: FORCE_UNLOCK_OPERATOR
  78. value: "true"
  79. - name: STOP_AFTER_BOOTSTRAP
  80. value: "true"
  81. - name: INSTALL_WEBHOOKS
  82. value: "true"
  83. - name: INSTALL_CONVERSION_WEBHOOKS
  84. value: "{{ if or .Values.allowedNamespaces .Values.allowedNamespaceLabelSelector .Values.disableClusterRole }}false{{ else }}true{{ end }}"
  85. - name: ALLOWED_NAMESPACES
  86. {{- $allowedNamespaces := regexSplit " " (include "allowedNamespaces" .) -1 }}
  87. value: "{{ if not ($allowedNamespaces | has "_all_namespaces_placeholder") }}{{ range $index, $namespace := $allowedNamespaces }}{{ if $index }},{{ end }}{{ $namespace }}{{ end }}{{ end }}"
  88. - name: CLUSTER_ROLE_DISABLED
  89. value: "{{ if .Values.disableClusterRole }}true{{ else }}false{{ end }}"
  90. {{- if not .Values.cert.certManager.autoConfigure }}
  91. - name: INSTALL_CERTS
  92. value: "true"
  93. {{- end }}
  94. {{- if .Values.developer.logLevel }}
  95. - name: OPERATOR_LOG_LEVEL
  96. value: "{{ .Values.developer.logLevel }}"
  97. {{- end }}
  98. {{- if .Values.developer.showStackTraces }}
  99. - name: OPERATOR_SHOW_STACK_TRACES
  100. value: "{{ .Values.developer.showStackTraces }}"
  101. {{- end }}
  102. {{- if .Values.developer.extraOpts }}
  103. - name: APP_OPTS
  104. value: '{{ range .Values.developer.extraOpts }}{{ . }} {{ end }}'
  105. {{- end }}
  106. {{- if .Values.developer.extraOpts }}
  107. - name: JAVA_OPTS
  108. value: '{{ range .Values.developer.extraOpts }}{{ . }} {{ end }}'
  109. {{- end }}
  110. {{- if .Values.developer.enableJvmDebug }}
  111. - name: DEBUG_OPERATOR
  112. value: "{{ .Values.developer.enableJvmDebug }}"
  113. {{- end }}
  114. {{- if .Values.developer.enableJvmDebugSuspend }}
  115. - name: DEBUG_OPERATOR_SUSPEND
  116. value: "{{ .Values.developer.enableJvmDebugSuspend }}"
  117. {{- end }}
  118. - name: OPERATOR_SERVICE_ACCOUNT
  119. valueFrom:
  120. fieldRef:
  121. apiVersion: v1
  122. fieldPath: spec.serviceAccountName
  123. - name: OPERATOR_POD_NAME
  124. valueFrom:
  125. fieldRef:
  126. apiVersion: v1
  127. fieldPath: metadata.name
  128. - name: OPERATOR_IP
  129. valueFrom:
  130. fieldRef:
  131. fieldPath: status.podIP
  132. {{- if .Values.developer.extraEnv }}
  133. {{- range $name,$value := .Values.developer.extraEnv }}
  134. - name: {{ $name }}
  135. value: {{ $value }}
  136. {{- end }}
  137. {{- end }}
  138. {{- with .Values.developer.version }}
  139. - name: OPERATOR_VERSION
  140. value: {{ . | quote }}
  141. {{- end }}
  142. {{- with .Values.operator.resources }}
  143. resources:
  144. {{- toYaml . | nindent 10 }}
  145. {{- end }}
  146. volumeMounts:
  147. - name: operator-certs
  148. mountPath: /etc/operator/certs
  149. readOnly: true
  150. {{- with ((.Values.developer.patches).operator).volumeMounts }}
  151. {{- toYaml . | nindent 10 }}
  152. {{- end }}
  153. volumes:
  154. - name: operator-certs
  155. secret:
  156. secretName: {{ include "cert-name" . }}
  157. optional: true
  158. {{- end }}