_postgres.tpl 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. {{- define "postgres.imageName" -}}
  2. {{- print "postgres:14.5" -}}
  3. {{- end -}}
  4. {{- define "postgres.nameSuffix" -}}
  5. {{- print "postgres" -}}
  6. {{- end -}}
  7. {{- define "postgres.secretName" -}}
  8. {{- print "postgres-details" -}}
  9. {{- end -}}
  10. {{- define "postgres.dbName" -}}
  11. {{- print "logsearchapi" -}}
  12. {{- end -}}
  13. {{- define "postgres.dbUser" -}}
  14. {{- print "logsearchapi" -}}
  15. {{- end -}}
  16. {{/*
  17. Retrieve postgres backup name
  18. This will return a unique name based on revision and chart numbers specified.
  19. */}}
  20. {{- define "postgres.backupName" -}}
  21. {{- $upgradeDict := .Values.ixChartContext.upgradeMetadata -}}
  22. {{- printf "postgres-backup-from-%s-to-%s-revision-%d" $upgradeDict.oldChartVersion $upgradeDict.newChartVersion (int64 $upgradeDict.preUpgradeRevision) -}}
  23. {{- end -}}
  24. {{- define "postgres.envVariableConfiguration" -}}
  25. {{- $envList := list -}}
  26. {{- $secretName := (include "postgres.secretName" .) -}}
  27. {{- $envList = mustAppend $envList (dict "name" "POSTGRES_USER" "valueFromSecret" true "secretName" $secretName "secretKey" "db_user") -}}
  28. {{- $envList = mustAppend $envList (dict "name" "POSTGRES_DB" "valueFromSecret" true "secretName" $secretName "secretKey" "db_name") -}}
  29. {{- $envList = mustAppend $envList (dict "name" "POSTGRES_PASSWORD" "valueFromSecret" true "secretName" $secretName "secretKey" "db_password") -}}
  30. {{- include "common.containers.environmentVariables" (dict "environmentVariables" $envList) -}}
  31. {{- end -}}
  32. {{- define "postgresBackup.envVariableConfiguration" -}}
  33. {{- $envList := list -}}
  34. {{- $secretName := (include "postgres.secretName" .) -}}
  35. {{- $envList = mustAppend $envList (dict "name" "POSTGRES_USER" "valueFromSecret" true "secretName" $secretName "secretKey" "db_user") -}}
  36. {{- $envList = mustAppend $envList (dict "name" "POSTGRES_DB" "valueFromSecret" true "secretName" $secretName "secretKey" "db_name") -}}
  37. {{/* PGPASSWORD is used by pg_dump */}}
  38. {{- $envList = mustAppend $envList (dict "name" "PGPASSWORD" "valueFromSecret" true "secretName" $secretName "secretKey" "db_password") -}}
  39. {{- $envList = mustAppend $envList (dict "name" "pgHost" "valueFromSecret" true "secretName" $secretName "secretKey" "postgresHost") -}}
  40. {{- include "common.containers.environmentVariables" (dict "environmentVariables" $envList) -}}
  41. {{- end -}}
  42. {{/* Used in the logsearchapi init container (checks that postgres is available) */}}
  43. {{- define "postgresInit.envVariableConfiguration" -}}
  44. {{- $envList := list -}}
  45. {{- $secretName := (include "postgres.secretName" .) -}}
  46. {{- $envList = mustAppend $envList (dict "name" "pgHost" "valueFromSecret" true "secretName" $secretName "secretKey" "postgresHost") -}}
  47. {{- $envList = mustAppend $envList (dict "name" "pguser" "valueFromSecret" true "secretName" $secretName "secretKey" "db_user") -}}
  48. {{- include "common.containers.environmentVariables" (dict "environmentVariables" $envList) -}}
  49. {{- end -}}
  50. {{/*
  51. Retrieve postgres volume configuration
  52. */}}
  53. {{- define "postgres.volumeConfiguration" -}}
  54. {{ include "common.storage.configureAppVolumes" (dict "appVolumeMounts" .Values.postgresAppVolumeMounts "emptyDirVolumes" .Values.emptyDirVolumes "ixVolumes" .Values.ixVolumes) | nindent 0 }}
  55. {{- end -}}
  56. {{/*
  57. Retrieve postgres volume mounts configuration
  58. */}}
  59. {{- define "postgres.volumeMountsConfiguration" -}}
  60. {{ include "common.storage.configureAppVolumeMountsInContainer" (dict "appVolumeMounts" .Values.postgresAppVolumeMounts ) | nindent 0 }}
  61. {{- end -}}