From 832a4e6d8907052f854f19ff6724d16086bb4a40 Mon Sep 17 00:00:00 2001 From: antonis-snowplow Date: Mon, 28 Oct 2024 18:23:36 +0200 Subject: [PATCH 1/2] Adds hook job for devdb creation in AWS --- .../templates/iglu-hooks.yaml | 53 ++++++++++++++++++- .../snowplow-iglu-server/values-aws.yaml.tmpl | 5 ++ charts/snowplow-iglu-server/values.yaml | 6 +++ 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/charts/snowplow-iglu-server/templates/iglu-hooks.yaml b/charts/snowplow-iglu-server/templates/iglu-hooks.yaml index 76ea37a..19b7f74 100644 --- a/charts/snowplow-iglu-server/templates/iglu-hooks.yaml +++ b/charts/snowplow-iglu-server/templates/iglu-hooks.yaml @@ -101,7 +101,58 @@ spec: - name: "CONFIG_FORCE_iglu_database_dbname" value: "{{ .Values.service.config.database.dbname }}" - name: "CONFIG_FORCE_iglu_database_port" - value: "{{ .Values.service.gcp.proxy.port }}" + value: "{{ .Values.service.config.database.port }}" + envFrom: + - secretRef: + name: {{ include "iglu.app.secret.name" . }} +{{- end }} + +{{- if .Values.service.aws.dev_db }} + +--- + +apiVersion: batch/v1 +kind: Job +metadata: + name: {{ include "iglu.hooks.name" . }}-create-dev-db + labels: + {{- include "snowplow.labels" $ | nindent 4 }} + annotations: + "helm.sh/hook": post-install,post-upgrade + "helm.sh/hook-delete-policy": hook-succeeded,hook-failed + "helm.sh/hook-weight": "1" +spec: + template: + metadata: + name: {{ include "iglu.hooks.name" . }}-create-dev-db + spec: + restartPolicy: Never + containers: + - name: {{ include "iglu.hooks.name" . }}-create-dev-db + image: postgres:15-alpine + imagePullPolicy: Always + command: ["/bin/bash", "-c"] + args: + - | + export PGPASSWORD="${CONFIG_FORCE_iglu_database_admin_password}" + psql -h "${CONFIG_FORCE_iglu_database_host}" \ + -d "${CONFIG_FORCE_iglu_database_prod_dbname}" \ + -U "${CONFIG_FORCE_iglu_database_admin_username}" \ + -p "${CONFIG_FORCE_iglu_database_port}" \ + -c "CREATE DATABASE ${CONFIG_FORCE_iglu_database_dbname};" && echo "OK" + env: + - name: "CONFIG_FORCE_iglu_database_admin_password" + value: "{{ .Values.service.aws.secrets.admin_password }}" + - name: "CONFIG_FORCE_iglu_database_admin_username" + value: "{{ .Values.service.aws.secrets.admin_username }}" + - name: "CONFIG_FORCE_iglu_database_prod_dbname" + value: "{{ .Values.service.aws.prod_dbname }}" + - name: "CONFIG_FORCE_iglu_database_host" + value: "{{ .Values.service.config.database.host }}" + - name: "CONFIG_FORCE_iglu_database_dbname" + value: "{{ .Values.service.config.database.dbname }}" + - name: "CONFIG_FORCE_iglu_database_port" + value: "{{ .Values.service.config.database.port }}" envFrom: - secretRef: name: {{ include "iglu.app.secret.name" . }} diff --git a/charts/snowplow-iglu-server/values-aws.yaml.tmpl b/charts/snowplow-iglu-server/values-aws.yaml.tmpl index e24891a..affc4ff 100644 --- a/charts/snowplow-iglu-server/values-aws.yaml.tmpl +++ b/charts/snowplow-iglu-server/values-aws.yaml.tmpl @@ -32,3 +32,8 @@ service: aws: targetGroupARN: "" + dev_db: "" + prod_dbname: "" + secrets: + admin_username: "" + dev_username "" diff --git a/charts/snowplow-iglu-server/values.yaml b/charts/snowplow-iglu-server/values.yaml index 5cb950d..1eddd8c 100644 --- a/charts/snowplow-iglu-server/values.yaml +++ b/charts/snowplow-iglu-server/values.yaml @@ -85,6 +85,12 @@ service: aws: # -- EC2 TargetGroup ARN to bind the service onto targetGroupARN: "" + # -- Whether we deploy for dev db + dev_db: false + prod_dbname: "" + secrets: + admin_username: "" + dev_username: "" azure: # -- Whether we deploy for dev db From ad2f7844af06c91f007d10737e304edffa8370e0 Mon Sep 17 00:00:00 2001 From: antonis-snowplow Date: Mon, 28 Oct 2024 18:37:23 +0200 Subject: [PATCH 2/2] updates on versioning and minor fixes --- CHANGELOG | 4 ++++ charts/snowplow-iglu-server/Chart.yaml | 2 +- charts/snowplow-iglu-server/README.md | 4 ++++ charts/snowplow-iglu-server/values-aws.yaml.tmpl | 1 - charts/snowplow-iglu-server/values.yaml | 1 - 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 9e5a773..9b8ff96 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +Version 0.1.78 (2024-10-28) +--------------------------- +charts/snowplow-iglu-server: Adds helm hook job to create dev database (closes #205) + Version 0.1.77 (2024-10-25) --------------------------- charts/service-deployment: update hpa to supply metrics object instead of fixed CPU utilization threshold (closes #202) diff --git a/charts/snowplow-iglu-server/Chart.yaml b/charts/snowplow-iglu-server/Chart.yaml index 8e63bfc..adcd54f 100644 --- a/charts/snowplow-iglu-server/Chart.yaml +++ b/charts/snowplow-iglu-server/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v2 name: snowplow-iglu-server description: A Helm Chart to deploy the Snowplow Iglu Server project -version: 0.9.0 +version: 0.10.0 appVersion: "0.12.0" icon: https://raw.githubusercontent.com/snowplow-devops/helm-charts/master/docs/logo/snowplow.png home: https://github.com/snowplow-devops/helm-charts diff --git a/charts/snowplow-iglu-server/README.md b/charts/snowplow-iglu-server/README.md index 2df3662..328df8d 100644 --- a/charts/snowplow-iglu-server/README.md +++ b/charts/snowplow-iglu-server/README.md @@ -122,6 +122,8 @@ When `dev_db` is `true` the hook job `-dev-db-user-setup` will be initiated ### AWS (EKS) settings +When `dev_db` is `true` the hook job `-create-dev-db` will be initiated + #### TargetGroup binding To manage the load balancer externally to the kubernetes cluster you can bind the deployment to an existing TargetGroup ARN. Its important that the TargetGroup exist ahead of time and that you use the same port as you have used in your `values.yaml`. @@ -151,6 +153,8 @@ You will need to fill these targeted fields: | global.labels | object | `{}` | Global labels deployed to all resources deployed by the chart | | service.annotations | object | `{}` | Map of annotations to add to the service | | service.aws.targetGroupARN | string | `""` | EC2 TargetGroup ARN to bind the service onto | +| service.aws.dev_db | bool | `false` | Whether we deploy for dev db in AWS | +| service.aws.secrets.admin_username | string | `""` | The admin username that will be used for the psql command | | service.config.database.dbname | string | `""` | Postgres database name | | service.config.database.host | string | `""` | Postgres database host | | service.config.database.port | int | `5432` | Postgres database port | diff --git a/charts/snowplow-iglu-server/values-aws.yaml.tmpl b/charts/snowplow-iglu-server/values-aws.yaml.tmpl index affc4ff..d05e41f 100644 --- a/charts/snowplow-iglu-server/values-aws.yaml.tmpl +++ b/charts/snowplow-iglu-server/values-aws.yaml.tmpl @@ -36,4 +36,3 @@ service: prod_dbname: "" secrets: admin_username: "" - dev_username "" diff --git a/charts/snowplow-iglu-server/values.yaml b/charts/snowplow-iglu-server/values.yaml index c822991..cf96e73 100644 --- a/charts/snowplow-iglu-server/values.yaml +++ b/charts/snowplow-iglu-server/values.yaml @@ -100,7 +100,6 @@ service: prod_dbname: "" secrets: admin_username: "" - dev_username: "" azure: # -- Whether we deploy for dev db