From 258df9e6fe21c7d689692a2b8dd2dee4edfd5549 Mon Sep 17 00:00:00 2001 From: pehlicd <65170388+pehlicd@users.noreply.github.com> Date: Sat, 23 Mar 2024 09:21:24 +0100 Subject: [PATCH 1/7] feat: add db pass from secret ability --- charts/keep/Chart.yaml | 2 +- charts/keep/README.md | 35 ++++++++++++++++--------- charts/keep/templates/keep-backend.yaml | 7 +++++ charts/keep/values.yaml | 16 +++++++++-- 4 files changed, 44 insertions(+), 16 deletions(-) diff --git a/charts/keep/Chart.yaml b/charts/keep/Chart.yaml index bcefcd1..1bf14b0 100644 --- a/charts/keep/Chart.yaml +++ b/charts/keep/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: keep -version: 0.0.3 +version: 0.0.4 description: Keep Helm Chart type: application icon: https://platform.keephq.dev/_next/image?url=%2Fkeep.png&w=48&q=75 diff --git a/charts/keep/README.md b/charts/keep/README.md index 0191b21..3dd6fd8 100644 --- a/charts/keep/README.md +++ b/charts/keep/README.md @@ -1,6 +1,6 @@ # keep -![Version: 0.0.3](https://img.shields.io/badge/Version-0.0.3-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.2.1](https://img.shields.io/badge/AppVersion-0.2.1-informational?style=flat-square) +![Version: 0.0.4](https://img.shields.io/badge/Version-0.0.4-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.2.1](https://img.shields.io/badge/AppVersion-0.2.1-informational?style=flat-square) Keep Helm Chart @@ -26,25 +26,34 @@ Keep Helm Chart | backend.autoscaling.maxReplicas | int | `3` | | | backend.autoscaling.minReplicas | int | `1` | | | backend.autoscaling.targetCPUUtilizationPercentage | int | `80` | | +| backend.databasePasswordFromSecret.enabled | bool | `false` | | +| backend.databasePasswordFromSecret.secretKey | string | `""` | | +| backend.databasePasswordFromSecret.secretName | string | `""` | | | backend.enabled | bool | `true` | | | backend.env[0].name | string | `"SECRET_MANAGER_TYPE"` | | | backend.env[0].value | string | `"k8s"` | | +| backend.env[10].name | string | `"PUSHER_HOST"` | | +| backend.env[10].value | string | `"keep-websocket"` | | +| backend.env[11].name | string | `"PUSHER_PORT"` | | +| backend.env[11].value | int | `6001` | | | backend.env[1].name | string | `"PORT"` | | | backend.env[1].value | string | `"8080"` | | | backend.env[2].name | string | `"SECRET_MANAGER_DIRECTORY"` | | | backend.env[2].value | string | `"/state"` | | -| backend.env[3].name | string | `"DATABASE_CONNECTION_STRING"` | | -| backend.env[3].value | string | `"mysql+pymysql://root@keep-database:3306/keep"` | | -| backend.env[4].name | string | `"PUSHER_APP_ID"` | | -| backend.env[4].value | int | `1` | | -| backend.env[5].name | string | `"PUSHER_APP_KEY"` | | -| backend.env[5].value | string | `"keepappkey"` | | -| backend.env[6].name | string | `"PUSHER_APP_SECRET"` | | -| backend.env[6].value | string | `"keepappsecret"` | | -| backend.env[7].name | string | `"PUSHER_HOST"` | | -| backend.env[7].value | string | `"keep-websocket"` | | -| backend.env[8].name | string | `"PUSHER_PORT"` | | -| backend.env[8].value | int | `6001` | | +| backend.env[3].name | string | `"DATABASE_HOST"` | | +| backend.env[3].value | string | `"keep-database"` | | +| backend.env[4].name | string | `"DATABASE_PORT"` | | +| backend.env[4].value | string | `"3306"` | | +| backend.env[5].name | string | `"DATABASE_NAME"` | | +| backend.env[5].value | string | `"keep"` | | +| backend.env[6].name | string | `"DATABASE_USER"` | | +| backend.env[6].value | string | `"root"` | | +| backend.env[7].name | string | `"PUSHER_APP_ID"` | | +| backend.env[7].value | int | `1` | | +| backend.env[8].name | string | `"PUSHER_APP_KEY"` | | +| backend.env[8].value | string | `"keepappkey"` | | +| backend.env[9].name | string | `"PUSHER_APP_SECRET"` | | +| backend.env[9].value | string | `"keepappsecret"` | | | backend.image.pullPolicy | string | `"Always"` | | | backend.image.repository | string | `"us-central1-docker.pkg.dev/keephq/keep/keep-api"` | | | backend.image.tag | string | `"latest"` | | diff --git a/charts/keep/templates/keep-backend.yaml b/charts/keep/templates/keep-backend.yaml index 641e962..d2f1f18 100644 --- a/charts/keep/templates/keep-backend.yaml +++ b/charts/keep/templates/keep-backend.yaml @@ -53,6 +53,13 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace + {{- if .Values.backend.databasePasswordFromSecret.enabled }} + - name: DATABASE_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Values.backend.databasePasswordFromSecret.secretName }} + key: {{ .Values.backend.databasePasswordFromSecret.secretKey }} + {{- end }} volumeMounts: - name: state-volume mountPath: /state diff --git a/charts/keep/values.yaml b/charts/keep/values.yaml index 9450627..50f80df 100644 --- a/charts/keep/values.yaml +++ b/charts/keep/values.yaml @@ -11,6 +11,12 @@ backend: # if true, wait for the database to be ready before starting the API # if you use external database, you can set this to false waitForDatabase: true + # if true, the database password will be read from a secret + # if it is false, the DATABASE_PASSWORD value can be set directly + databasePasswordFromSecret: + enabled: false + secretName: "" + secretKey: "" env: - name: SECRET_MANAGER_TYPE value: k8s @@ -18,8 +24,14 @@ backend: value: "8080" - name: SECRET_MANAGER_DIRECTORY value: /state - - name: DATABASE_CONNECTION_STRING - value: mysql+pymysql://root@keep-database:3306/keep + - name: DATABASE_HOST + value: keep-database + - name: DATABASE_PORT + value: "3306" + - name: DATABASE_NAME + value: keep + - name: DATABASE_USER + value: root - name: PUSHER_APP_ID value: 1 - name: PUSHER_APP_KEY From 96d9ccafb1bfb816c889adca8eca0bb4c72867a5 Mon Sep 17 00:00:00 2001 From: pehlicd <65170388+pehlicd@users.noreply.github.com> Date: Sat, 23 Mar 2024 09:33:00 +0100 Subject: [PATCH 2/7] feat(ci): update ct --- ct.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ct.yaml b/ct.yaml index 156aeee..e4e5e8a 100644 --- a/ct.yaml +++ b/ct.yaml @@ -1,10 +1,8 @@ remote: origin target-branch: main debug: true -check-version-increment: false +check-version-increment: true helm-extra-args: --timeout 15m validate-maintainers: false charts: - charts/keep -chart-repos: - - keep=https://keephq.github.io/helm-charts From 83a5a1dda3d198fae57b145d057503dbd870af96 Mon Sep 17 00:00:00 2001 From: pehlicd <65170388+pehlicd@users.noreply.github.com> Date: Sat, 23 Mar 2024 09:36:29 +0100 Subject: [PATCH 3/7] feat(ci): add lint pr workflow --- .github/workflows/lint-pr.yml | 41 +++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/lint-pr.yml diff --git a/.github/workflows/lint-pr.yml b/.github/workflows/lint-pr.yml new file mode 100644 index 0000000..573eaeb --- /dev/null +++ b/.github/workflows/lint-pr.yml @@ -0,0 +1,41 @@ +name: "Lint PR" + +on: + pull_request_target: + types: + - opened + - edited + - synchronize + +jobs: + main: + name: Validate PR title + runs-on: ubuntu-latest + steps: + - name: lint_pr_title + id: lint_pr_title + uses: amannn/action-semantic-pull-request@v5.1.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: marocchino/sticky-pull-request-comment@v2 + # When the previous steps fails, the workflow would stop. By adding this + # condition you can continue the execution with the populated error message. + if: always() && (steps.lint_pr_title.outputs.error_message != null) + with: + header: pr-title-lint-error + message: | + Hey there and thank you for opening this pull request! 👋🏼 + + We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your proposed title needs to be adjusted. + + Details: + + ``` + ${{ steps.lint_pr_title.outputs.error_message }} + ``` + # Delete a previous comment when the issue has been resolved + - if: ${{ steps.lint_pr_title.outputs.error_message == null }} + uses: marocchino/sticky-pull-request-comment@v2 + with: + header: pr-title-lint-error + delete: true \ No newline at end of file From d34a5bfc2ea7da44b29a0335c30a3d610f46481a Mon Sep 17 00:00:00 2001 From: pehlicd <65170388+pehlicd@users.noreply.github.com> Date: Sat, 23 Mar 2024 09:59:35 +0100 Subject: [PATCH 4/7] feat(ci): update envs --- charts/keep/templates/keep-backend.yaml | 8 ++++---- charts/keep/values.yaml | 16 +++++----------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/charts/keep/templates/keep-backend.yaml b/charts/keep/templates/keep-backend.yaml index d2f1f18..edb9715 100644 --- a/charts/keep/templates/keep-backend.yaml +++ b/charts/keep/templates/keep-backend.yaml @@ -53,12 +53,12 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - {{- if .Values.backend.databasePasswordFromSecret.enabled }} - - name: DATABASE_PASSWORD + {{- if .Values.backend.databaseConnectionStringFromSecret.enabled }} + - name: DATABASE_CONNECTION_STRING valueFrom: secretKeyRef: - name: {{ .Values.backend.databasePasswordFromSecret.secretName }} - key: {{ .Values.backend.databasePasswordFromSecret.secretKey }} + name: {{ .Values.backend.databaseConnectionStringFromSecret.secretName }} + key: {{ .Values.backend.databaseConnectionStringFromSecret.secretKey }} {{- end }} volumeMounts: - name: state-volume diff --git a/charts/keep/values.yaml b/charts/keep/values.yaml index 50f80df..df69a41 100644 --- a/charts/keep/values.yaml +++ b/charts/keep/values.yaml @@ -11,27 +11,21 @@ backend: # if true, wait for the database to be ready before starting the API # if you use external database, you can set this to false waitForDatabase: true - # if true, the database password will be read from a secret - # if it is false, the DATABASE_PASSWORD value can be set directly - databasePasswordFromSecret: + # if true, the database connection string will be read from a secret + # if it is false, the DATABASE_CONNECTION_STRING value can be set directly + databaseConnectionStringFromSecret: enabled: false secretName: "" secretKey: "" env: + - name: DATABASE_CONNECTION_STRING + value: mysql+pymysql://root@keep-database.default.svc.cluster.local:3306/keep - name: SECRET_MANAGER_TYPE value: k8s - name: PORT value: "8080" - name: SECRET_MANAGER_DIRECTORY value: /state - - name: DATABASE_HOST - value: keep-database - - name: DATABASE_PORT - value: "3306" - - name: DATABASE_NAME - value: keep - - name: DATABASE_USER - value: root - name: PUSHER_APP_ID value: 1 - name: PUSHER_APP_KEY From 584806cf4bcaf6e3d692be9934e034c4a26280ee Mon Sep 17 00:00:00 2001 From: pehlicd <65170388+pehlicd@users.noreply.github.com> Date: Sat, 23 Mar 2024 10:28:52 +0100 Subject: [PATCH 5/7] feat: update docs --- .github/workflows/lint-pr.yml | 2 +- charts/keep/README.md | 48 +++++++++++++++-------------------- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/.github/workflows/lint-pr.yml b/.github/workflows/lint-pr.yml index 573eaeb..2d7d611 100644 --- a/.github/workflows/lint-pr.yml +++ b/.github/workflows/lint-pr.yml @@ -38,4 +38,4 @@ jobs: uses: marocchino/sticky-pull-request-comment@v2 with: header: pr-title-lint-error - delete: true \ No newline at end of file + delete: true diff --git a/charts/keep/README.md b/charts/keep/README.md index 3dd6fd8..3fb5d8c 100644 --- a/charts/keep/README.md +++ b/charts/keep/README.md @@ -26,34 +26,28 @@ Keep Helm Chart | backend.autoscaling.maxReplicas | int | `3` | | | backend.autoscaling.minReplicas | int | `1` | | | backend.autoscaling.targetCPUUtilizationPercentage | int | `80` | | -| backend.databasePasswordFromSecret.enabled | bool | `false` | | -| backend.databasePasswordFromSecret.secretKey | string | `""` | | -| backend.databasePasswordFromSecret.secretName | string | `""` | | +| backend.databaseConnectionStringFromSecret.enabled | bool | `false` | | +| backend.databaseConnectionStringFromSecret.secretKey | string | `""` | | +| backend.databaseConnectionStringFromSecret.secretName | string | `""` | | | backend.enabled | bool | `true` | | -| backend.env[0].name | string | `"SECRET_MANAGER_TYPE"` | | -| backend.env[0].value | string | `"k8s"` | | -| backend.env[10].name | string | `"PUSHER_HOST"` | | -| backend.env[10].value | string | `"keep-websocket"` | | -| backend.env[11].name | string | `"PUSHER_PORT"` | | -| backend.env[11].value | int | `6001` | | -| backend.env[1].name | string | `"PORT"` | | -| backend.env[1].value | string | `"8080"` | | -| backend.env[2].name | string | `"SECRET_MANAGER_DIRECTORY"` | | -| backend.env[2].value | string | `"/state"` | | -| backend.env[3].name | string | `"DATABASE_HOST"` | | -| backend.env[3].value | string | `"keep-database"` | | -| backend.env[4].name | string | `"DATABASE_PORT"` | | -| backend.env[4].value | string | `"3306"` | | -| backend.env[5].name | string | `"DATABASE_NAME"` | | -| backend.env[5].value | string | `"keep"` | | -| backend.env[6].name | string | `"DATABASE_USER"` | | -| backend.env[6].value | string | `"root"` | | -| backend.env[7].name | string | `"PUSHER_APP_ID"` | | -| backend.env[7].value | int | `1` | | -| backend.env[8].name | string | `"PUSHER_APP_KEY"` | | -| backend.env[8].value | string | `"keepappkey"` | | -| backend.env[9].name | string | `"PUSHER_APP_SECRET"` | | -| backend.env[9].value | string | `"keepappsecret"` | | +| backend.env[0].name | string | `"DATABASE_CONNECTION_STRING"` | | +| backend.env[0].value | string | `"mysql+pymysql://root@keep-database.default.svc.cluster.local:3306/keep"` | | +| backend.env[1].name | string | `"SECRET_MANAGER_TYPE"` | | +| backend.env[1].value | string | `"k8s"` | | +| backend.env[2].name | string | `"PORT"` | | +| backend.env[2].value | string | `"8080"` | | +| backend.env[3].name | string | `"SECRET_MANAGER_DIRECTORY"` | | +| backend.env[3].value | string | `"/state"` | | +| backend.env[4].name | string | `"PUSHER_APP_ID"` | | +| backend.env[4].value | int | `1` | | +| backend.env[5].name | string | `"PUSHER_APP_KEY"` | | +| backend.env[5].value | string | `"keepappkey"` | | +| backend.env[6].name | string | `"PUSHER_APP_SECRET"` | | +| backend.env[6].value | string | `"keepappsecret"` | | +| backend.env[7].name | string | `"PUSHER_HOST"` | | +| backend.env[7].value | string | `"keep-websocket"` | | +| backend.env[8].name | string | `"PUSHER_PORT"` | | +| backend.env[8].value | int | `6001` | | | backend.image.pullPolicy | string | `"Always"` | | | backend.image.repository | string | `"us-central1-docker.pkg.dev/keephq/keep/keep-api"` | | | backend.image.tag | string | `"latest"` | | From 908b675a42802fee7195c696a17b3b2a6ac83a2c Mon Sep 17 00:00:00 2001 From: pehlicd <65170388+pehlicd@users.noreply.github.com> Date: Sat, 23 Mar 2024 10:52:27 +0100 Subject: [PATCH 6/7] feat: update docs --- charts/keep/README.md | 2 +- charts/keep/values.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/keep/README.md b/charts/keep/README.md index 3fb5d8c..9bacc45 100644 --- a/charts/keep/README.md +++ b/charts/keep/README.md @@ -31,7 +31,7 @@ Keep Helm Chart | backend.databaseConnectionStringFromSecret.secretName | string | `""` | | | backend.enabled | bool | `true` | | | backend.env[0].name | string | `"DATABASE_CONNECTION_STRING"` | | -| backend.env[0].value | string | `"mysql+pymysql://root@keep-database.default.svc.cluster.local:3306/keep"` | | +| backend.env[0].value | string | `"mysql+pymysql://root@keep-database:3306/keep"` | | | backend.env[1].name | string | `"SECRET_MANAGER_TYPE"` | | | backend.env[1].value | string | `"k8s"` | | | backend.env[2].name | string | `"PORT"` | | diff --git a/charts/keep/values.yaml b/charts/keep/values.yaml index df69a41..c92b175 100644 --- a/charts/keep/values.yaml +++ b/charts/keep/values.yaml @@ -19,7 +19,7 @@ backend: secretKey: "" env: - name: DATABASE_CONNECTION_STRING - value: mysql+pymysql://root@keep-database.default.svc.cluster.local:3306/keep + value: mysql+pymysql://root@keep-database:3306/keep - name: SECRET_MANAGER_TYPE value: k8s - name: PORT From bc9b67702e30bd5e3d1e0455ae72ac41d46609a7 Mon Sep 17 00:00:00 2001 From: pehlicd <65170388+pehlicd@users.noreply.github.com> Date: Tue, 26 Mar 2024 17:56:05 +0100 Subject: [PATCH 7/7] fix: fix test error --- charts/keep/templates/keep-db-service.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/keep/templates/keep-db-service.yaml b/charts/keep/templates/keep-db-service.yaml index 38ba5ed..bad6d8f 100644 --- a/charts/keep/templates/keep-db-service.yaml +++ b/charts/keep/templates/keep-db-service.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: Service metadata: - name: {{ include "keep.fullname" . }}-database + name: {{ include "keep.name" . }}-database labels: {{- include "keep.labels" . | nindent 4 }} keep-component: database-service