_unifi.tpl 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. {{- define "unifi.workload" -}}
  2. workload:
  3. unifi:
  4. enabled: true
  5. primary: true
  6. type: Deployment
  7. podSpec:
  8. hostNetwork: {{ .Values.unifiNetwork.hostNetwork }}
  9. containers:
  10. unifi:
  11. enabled: true
  12. primary: true
  13. imageSelector: image
  14. securityContext:
  15. runAsUser: 999
  16. runAsGroup: 999
  17. readOnlyRootFilesystem: false
  18. env:
  19. UNIFI_STDOUT: true
  20. UNIFI_HTTP_PORT: {{ .Values.unifiNetwork.webHttpPort }}
  21. UNIFI_HTTPS_PORT: {{ .Values.unifiNetwork.webHttpsPort }}
  22. PORTAL_HTTP_PORT: {{ .Values.unifiNetwork.portalHttpPort }}
  23. PORTAL_HTTPS_PORT: {{ .Values.unifiNetwork.portalHttpsPort }}
  24. {{- if .Values.unifiNetwork.certificateID }}
  25. CERTNAME: cert.pem
  26. CERT_PRIVATE_NAME: privkey.pem
  27. CERT_IS_CHAIN: true
  28. {{- end }}
  29. {{ with .Values.unifiConfig.additionalEnvs }}
  30. envList:
  31. {{ range $env := . }}
  32. - name: {{ $env.name }}
  33. value: {{ $env.value }}
  34. {{ end }}
  35. {{ end }}
  36. probes:
  37. liveness:
  38. enabled: true
  39. type: exec
  40. command: /usr/local/bin/docker-healthcheck.sh
  41. readiness:
  42. enabled: true
  43. type: exec
  44. command: /usr/local/bin/docker-healthcheck.sh
  45. startup:
  46. enabled: true
  47. type: exec
  48. command: /usr/local/bin/docker-healthcheck.sh
  49. initContainers:
  50. {{- include "ix.v1.common.app.permissions" (dict "containerName" "01-permissions"
  51. "UID" 999
  52. "GID" 999
  53. "mode" "check"
  54. "type" "init") | nindent 8 }}
  55. {{- if .Values.unifiNetwork.certificateID }}
  56. # Unifi chowns the files on startup, and if we mount them directly
  57. # from the secret, it will fail to start. So we make copy.
  58. 02-certs:
  59. enabled: true
  60. type: init
  61. imageSelector: image
  62. securityContext:
  63. runAsUser: 999
  64. runAsGroup: 999
  65. readOnlyRootFilesystem: false
  66. command:
  67. - /bin/sh
  68. - -c
  69. args:
  70. - |
  71. certdir=/unifi/cert
  72. echo "Copying certificates to $certdir"
  73. mkdir -p $certdir
  74. cp --force --verbose /ix/cert/private.key $certdir/privkey.pem
  75. cp --force --verbose /ix/cert/public.crt $certdir/cert.pem
  76. cp --force --verbose /ix/cert/public.crt $certdir/chain.pem
  77. {{- end -}}
  78. {{- end -}}