Skip to content

Commit 0c0b364

Browse files
authored
Merge pull request #208 from bcgov/chore/database-migration
Chore/database migration
2 parents e249920 + 0bad2ee commit 0c0b364

15 files changed

Lines changed: 149 additions & 18 deletions

File tree

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
context: .
5353
dockerfile_path: Dockerfile
5454
github_token: ${{ secrets.GITHUB_TOKEN }}
55-
chart_version: 2.0.20
55+
chart_version: 2.1.0
5656
is_chart_release: true
5757
cas-airflow-dag-trigger-build:
5858
needs: [release]

deploy.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ set -euo pipefail
77
git_sha1=$(git rev-parse HEAD)
88

99
helm dep up ./helm/cas-airflow
10+
helm repo add cas-postgres https://bcgov.github.io/cas-postgres/
11+
helm repo update
12+
13+
helm upgrade --install \
14+
-f ./helm/cas-airflow-postgres-cluster/values.yaml \
15+
-f "./helm/cas-airflow/values-$ENVIRONMENT.yaml" \
16+
cas-airflow-db cas-postgres/cas-postgres-cluster
17+
1018
helm upgrade --install --timeout 900s \
1119
--namespace "$AIRFLOW_NAMESPACE_PREFIX-$ENVIRONMENT" \
1220
-f ./helm/cas-airflow/values.yaml \
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
environment: dev
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
environment: prod
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
environment: test
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Values file to be passed to a deployment of https://github.com/bcgov/cas-postgres/tree/develop/helm/cas-postgres-cluster
2+
3+
# dev, test, prod
4+
environment: ~
5+
6+
postgresCluster:
7+
postgresVersion: 17
8+
postgres:
9+
replicaCount: 3
10+
pgbouncer:
11+
replicaCount: 2
12+
resources:
13+
requests:
14+
cpu: 100m
15+
memory: 256Mi
16+
17+
# The "users" value(s) is passed to the crunch postgres operator to create the database.
18+
# See http://access.crunchydata.com/documentation/postgres-operator/latest/tutorials/basic-setup/user-management
19+
users:
20+
- name: postgres
21+
options: "SUPERUSER"
22+
databases:
23+
- postgres
24+
- name: airflow
25+
databases:
26+
- postgres
27+
28+
gcsBackups:
29+
enable: true
30+
# Needs to match the "namespace_apps" value in the terraform provisioning chart.
31+
# example syntax: bucketName
32+
bucketName: af-pgo-backups
33+
34+
terraform-bucket-provision:
35+
terraform:
36+
# example syntax: '["bucketName"]'
37+
namespace_apps: '["af-pgo-backups"]'
38+
# !important: unique for the deployment
39+
workspace: airflow-pgo
40+
41+
# To configure a KNP allowing external access, for metabase for example
42+
external-access:
43+
enabled: false

helm/cas-airflow/Chart.lock

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@ dependencies:
88
- name: terraform-bucket-provision
99
repository: https://bcgov.github.io/cas-pipeline/
1010
version: 0.1.3
11-
digest: sha256:fa547b34056cf2431a0354054e48b4efeefc39cd74be257e4e6a64b14cc9174e
12-
generated: "2024-11-15T13:11:12.776004708-08:00"
11+
- name: patroni-migration
12+
repository: https://bcgov.github.io/cas-postgres/
13+
version: 1.0.1
14+
digest: sha256:164d57773acfb1c55c545e2bede23068136614ae2a2a52b9bf8d26bacd375914
15+
generated: "2025-05-13T08:52:20.688824737-06:00"

helm/cas-airflow/Chart.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v2
22
name: cas-airflow
33
type: application
4-
version: 2.0.20 # Changing this requires updating the image tag in .github/workflows/release.yaml
4+
version: 2.1.0 # Changing this requires updating the image tag in .github/workflows/release.yaml
55
appVersion: 2.10.5 # The airflow version
66
description: Helm chart to deploy cas' flavour of airflow, compatible with OpenShift 4. This chart uses the vanilla airflow chart and adds cas' own templates and values.
77
icon: https://www.astronomer.io/static/airflowNewA.png
@@ -20,3 +20,6 @@ dependencies:
2020
- name: terraform-bucket-provision
2121
version: "0.1.3"
2222
repository: https://bcgov.github.io/cas-pipeline/
23+
- name: patroni-migration
24+
version: 1.0.1
25+
repository: https://bcgov.github.io/cas-postgres/
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
kind: NetworkPolicy
2+
apiVersion: networking.k8s.io/v1
3+
metadata:
4+
name: {{ include "cas-airflow.fullname" . }}-postgres-cluster-access
5+
labels: {{ include "cas-airflow.labels" . | nindent 4 }}
6+
spec:
7+
podSelector:
8+
matchLabels:
9+
app.kubernetes.io/instance: {{ .Values.database.clusterReleaseName }}
10+
ingress:
11+
- from:
12+
- podSelector:
13+
matchLabels:
14+
release: {{ include "cas-airflow.name" . }}
15+
- podSelector:
16+
matchLabels:
17+
app.kubernetes.io/instance: {{ include "cas-airflow.name" . }}
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
################################
22
## Airflow Metadata Secret
33
#################################
4-
{{- $postgresHost := (printf "%s-%s.%s.svc.cluster.local" .Release.Name "patroni" .Release.Namespace) }}
5-
{{- $host := $postgresHost }}
6-
{{- $port := .Values.airflow.data.metadataConnection.port | toString }}
7-
{{- $database := .Values.airflow.data.metadataConnection.db }}
4+
## Uses the PGBOUNCER_URI environment variable to connect to the database, which ensures characters are URI encoded
5+
#################################
86

97
kind: Secret
108
apiVersion: v1
@@ -16,4 +14,4 @@ metadata:
1614
{{ include "cas-airflow.labels" $ | nindent 4 }}
1715
type: Opaque
1816
data:
19-
connection: {{ (printf "postgresql://%s:%s@%s:%s/%s?sslmode=%s" .Values.airflow.data.metadataConnection.user .Values.airflow.data.metadataConnection.pass $host $port $database .Values.airflow.data.metadataConnection.sslmode) | b64enc | quote }}
17+
connection: {{ (printf "$PGBOUNCER_URI?sslmode=%s" .Values.airflow.data.metadataConnection.sslmode) | b64enc | quote }}

0 commit comments

Comments
 (0)