sgconfig.yaml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. ---
  2. apiVersion: v1
  3. kind: ConfigMap
  4. metadata:
  5. namespace: {{ .Release.Namespace }}
  6. name: "{{ .Release.Name }}-sgconfig-crd"
  7. annotations:
  8. "helm.sh/hook": pre-install,pre-upgrade,post-upgrade # Remove post-upgrade after version 1.13 get out of support
  9. "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
  10. "helm.sh/hook-weight": "9"
  11. data:
  12. SGConfig.yaml: |
  13. {{ .Files.Get "crds/SGConfig.yaml" | nindent 4 }}
  14. ---
  15. apiVersion: v1
  16. kind: ConfigMap
  17. metadata:
  18. namespace: {{ .Release.Namespace }}
  19. name: "{{ .Release.Name }}-sgconfig"
  20. annotations:
  21. "helm.sh/hook": pre-install,pre-upgrade,post-upgrade # Remove post-upgrade after version 1.13 get out of support
  22. "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
  23. "helm.sh/hook-weight": "9"
  24. data:
  25. sgconfig.yaml: |
  26. apiVersion: stackgres.io/v1
  27. kind: SGConfig
  28. metadata:
  29. annotations:
  30. meta.helm.sh/release-name: {{ .Release.Name }}
  31. meta.helm.sh/release-namespace: {{ .Release.Namespace }}
  32. labels:
  33. app.kubernetes.io/managed-by: Helm
  34. name: {{ .Release.Name }}
  35. namespace: {{ .Values.sgConfigNamespace | default .Release.Namespace }}
  36. spec:
  37. {{ regexReplaceAll "[^ ]+: null" (unset .Values "global" | toYaml | nindent 6) "" }}
  38. ---
  39. apiVersion: batch/v1
  40. kind: Job
  41. metadata:
  42. namespace: {{ .Release.Namespace }}
  43. name: "{{ .Release.Name }}-install-sgconfig"
  44. labels:
  45. app: stackgres-operator-init
  46. job: install-sgconfig
  47. annotations:
  48. "helm.sh/hook": pre-install,pre-upgrade,post-upgrade # Remove post-upgrade after version 1.13 get out of support
  49. "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
  50. "helm.sh/hook-weight": "10"
  51. {{- with .Values.jobs.annotations }}
  52. {{- toYaml . | nindent 4 }}
  53. {{- end }}
  54. spec:
  55. ttlSecondsAfterFinished: 3600
  56. template:
  57. metadata:
  58. labels:
  59. app: stackgres-operator-init
  60. job: install-sgconfig
  61. spec:
  62. serviceAccountName: {{ .Release.Name }}-init
  63. restartPolicy: OnFailure
  64. terminationGracePeriodSeconds: 0
  65. {{- with .Values.jobs.affinity}}
  66. affinity:
  67. {{- toYaml . | nindent 8 }}
  68. {{- end}}
  69. {{- with .Values.jobs.nodeSelector}}
  70. nodeSelector:
  71. {{- toYaml . | nindent 8 }}
  72. {{- end }}
  73. {{- with .Values.jobs.tolerations }}
  74. tolerations:
  75. {{- toYaml . | nindent 8 }}
  76. {{- end }}
  77. containers:
  78. - name: "install-sgconfig"
  79. image: {{ template "kubectl-image" . }}
  80. imagePullPolicy: "IfNotPresent"
  81. {{- with .Values.jobs.resources }}
  82. resources:
  83. {{- toYaml . | nindent 10 }}
  84. {{- end }}
  85. command:
  86. - "/bin/bash"
  87. - "-ecx"
  88. - |
  89. kubectl replace -f /SGConfig.yaml
  90. kubectl apply -f /sgconfig.yaml
  91. volumeMounts:
  92. - name: sgconfig-crd
  93. mountPath: /SGConfig.yaml
  94. subPath: SGConfig.yaml
  95. - name: sgconfig
  96. mountPath: /sgconfig.yaml
  97. subPath: sgconfig.yaml
  98. volumes:
  99. - name: sgconfig-crd
  100. configMap:
  101. name: "{{ .Release.Name }}-sgconfig-crd"
  102. optional: false
  103. - name: sgconfig
  104. configMap:
  105. name: "{{ .Release.Name }}-sgconfig"
  106. optional: false
  107. ---
  108. apiVersion: batch/v1
  109. kind: Job
  110. metadata:
  111. namespace: {{ .Release.Namespace }}
  112. name: "{{ .Release.Name }}-remove-sgconfig"
  113. labels:
  114. app: stackgres-operator-init
  115. job: remove-sgconfig
  116. annotations:
  117. "helm.sh/hook": post-delete
  118. "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
  119. "helm.sh/hook-weight": "10"
  120. {{- with .Values.jobs.annotations }}
  121. {{- toYaml . | nindent 4 }}
  122. {{- end }}
  123. spec:
  124. ttlSecondsAfterFinished: 3600
  125. template:
  126. metadata:
  127. labels:
  128. app: stackgres-operator-init
  129. job: remove-sgconfig
  130. spec:
  131. serviceAccountName: {{ .Release.Name }}-init
  132. restartPolicy: OnFailure
  133. terminationGracePeriodSeconds: 0
  134. {{- with .Values.jobs.affinity}}
  135. affinity:
  136. {{- toYaml . | nindent 8 }}
  137. {{- end}}
  138. {{- with .Values.jobs.nodeSelector}}
  139. nodeSelector:
  140. {{- toYaml . | nindent 8 }}
  141. {{- end }}
  142. {{- with .Values.jobs.tolerations }}
  143. tolerations:
  144. {{- toYaml . | nindent 8 }}
  145. {{- end }}
  146. containers:
  147. - name: "remove-sgconfig"
  148. image: {{ template "kubectl-image" . }}
  149. imagePullPolicy: "IfNotPresent"
  150. {{- with .Values.jobs.resources }}
  151. resources:
  152. {{- toYaml . | nindent 10 }}
  153. {{- end }}
  154. command:
  155. - "/bin/bash"
  156. - "-ecx"
  157. - |
  158. kubectl delete sgconfig -n "{{ .Values.sgConfigNamespace | default .Release.Namespace }}" "{{ .Release.Name }}"