diff --git a/components/airflow-cnpg-database/configurations/cnpg-cluster.yaml b/components/airflow-cnpg-database/configurations/cnpg-cluster.yaml new file mode 100644 index 0000000..2eb79d2 --- /dev/null +++ b/components/airflow-cnpg-database/configurations/cnpg-cluster.yaml @@ -0,0 +1,8 @@ +--- +nameReference: +- kind: Secret + fieldSpecs: + - path: spec/superuserSecret/name + kind: Cluster + - path: spec/bootstrap/initdb/secret/name + kind: Cluster diff --git a/components/airflow-cnpg-database/kustomization.yaml b/components/airflow-cnpg-database/kustomization.yaml new file mode 100644 index 0000000..456fe83 --- /dev/null +++ b/components/airflow-cnpg-database/kustomization.yaml @@ -0,0 +1,36 @@ +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component + +generatorOptions: + disableNameSuffixHash: true + +configurations: +- ./configurations/cnpg-cluster.yaml + +resources: +- ./resources/airflow-cnpg-cluster.yaml + +secretGenerator: +- name: airflow-postgres-admin + type: Secret + literals: + - username=postgres + - password=NotSoSecret +- name: airflow-postgres-user + type: Secret + literals: + - username=airflow + - password=NotSoSecret +- name: airflow-postgres-connection + type: Secret + literals: + - connection=postgresql://airflow:NotSoSecret@airflow-postgres-rw:5432/airflow + +vars: +- name: AIRFLOW_DATABASE_SERVICE_NAME + objref: + name: airflow-postgres + kind: Cluster + apiVersion: postgresql.cnpg.io/v1 + fieldref: + fieldpath: metadata.name diff --git a/components/airflow-cnpg-database/resources/airflow-cnpg-cluster.yaml b/components/airflow-cnpg-database/resources/airflow-cnpg-cluster.yaml new file mode 100644 index 0000000..a1bc09e --- /dev/null +++ b/components/airflow-cnpg-database/resources/airflow-cnpg-cluster.yaml @@ -0,0 +1,17 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: airflow-postgres +spec: + instances: 3 + primaryUpdateStrategy: unsupervised + superuserSecret: + name: airflow-postgres-admin + bootstrap: + initdb: + database: airflow + owner: airflow + secret: + name: airflow-postgres-user + storage: + size: 2Gi diff --git a/kustomization.yaml b/kustomization.yaml new file mode 100644 index 0000000..2816262 --- /dev/null +++ b/kustomization.yaml @@ -0,0 +1,33 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: airflow + +generatorOptions: + disableNameSuffixHash: true + +resources: +- ./resources/namespace.yaml + +components: +- ./components/airflow-cnpg-database + +secretGenerator: +- name: airflow-webserver-secret-key + type: secret + literals: + - webserver-secret-key=c94b62cffbf4dd1c42747fc65007054432f10c185c5e6160 + +helmCharts: +- name: airflow + repo: https://airflow.apache.org + version: 1.9.0 + releaseName: airflow + namespace: airflow + valuesInline: + postgresql: + enabled: false + pgbouncer: + enabled: true + data: + metadataSecretName: airflow-postgres-connection + webserverSecretKeySecretName: airflow-webserver-secret-key diff --git a/resources/namespace.yaml b/resources/namespace.yaml new file mode 100644 index 0000000..8f9f606 --- /dev/null +++ b/resources/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: airflow