extensions-cache-statefulset.yaml 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. {{- if .Values.extensions.cache.enabled }}
  2. apiVersion: "apps/v1"
  3. kind: "StatefulSet"
  4. metadata:
  5. labels:
  6. app: {{ .Release.Name }}-extensions-cache
  7. version: "{{ .Chart.Version }}"
  8. group: stackgres.io
  9. name: {{ .Release.Name }}-extensions-cache
  10. namespace: {{ .Release.Namespace }}
  11. spec:
  12. replicas: 1
  13. selector:
  14. matchLabels:
  15. app: {{ .Release.Name }}-extensions-cache
  16. group: stackgres.io
  17. serviceName: {{ .Release.Name }}-extensions-cache
  18. template:
  19. metadata:
  20. labels:
  21. app: {{ .Release.Name }}-extensions-cache
  22. group: stackgres.io
  23. spec:
  24. securityContext:
  25. {{- if or (not (.Capabilities.APIVersions.Has "project.openshift.io/v1")) .Values.developer.disableArbitraryUser }}
  26. fsGroup: 1000
  27. {{- end }}
  28. serviceAccountName: {{ .Release.Name }}-extensions-cache
  29. shareProcessNamespace: true
  30. terminationGracePeriodSeconds: 0
  31. restartPolicy: Always
  32. containers:
  33. - name: http
  34. image: "registry.access.redhat.com/ubi8/nginx-120:1-92.1679484498"
  35. imagePullPolicy: {{ .Values.imagePullPolicy }}
  36. securityContext:
  37. {{- if and (or (not (.Capabilities.APIVersions.Has "project.openshift.io/v1")) .Values.developer.disableArbitraryUser) (not .Values.extensions.cache.hostPath) }}
  38. runAsNonRoot: true
  39. runAsUser: 998
  40. runAsGroup: 1000
  41. {{- end }}
  42. {{- if .Values.extensions.cache.hostPath }}
  43. runAsUser: 0
  44. {{- end }}
  45. args:
  46. - '/bin/sh'
  47. - '-ec'
  48. {{- if .Values.developer.showDebug }}
  49. - '-x'
  50. {{- end }}
  51. - |
  52. mkdir -p /var/lib/nginx/tmp
  53. exec nginx -g 'daemon off;'
  54. ports:
  55. - containerPort: 8080
  56. name: "http"
  57. protocol: "TCP"
  58. readinessProbe:
  59. tcpSocket:
  60. port: 8080
  61. volumeMounts:
  62. - name: extensions-cache-config
  63. mountPath: /etc/nginx/nginx.conf
  64. subPath: nginx.conf
  65. readOnly: true
  66. - name: extensions-cache-config
  67. mountPath: /etc/nginx/conf.d/stackgres-operator-extensions-cache.conf
  68. subPath: stackgres-operator-extensions-cache.conf
  69. readOnly: true
  70. - name: extensions-cache-nginx-var
  71. subPath: var/cache/nginx
  72. mountPath: /var/cache/nginx
  73. readOnly: false
  74. - name: extensions-cache-nginx-var
  75. subPath: var/run
  76. mountPath: /var/run
  77. readOnly: false
  78. - name: extensions-cache-nginx-var
  79. subPath: var/lib/nginx
  80. mountPath: /var/lib/nginx
  81. readOnly: false
  82. - name: extensions-cache-nginx-var
  83. subPath: var/log/nginx
  84. mountPath: /var/log/nginx
  85. readOnly: false
  86. - name: {{ .Release.Name }}-extensions-cache
  87. subPath: repository
  88. mountPath: /opt/app-root/src
  89. readOnly: true
  90. - name: "controller"
  91. image: {{ template "kubectl-image" . }}
  92. imagePullPolicy: {{ .Values.imagePullPolicy }}
  93. securityContext:
  94. {{- if and (or (not (.Capabilities.APIVersions.Has "project.openshift.io/v1")) .Values.developer.disableArbitraryUser) (not .Values.extensions.cache.hostPath) }}
  95. runAsNonRoot: true
  96. runAsUser: 1000
  97. runAsGroup: 1000
  98. {{- end }}
  99. {{- if .Values.extensions.cache.hostPath }}
  100. runAsUser: 0
  101. {{- end }}
  102. env:
  103. - name: HOME
  104. value: /tmp
  105. - name: EXTENSIONS_REPOSITORY_URLS
  106. value: "{{ range $index, $element := .Values.extensions.repositoryUrls }}{{ if $index }},{{ end }}{{ $element }}{{ end }}"
  107. - name: OPERATOR_NAMESPACE
  108. valueFrom:
  109. fieldRef:
  110. apiVersion: v1
  111. fieldPath: metadata.namespace
  112. {{- if .Values.developer.logLevel }}
  113. - name: EXTENSIONS_CACHE_LOG_LEVEL
  114. value: "{{ .Values.developer.logLevel }}"
  115. {{- end }}
  116. {{- range .Values.developer.extraOpts }}
  117. {{- if . | hasPrefix "-Dquarkus.log.category.\"stackgres-extensions-cache\".level=" }}
  118. - name: EXTENSIONS_CACHE_LOG_LEVEL
  119. value: "{{ . | trimPrefix "-Dquarkus.log.category.\"stackgres-extensions-cache\".level=" }}"
  120. {{- end }}
  121. {{- end }}
  122. {{- if .Values.extensions.cache.preloadedExtensions }}
  123. - name: EXTENSIONS_CACHE_PRELOADED_EXTENSIONS
  124. value: {{ .Values.extensions.cache.preloadedExtensions | toJson | squote }}
  125. {{- end }}
  126. - name: ALLOWED_NAMESPACES
  127. {{- $allowedNamespaces := regexSplit " " (include "allowedNamespaces" .) -1 }}
  128. value: "{{ if not ($allowedNamespaces | has "_all_namespaces_placeholder") }}{{ range $index, $namespace := $allowedNamespaces }}{{ if $index }},{{ end }}{{ $namespace }}{{ end }}{{ end }}"
  129. command:
  130. - "/bin/bash"
  131. - "-ec"
  132. - |
  133. echo "$EXTENSIONS_CACHE_LOG_LEVEL" | grep -v -q '^\(DEBUG\|TRACE\)$' || set -x
  134. cd /opt/app-root/src
  135. sh /usr/local/bin/extensions-cache-conciliator.sh run "$OPERATOR_NAMESPACE" '{{ .Release.Name }}-extensions-cache'
  136. readinessProbe:
  137. exec:
  138. command:
  139. - test
  140. - -f
  141. - /tmp/extensions-cache-ready
  142. volumeMounts:
  143. - name: extensions-cache-config
  144. mountPath: /usr/local/bin/extensions-cache-conciliator.sh
  145. subPath: extensions-cache-conciliator.sh
  146. readOnly: true
  147. - name: {{ .Release.Name }}-extensions-cache
  148. subPath: repository
  149. mountPath: /opt/app-root/src
  150. readOnly: false
  151. - name: extensions-cache-nginx-var
  152. subPath: var/log/nginx
  153. mountPath: /var/log/nginx
  154. readOnly: true
  155. volumes:
  156. {{- if .Values.extensions.cache.hostPath }}
  157. - name: {{ .Release.Name }}-extensions-cache
  158. hostPath:
  159. path: "{{ .Values.extensions.cache.hostPath }}"
  160. type: DirectoryOrCreate
  161. {{- end }}
  162. - name: extensions-cache-config
  163. configMap:
  164. name: {{ .Release.Name }}-extensions-cache
  165. optional: false
  166. items:
  167. - key: nginx.conf
  168. path: nginx.conf
  169. - key: stackgres-operator-extensions-cache.conf
  170. path: stackgres-operator-extensions-cache.conf
  171. - key: extensions-cache-conciliator.sh
  172. path: extensions-cache-conciliator.sh
  173. - name: extensions-cache-nginx-var
  174. emptyDir: {}
  175. {{- if not .Values.extensions.cache.hostPath }}
  176. volumeClaimTemplates:
  177. - metadata:
  178. labels:
  179. app: {{ .Release.Name }}-extensions-cache
  180. version: "{{ .Chart.Version }}"
  181. group: stackgres.io
  182. name: {{ .Release.Name }}-extensions-cache
  183. spec:
  184. accessModes: [ "ReadWriteOnce" ]
  185. {{- if .Values.extensions.cache.persistentVolume.storageClass }}
  186. {{- if eq "-" .Values.extensions.cache.persistentVolume.storageClass }}
  187. storageClassName: ""
  188. {{- else }}
  189. storageClassName: "{{ .Values.extensions.cache.persistentVolume.storageClass }}"
  190. {{- end }}
  191. {{- end }}
  192. resources:
  193. requests:
  194. storage: "{{ .Values.extensions.cache.persistentVolume.size }}"
  195. {{- end }}
  196. {{- end }}