deployment.yaml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. {{ if .Values.hostNetwork }}
  33. hostNetwork: true
  34. dnsPolicy: ClusterFirstWithHostNet
  35. {{ else }}
  36. hostNetwork: false
  37. dnsPolicy: ClusterFirst
  38. {{ end }}
  39. initContainers:
  40. - name: init-postgresdb
  41. image: {{ template "postgres.imageName" . }}
  42. command: ['sh', '-c', "until pg_isready -h {{ template "common.names.fullname" $postgres_values }}; do echo waiting for postgres; sleep 2; done"]
  43. imagePullPolicy: {{ .Values.image.pullPolicy }}
  44. - name: init-configs
  45. image: "alpine:latest"
  46. imagePullPolicy: {{ .Values.image.pullPolicy }}
  47. command:
  48. - "sh"
  49. - "/config/init/init.sh"
  50. env:
  51. {{ $envList := (default list .Values.environmentVariables) }}
  52. {{ $envList = mustAppend $envList (dict "name" "POSTGRES_HOST" "value" (printf "%s:5432" (include "common.names.fullname" $postgres_values))) }}
  53. {{ $envList = mustAppend $envList (dict "name" "POSTGRES_DB" "value" (include "postgres.DatabaseName" .)) }}
  54. {{ $envList = mustAppend $envList (dict "name" "POSTGRES_USER" "valueFromSecret" true "secretName" "db-details" "secretKey" "db-user")}}
  55. {{ $envList = mustAppend $envList (dict "name" "POSTGRES_PASSWORD" "valueFromSecret" true "secretName" "db-details" "secretKey" "db-password")}}
  56. {{ include "common.containers.environmentVariables" (dict "environmentVariables" $envList) | nindent 12 }}
  57. volumeMounts: {{ include "common.storage.configureAppVolumeMountsInContainer" .Values | nindent 12 }}
  58. - name: initial-config-script
  59. mountPath: /config/init
  60. containers:
  61. - name: {{ .Chart.Name }}
  62. {{ include "common.resources.limitation" . | nindent 10 }}
  63. {{ include "common.containers.imageConfig" .Values.image | nindent 10 }}
  64. volumeMounts: {{ include "common.storage.configureAppVolumeMountsInContainer" .Values | nindent 12 }}
  65. {{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }}
  66. - name: extrappvolume-{{ $index }}
  67. mountPath: {{ $hostPathConfiguration.mountPath }}
  68. {{ end }}
  69. ports:
  70. - name: web
  71. containerPort: 8123
  72. {{- if not .Values.hostNetwork }}
  73. hostPort: null
  74. {{- end }}
  75. readinessProbe:
  76. tcpSocket:
  77. port: 8123
  78. initialDelaySeconds: 10
  79. periodSeconds: 10
  80. timeoutSeconds: 5
  81. failureThreshold: 5
  82. successThreshold: 2
  83. livenessProbe:
  84. tcpSocket:
  85. port: 8123
  86. initialDelaySeconds: 10
  87. periodSeconds: 10
  88. timeoutSeconds: 5
  89. failureThreshold: 5
  90. successThreshold: 1
  91. startupProbe:
  92. tcpSocket:
  93. port: 8123
  94. initialDelaySeconds: 10
  95. periodSeconds: 5
  96. timeoutSeconds: 2
  97. failureThreshold: 60
  98. successThreshold: 1
  99. env:
  100. {{ $databaseName := (include "postgres.DatabaseName" .)}}
  101. {{ $envList := (default list .Values.environmentVariables) }}
  102. {{ $envList = mustAppend $envList (dict "name" "PUID" "value" .Values.ownerUID) }}
  103. {{ $envList = mustAppend $envList (dict "name" "PGID" "value" .Values.ownerGID) }}
  104. {{ $envList = mustAppend $envList (dict "name" "TZ" "value" .Values.timezone) }}
  105. {{ include "common.containers.environmentVariables" (dict "environmentVariables" $envList) | nindent 12 }}
  106. {{ include "common.networking.dnsConfiguration" .Values | nindent 6 }}
  107. volumes: {{ include "common.storage.configureAppVolumes" .Values | nindent 8 }}
  108. - name: initial-config-script
  109. configMap:
  110. defaultMode: 0700
  111. name: "home-assistance-initial-script-configmap"
  112. {{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }}
  113. - name: extrappvolume-{{ $index }}
  114. hostPath:
  115. path: {{ $hostPathConfiguration.hostPath }}
  116. {{ end }}