deployment.yaml 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. {{ include "common.storage.hostPathValidate" .Values }}
  2. {{ $postgres_values := (. | mustDeepCopy) }}
  3. {{ $_ := set $postgres_values "common" (dict "nameSuffix" "postgres") }}
  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. hostNetwork: {{ .Values.hostNetwork }}
  33. initContainers:
  34. - name: init-postgresdb
  35. image: {{ template "postgres.imageName" . }}
  36. command: ['sh', '-c', "until pg_isready -h {{ template "common.names.fullname" $postgres_values }}; do echo waiting for postgres; sleep 2; done"]
  37. imagePullPolicy: {{ .Values.image.pullPolicy }}
  38. - name: init-configs
  39. image: "alpine:latest"
  40. imagePullPolicy: {{ .Values.image.pullPolicy }}
  41. command:
  42. - "sh"
  43. - "/config/init/init.sh"
  44. env:
  45. {{ $envList := (default list .Values.environmentVariables) }}
  46. {{ $envList = mustAppend $envList (dict "name" "POSTGRES_HOST" "value" (printf "%s:5432" (include "common.names.fullname" $postgres_values))) }}
  47. {{ $envList = mustAppend $envList (dict "name" "POSTGRES_DB" "value" (include "postgres.DatabaseName" .)) }}
  48. {{ $envList = mustAppend $envList (dict "name" "POSTGRES_USER" "valueFromSecret" true "secretName" "db-details" "secretKey" "db-user")}}
  49. {{ $envList = mustAppend $envList (dict "name" "POSTGRES_PASSWORD" "valueFromSecret" true "secretName" "db-details" "secretKey" "db-password")}}
  50. {{ include "common.containers.environmentVariables" (dict "environmentVariables" $envList) | nindent 12 }}
  51. volumeMounts: {{ include "common.storage.configureAppVolumeMountsInContainer" .Values | nindent 12 }}
  52. - name: initial-config-script
  53. mountPath: /config/init
  54. containers:
  55. - name: {{ .Chart.Name }}
  56. {{ include "common.resources.limitation" . | nindent 10 }}
  57. {{ include "common.containers.imageConfig" .Values.image | nindent 10 }}
  58. volumeMounts: {{ include "common.storage.configureAppVolumeMountsInContainer" .Values | nindent 12 }}
  59. {{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }}
  60. - name: extrappvolume-{{ $index }}
  61. mountPath: {{ $hostPathConfiguration.mountPath }}
  62. {{ end }}
  63. ports:
  64. - name: web
  65. containerPort: 8123
  66. env:
  67. {{ $databaseName := (include "postgres.DatabaseName" .)}}
  68. {{ $envList := (default list .Values.environmentVariables) }}
  69. {{ $envList = mustAppend $envList (dict "name" "PUID" "value" .Values.ownerUID) }}
  70. {{ $envList = mustAppend $envList (dict "name" "PGID" "value" .Values.ownerGID) }}
  71. {{ $envList = mustAppend $envList (dict "name" "TZ" "value" .Values.timezone) }}
  72. {{ include "common.containers.environmentVariables" (dict "environmentVariables" $envList) | nindent 12 }}
  73. {{ include "common.networking.dnsConfiguration" .Values | nindent 6 }}
  74. volumes: {{ include "common.storage.configureAppVolumes" .Values | nindent 8 }}
  75. - name: initial-config-script
  76. configMap:
  77. defaultMode: 0700
  78. name: "home-assistance-initial-script-configmap"
  79. {{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }}
  80. - name: extrappvolume-{{ $index }}
  81. hostPath:
  82. path: {{ $hostPathConfiguration.hostPath }}
  83. {{ end }}