deployment.yaml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. {{ include "common.storage.hostPathValidate" .Values }}
  2. {{ $elastic_search := (. | mustDeepCopy) }}
  3. {{ $_ := set $elastic_search "common" (dict "nameSuffix" "elasticsearch") }}
  4. apiVersion: {{ template "common.capabilities.deployment.apiVersion" . }}
  5. kind: Deployment
  6. metadata:
  7. name: {{ template "common.names.fullname" . }}
  8. labels:
  9. app: {{ template "common.names.name" . }}
  10. chart: {{ template "common.names.chart" . }}
  11. release: {{ .Release.Name }}
  12. heritage: {{ .Release.Service }}
  13. annotations:
  14. rollme: {{ randAlphaNum 5 | quote }}
  15. spec:
  16. replicas: {{ (default 1 .Values.replicas) }}
  17. strategy:
  18. type: "Recreate"
  19. selector:
  20. matchLabels:
  21. app: {{ template "common.names.name" . }}
  22. release: {{ .Release.Name }}
  23. template:
  24. metadata:
  25. name: {{ template "common.names.fullname" . }}
  26. labels:
  27. app: {{ template "common.names.name" . }}
  28. release: {{ .Release.Name }}
  29. {{- include "common.labels.selectorLabels" . | nindent 8 }}
  30. annotations: {{ include "common.annotations" . | nindent 8 }}
  31. spec:
  32. initContainers:
  33. - name: init-config
  34. {{ include "common.containers.imageConfig" .Values.python.image | nindent 10 }}
  35. command: ["python3", "/init_scripts/init_config.py"]
  36. env:
  37. {{ $envList := (default list .Values.environmentVariables) }}
  38. {{ $envList = mustAppend $envList (dict "name" "TZ" "value" .Values.timezone) }}
  39. {{ $envList = mustAppend $envList (dict "name" "DS_USER" "valueFromSecret" true "secretName" "diskover-credentials" "secretKey" "username") }}
  40. {{ $envList = mustAppend $envList (dict "name" "DS_PASS" "valueFromSecret" true "secretName" "diskover-credentials" "secretKey" "password") }}
  41. {{ include "common.containers.environmentVariables" (dict "environmentVariables" $envList) | nindent 12 }}
  42. {{ include "elasticsearch.IP" $elastic_search | nindent 12 }}
  43. {{ include "elasticsearch.credentials" . | nindent 12 }}
  44. {{ $configPath := (dict "mountPath" (printf "%s/diskover-web.conf.d/" .Values.appVolumeMounts.config.mountPath) "configFile" "Constants.php") }}
  45. {{ include "config.file.path" $configPath | nindent 12 }}
  46. volumeMounts: {{ include "common.storage.configureAppVolumeMountsInContainer" .Values | nindent 12 }}
  47. - name: diskover-initial-scripts
  48. mountPath: /init_scripts/
  49. - name: wait-es-search
  50. {{ include "common.containers.imageConfig" .Values.image | nindent 10 }}
  51. env:
  52. {{ include "elasticsearch.IP" $elastic_search | nindent 12 }}
  53. command: ["python3", "/init_scripts/wait_for_elastic_search.py"]
  54. volumeMounts:
  55. - name: diskover-initial-scripts
  56. mountPath: /init_scripts/
  57. - name: init-es-config
  58. {{ include "common.containers.imageConfig" .Values.python.image | nindent 10 }}
  59. command: ["python3", "/init_scripts/initial_es_config.py"]
  60. env:
  61. {{ $envListConfig := (default list .Values.environmentVariables) }}
  62. {{ include "elasticsearch.IP" $elastic_search | nindent 12 }}
  63. {{ include "elasticsearch.credentials" . | nindent 12 }}
  64. {{ $configPathES := (dict "mountPath" (printf "%s/diskover.conf.d/diskover/" .Values.appVolumeMounts.config.mountPath) "configFile" "config.yaml") }}
  65. {{ include "config.file.path" $configPathES | nindent 12 }}
  66. {{ include "common.containers.environmentVariables" (dict "environmentVariables" $envListConfig) | nindent 12 }}
  67. volumeMounts: {{ include "common.storage.configureAppVolumeMountsInContainer" .Values | nindent 12 }}
  68. - name: diskover-initial-scripts
  69. mountPath: /init_scripts/
  70. containers:
  71. - name: {{ .Chart.Name }}
  72. {{ include "common.resources.limitation" . | nindent 10 }}
  73. {{ include "common.containers.imageConfig" .Values.image | nindent 10 }}
  74. volumeMounts: {{ include "common.storage.configureAppVolumeMountsInContainer" .Values | nindent 12 }}
  75. - name: diskover-initial-scripts
  76. mountPath: /init_scripts/
  77. {{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }}
  78. - name: extrappvolume-{{ $index }}
  79. mountPath: {{ $hostPathConfiguration.mountPath }}
  80. {{ end }}
  81. {{ range $index, $hostPathConfiguration := .Values.extraDataVolumeMounts }}
  82. - name: extradatavolume-{{ $index }}
  83. mountPath: {{ $hostPathConfiguration.mountPath }}
  84. {{ end }}
  85. ports:
  86. - name: web
  87. containerPort: 80
  88. {{ $cronjobSchedule := .Values.cronjobSchedule }}
  89. lifecycle:
  90. postStart:
  91. exec:
  92. command:
  93. - /bin/sh
  94. - -c
  95. - |
  96. ./init_scripts/.default_crawler.sh /app/diskover/diskover.py /data;
  97. {{ range $index, $hostPathConfiguration := .Values.extraDataVolumeMounts }}
  98. ./init_scripts/.default_crawler.sh /app/diskover/diskover.py {{ $hostPathConfiguration.mountPath }};
  99. {{ end }}
  100. {{ range $index, $hostPathConfiguration := .Values.extraDataVolumeMounts }}
  101. echo "{{$cronjobSchedule}} python3 /app/diskover/diskover.py {{ $hostPathConfiguration.mountPath }}" >> /config/crontab;
  102. {{ end }}
  103. echo "{{.Values.cronjobSchedule}} python3 /app/diskover/diskover.py /data" >> /config/crontab;
  104. crontab /config/crontab;
  105. env:
  106. {{ $envListDiskover := (default list .Values.environmentVariables) }}
  107. {{ $envListDiskover = mustAppend $envListDiskover (dict "name" "PUID" "value" .Values.ownerUID) }}
  108. {{ $envListDiskover = mustAppend $envListDiskover (dict "name" "PGID" "value" .Values.ownerGID) }}
  109. {{ include "common.containers.environmentVariables" (dict "environmentVariables" $envListDiskover) | nindent 12 }}
  110. livenessProbe:
  111. httpGet:
  112. path: /login.php
  113. port: 80
  114. initialDelaySeconds: 10
  115. periodSeconds: 10
  116. timeoutSeconds: 5
  117. failureThreshold: 5
  118. successThreshold: 1
  119. readinessProbe:
  120. httpGet:
  121. path: /login.php
  122. port: 80
  123. initialDelaySeconds: 10
  124. periodSeconds: 10
  125. timeoutSeconds: 5
  126. failureThreshold: 5
  127. successThreshold: 2
  128. startupProbe:
  129. httpGet:
  130. path: /login.php
  131. port: 80
  132. initialDelaySeconds: 10
  133. periodSeconds: 5
  134. timeoutSeconds: 2
  135. failureThreshold: 60
  136. successThreshold: 1
  137. {{ include "common.networking.dnsConfiguration" .Values | nindent 6 }}
  138. volumes: {{ include "common.storage.configureAppVolumes" .Values | nindent 8 }}
  139. {{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }}
  140. - name: extrappvolume-{{ $index }}
  141. hostPath:
  142. path: {{ $hostPathConfiguration.hostPath }}
  143. {{ end }}
  144. {{ range $index, $hostPathConfiguration := .Values.extraDataVolumeMounts }}
  145. - name: extradatavolume-{{ $index }}
  146. hostPath:
  147. path: {{ $hostPathConfiguration.hostPath }}
  148. {{ end }}
  149. - name: diskover-initial-scripts
  150. configMap:
  151. defaultMode: 0700
  152. name: "diskover-initial-scripts"