_diskover.tpl 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. {{- define "diskover.workload" -}}
  2. {{- $fullname := (include "ix.v1.common.lib.chart.names.fullname" $) -}}
  3. {{- $elasticsearch := printf "http://%s-elasticsearch:%v/_cluster/health?local=true" $fullname 9200 }}
  4. workload:
  5. diskover:
  6. enabled: true
  7. primary: true
  8. type: Deployment
  9. podSpec:
  10. hostNetwork: false
  11. securityContext:
  12. fsGroup: {{ .Values.diskoverID.group }}
  13. containers:
  14. diskover:
  15. enabled: true
  16. primary: true
  17. imageSelector: image
  18. securityContext:
  19. runAsUser: 0
  20. runAsGroup: 0
  21. runAsNonRoot: false
  22. readOnlyRootFilesystem: false
  23. capabilities:
  24. add:
  25. - CHOWN
  26. - DAC_OVERRIDE
  27. - FOWNER
  28. - SETGID
  29. - SETUID
  30. - KILL
  31. fixedEnv:
  32. PUID: {{ .Values.diskoverID.user }}
  33. {{ with .Values.diskoverConfig.additionalEnvs }}
  34. envList:
  35. {{ range $env := . }}
  36. - name: {{ $env.name }}
  37. value: {{ $env.value }}
  38. {{ end }}
  39. {{ end }}
  40. probes:
  41. liveness:
  42. enabled: true
  43. type: http
  44. path: /login.php
  45. port: 80
  46. readiness:
  47. enabled: true
  48. type: http
  49. path: /login.php
  50. port: 80
  51. startup:
  52. enabled: true
  53. type: http
  54. path: /login.php
  55. port: 80
  56. lifecycle:
  57. {{- $sched := .Values.diskoverConfig.cronSchedule }}
  58. postStart:
  59. type: exec
  60. command:
  61. - /bin/sh
  62. - -c
  63. - |
  64. /scripts/.default_crawler.sh /app/diskover/diskover.py /data;
  65. {{- $cron := printf "%s python3 /app/diskover/diskover.py /data" $sched }}
  66. if ! cat /config/crontab | grep -q "{{ $cron }}"; then
  67. echo "{{ $cron }}" >> /config/crontab;
  68. fi
  69. {{- range $item := .Values.diskoverStorage.additionalStorages }}
  70. /scripts/.default_crawler.sh /app/diskover/diskover.py {{ $item.mountPath }};
  71. {{- end -}}
  72. {{- range $item := .Values.diskoverStorage.additionalStorages }}
  73. {{- if $item.diskoverDataIndex }}
  74. {{- $cron := printf "%s python3 /app/diskover/diskover.py %s" $sched $item.mountPath }}
  75. if ! cat /config/crontab | grep -q "{{ $cron }}"; then
  76. echo "{{ $cron }}" >> /config/crontab;
  77. fi
  78. {{- end }}
  79. {{- end }}
  80. crontab /config/crontab;
  81. initContainers:
  82. 01-wait-for-elasticsearch:
  83. enabled: true
  84. type: init
  85. imageSelector: bashImage
  86. env:
  87. ELASTIC_PASSWORD:
  88. secretKeyRef:
  89. name: diskover-secret
  90. key: es-password
  91. command:
  92. - bash
  93. - -c
  94. args:
  95. - |
  96. echo "Pinging [{{ $elasticsearch }}] until it is ready..."
  97. head="--header=Authorization: Basic x$(base64 <<< "elastic:$ELASTIC_PASSWORD")"
  98. time="--timeout=3"
  99. until wget "$head" "$time" --spider -qO- "{{ $elasticsearch }}"; do
  100. echo "Waiting for [{{ $elasticsearch }}] to be ready..."
  101. sleep 2
  102. done
  103. echo "URL [{{ $elasticsearch }}] is ready!"
  104. {{- end -}}