postgres-deployment.yaml 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. {{ $values := (. | mustDeepCopy) }}
  2. {{ $_ := set $values "common" (dict "nameSuffix" "postgres") }}
  3. {{ include "common.deployment.common_config" $values | nindent 0 }}
  4. spec: {{ include "common.deployment.common_spec" $values | nindent 2 }}
  5. template: {{ include "common.deployment.pod.metadata" $values | nindent 4 }}
  6. spec:
  7. hostNetwork: {{ .Values.hostNetwork }}
  8. containers:
  9. - name: {{ .Chart.Name }}-postgres
  10. image: {{ template "postgres.imageName" . }}
  11. imagePullPolicy: {{ .Values.image.pullPolicy }}
  12. env:
  13. {{ $envList := (default list .Values.environmentVariables) }}
  14. {{ $envList = mustAppend $envList (dict "name" "POSTGRES_DB" "value" (include "postgres.DatabaseName" .)) }}
  15. {{ $envList = mustAppend $envList (dict "name" "POSTGRES_USER" "valueFromSecret" true "secretName" "db-details" "secretKey" "db-user")}}
  16. {{ $envList = mustAppend $envList (dict "name" "POSTGRES_PASSWORD" "valueFromSecret" true "secretName" "db-details" "secretKey" "db-password")}}
  17. {{ include "common.containers.environmentVariables" (dict "environmentVariables" $envList) | nindent 10 }}
  18. volumeMounts: {{ include "postgres.volumeMountsConfiguration" $values | nindent 10 }}
  19. ports:
  20. - name: postgres-tcp
  21. containerPort: 5432
  22. protocol: TCP
  23. readinessProbe:
  24. exec:
  25. command:
  26. - sh
  27. - -c
  28. - "until pg_isready -U ${POSTGRES_USER} -h localhost; do sleep 2; done"
  29. initialDelaySeconds: 10
  30. periodSeconds: 10
  31. timeoutSeconds: 5
  32. failureThreshold: 5
  33. successThreshold: 2
  34. livenessProbe:
  35. exec:
  36. command:
  37. - sh
  38. - -c
  39. - "until pg_isready -U ${POSTGRES_USER} -h localhost; do sleep 2; done"
  40. initialDelaySeconds: 10
  41. periodSeconds: 10
  42. timeoutSeconds: 5
  43. failureThreshold: 5
  44. successThreshold: 1
  45. startupProbe:
  46. exec:
  47. command:
  48. - sh
  49. - -c
  50. - "until pg_isready -U ${POSTGRES_USER} -h localhost; do sleep 2; done"
  51. initialDelaySeconds: 10
  52. periodSeconds: 5
  53. timeoutSeconds: 2
  54. failureThreshold: 60
  55. successThreshold: 1
  56. volumes: {{ include "postgres.volumeConfiguration" $values | nindent 8 }}