deployment.yaml 6.6 KB

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