deployment.yaml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. readinessProbe:
  67. httpGet:
  68. path: /
  69. port: 8123
  70. initialDelaySeconds: 10
  71. periodSeconds: 10
  72. timeoutSeconds: 5
  73. failureThreshold: 5
  74. successThreshold: 2
  75. livenessProbe:
  76. httpGet:
  77. path: /
  78. port: 8123
  79. initialDelaySeconds: 10
  80. periodSeconds: 10
  81. timeoutSeconds: 5
  82. failureThreshold: 5
  83. successThreshold: 1
  84. startupProbe:
  85. httpGet:
  86. path: /
  87. port: 8123
  88. initialDelaySeconds: 10
  89. periodSeconds: 5
  90. timeoutSeconds: 2
  91. failureThreshold: 60
  92. successThreshold: 1
  93. env:
  94. {{ $databaseName := (include "postgres.DatabaseName" .)}}
  95. {{ $envList := (default list .Values.environmentVariables) }}
  96. {{ $envList = mustAppend $envList (dict "name" "PUID" "value" .Values.ownerUID) }}
  97. {{ $envList = mustAppend $envList (dict "name" "PGID" "value" .Values.ownerGID) }}
  98. {{ $envList = mustAppend $envList (dict "name" "TZ" "value" .Values.timezone) }}
  99. {{ include "common.containers.environmentVariables" (dict "environmentVariables" $envList) | nindent 12 }}
  100. {{ include "common.networking.dnsConfiguration" .Values | nindent 6 }}
  101. volumes: {{ include "common.storage.configureAppVolumes" .Values | nindent 8 }}
  102. - name: initial-config-script
  103. configMap:
  104. defaultMode: 0700
  105. name: "home-assistance-initial-script-configmap"
  106. {{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }}
  107. - name: extrappvolume-{{ $index }}
  108. hostPath:
  109. path: {{ $hostPathConfiguration.hostPath }}
  110. {{ end }}