diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index ae942ed6..5a4e928d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -3,7 +3,7 @@ on: push: branches: - main - - PH-52/* + - 85-* - PH-47/* - PH-54/* - PH-79/* diff --git a/helm/pharos/Chart.yaml b/helm/pharos/Chart.yaml index 5106cb13..a2d7bea7 100644 --- a/helm/pharos/Chart.yaml +++ b/helm/pharos/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: pharos version: 0.0.1 description: Helm chart for pharos -appVersion: 0.0.1-testtesttesttesttesttesttesttesttesttesttesttesttest1234567890 +appVersion: 0.0.1 dependencies: - name: redis alias: redis diff --git a/helm/pharos/templates/secret-postgres.yaml b/helm/pharos/templates/secret-postgres.yaml new file mode 100644 index 00000000..6f32f227 --- /dev/null +++ b/helm/pharos/templates/secret-postgres.yaml @@ -0,0 +1,30 @@ +{{- if .Values.postgres.auth.generateSecret }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Values.postgres.auth.existingSecret }} + labels: + {{- include "pharos.labels" . | nindent 4 }} +type: Opaque +data: + {{- /* Define $postgresPassword outside the if/else blocks so it's available throughout the template */ -}} + {{- $postgresPassword := "" }} + {{- $secret := (lookup "v1" "Secret" .Release.Namespace .Values.postgres.auth.existingSecret) }} + {{- if $secret }} + {{- $postgresPassword = index $secret.data "password" }} + {{- else }} + {{- $postgresPassword = randAlphaNum 16 }} + {{- end }} + {{- $postgresUsername := "pharos" }} + {{- $postgresPort := "5432" }} + {{- $postgresEndpoint := printf "%s-postgres.%s.svc.cluster.local" .Release.Name .Release.Namespace }} + {{- $postgresDSN := printf "postgres://%s:%s@%s:%s/%s?sslmode=disable" $postgresUsername $postgresPassword $postgresEndpoint $postgresPort $postgresUsername }} + + # Store the generated values + postgres-password: {{ $postgresPassword | b64enc }} + password: {{ $postgresPassword | b64enc }} + username: {{ $postgresUsername | b64enc }} + port: {{ $postgresPort | b64enc }} + endpoint: {{ $postgresEndpoint | b64enc }} + dsn: {{ $postgresDSN | b64enc }} +{{- end }} diff --git a/helm/pharos/values.yaml b/helm/pharos/values.yaml index 990331d8..49e729d6 100644 --- a/helm/pharos/values.yaml +++ b/helm/pharos/values.yaml @@ -54,7 +54,13 @@ postgres: # -- Enable PostgreSQL deployment enabled: true # -- PostgreSQL authentication + + passwordUpdateJob: + enabled: true + auth: + # -- Generate a secret for PostgreSQL connection + generateSecret: true # -- Use an existing secret for PostgreSQL connection existingSecret: "postgres-connection" primary: