_nextcloud.tpl 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. {{- define "nextcloud.workload" -}}
  2. workload:
  3. nextcloud:
  4. enabled: true
  5. primary: true
  6. type: Deployment
  7. podSpec:
  8. hostNetwork: false
  9. securityContext:
  10. fsGroup: 33
  11. containers:
  12. nextcloud:
  13. enabled: true
  14. primary: true
  15. imageSelector: image
  16. securityContext:
  17. runAsUser: 0
  18. runAsGroup: 0
  19. runAsNonRoot: false
  20. readOnlyRootFilesystem: false
  21. capabilities:
  22. add:
  23. - CHOWN
  24. - DAC_OVERRIDE
  25. - FOWNER
  26. - NET_BIND_SERVICE
  27. - NET_RAW
  28. - SETGID
  29. - SETUID
  30. envFrom:
  31. - secretRef:
  32. name: nextcloud-creds
  33. {{ with .Values.ncConfig.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. port: 80
  45. path: /status.php
  46. httpHeaders:
  47. Host: localhost
  48. readiness:
  49. enabled: true
  50. type: http
  51. port: 80
  52. path: /status.php
  53. httpHeaders:
  54. Host: localhost
  55. startup:
  56. enabled: true
  57. {{- include "nextcloud.validate-commands" $ -}}
  58. {{- $cmds := .Values.ncConfig.commands | mustUniq -}}
  59. {{- if not $cmds }}
  60. type: http
  61. port: 80
  62. path: /status.php
  63. httpHeaders:
  64. Host: localhost
  65. {{- else }}
  66. type: exec
  67. command:
  68. - /bin/sh
  69. - -c
  70. - |
  71. check_commands={{ join " " $cmds }}
  72. for comm in $check_commands; do
  73. if ! command -v $comm /dev/null 2>&1; then
  74. echo "Command $comm not found"
  75. exit 1
  76. fi
  77. done
  78. {{- end }}
  79. lifecycle:
  80. postStart:
  81. type: exec
  82. command:
  83. - /bin/sh
  84. - -c
  85. - |
  86. echo "Installing {{ join " " $cmds }}..."
  87. apt update && apt install -y --no-install-recommends \
  88. {{ join " " $cmds }} || echo "Failed to install binary/binaries..."
  89. echo "Finished."
  90. initContainers:
  91. {{- include "ix.v1.common.app.postgresWait" (dict "name" "postgres-wait"
  92. "secretName" "postgres-creds") | nindent 8 }}
  93. {{- include "ix.v1.common.app.redisWait" (dict "name" "redis-wait"
  94. "secretName" "redis-creds") | nindent 8 }}
  95. {{- end -}}
  96. {{- define "nextcloud.validate-commands" -}}
  97. {{- $allowedCommmads := list "ffmpeg" "smbclient" -}}
  98. {{- range $c := .Values.ncConfig.commands | mustUniq -}}
  99. {{- if not (mustHas $c $allowedCommmads) -}}
  100. {{- fail (printf "Nextcloud - Expected command to be one of [%s], but got [%s]" (join ", " $allowedCommmads) $c) -}}
  101. {{- end -}}
  102. {{- end -}}
  103. {{- end -}}