From d99bcf25c42cd1300dd45540c347ad112ee8bd32 Mon Sep 17 00:00:00 2001 From: Tamal Saha Date: Sun, 24 Mar 2024 16:55:45 -0700 Subject: [PATCH] Fix dbgate chart (#958) Signed-off-by: Tamal Saha --- charts/dbgate/README.md | 71 +++++++++++++------------ charts/dbgate/ci/ci-values.yaml | 7 +++ charts/dbgate/templates/deployment.yaml | 18 +++++-- charts/dbgate/values.yaml | 7 +++ 4 files changed, 63 insertions(+), 40 deletions(-) diff --git a/charts/dbgate/README.md b/charts/dbgate/README.md index 36c4a0766..ae30bea83 100644 --- a/charts/dbgate/README.md +++ b/charts/dbgate/README.md @@ -45,41 +45,42 @@ The command removes all the Kubernetes components associated with the chart and The following table lists the configurable parameters of the `dbgate` chart and their default values. -| Parameter | Description | Default | -|--------------------------------|------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------| -| replicaCount | | 1 | -| image.repository | | "dbgate/dbgate" | -| image.pullPolicy | | Always | -| image.tag | Overrides the image tag whose default is the chart appVersion. | "alpine" | -| imagePullSecrets | | [] | -| nameOverride | | "" | -| fullnameOverride | | "" | -| serviceAccount.create | Specifies whether a service account should be created | true | -| serviceAccount.annotations | Annotations to add to the service account | {} | -| serviceAccount.name | The name of the service account to use. If not set and create is true, a name is generated using the fullname template | "" | -| podAnnotations | | {} | -| podSecurityContext | | {} | -| service.type | | ClusterIP | -| service.port | | 80 | -| resources | | {} | -| nodeSelector | | {} | -| tolerations | | [] | -| affinity | | {} | -| namespace.create | | false | -| gateway.className | | "ace" | -| gateway.port | | 8082 | -| gateway.tlsSecretRef.name | | service-presets-cert | -| gateway.tlsSecretRef.namespace | | ace | -| gateway.referenceGrant.create | | true | -| keda.proxyService.namespace | | "keda" | -| keda.proxyService.name | | "keda-add-ons-http-interceptor-proxy" | -| keda.proxyService.port | | 8080 | -| targetPendingRequests | | 200 | -| autoscaling.http.minReplicas | | 0 | -| autoscaling.http.maxReplicas | | 1 | -| app.service.name | | "" | -| app.service.namespace | | "" | -| app.authSecret.name | | "" | +| Parameter | Description | Default | +|--------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------| +| replicaCount | | 1 | +| image.repository | | "dbgate/dbgate" | +| image.pullPolicy | | Always | +| image.tag | Overrides the image tag whose default is the chart appVersion. | "alpine" | +| imagePullSecrets | | [] | +| nameOverride | | "" | +| fullnameOverride | | "" | +| serviceAccount.create | Specifies whether a service account should be created | true | +| serviceAccount.annotations | Annotations to add to the service account | {} | +| serviceAccount.name | The name of the service account to use. If not set and create is true, a name is generated using the fullname template | "" | +| podAnnotations | | {} | +| podSecurityContext | | {} | +| service.type | | ClusterIP | +| service.port | | 80 | +| resources | | {} | +| nodeSelector | | {} | +| tolerations | | [] | +| affinity | | {} | +| namespace.create | | false | +| gateway.className | | "ace" | +| gateway.port | | 8082 | +| gateway.tlsSecretRef.name | | service-presets-cert | +| gateway.tlsSecretRef.namespace | | ace | +| gateway.referenceGrant.create | | true | +| keda.proxyService.namespace | | "keda" | +| keda.proxyService.name | | "keda-add-ons-http-interceptor-proxy" | +| keda.proxyService.port | | 8080 | +| targetPendingRequests | | 200 | +| autoscaling.http.minReplicas | | 0 | +| autoscaling.http.maxReplicas | | 1 | +| app.kind | MicrosoftSQLServer: mssql@dbgate-plugin-mssql MySQL: mysql@dbgate-plugin-mysql MariaDB: mariadb@dbgate-plugin-mysql Postgres: postgres@dbgate-plugin-postgres MongoDB: mongo@dbgate-plugin-mongo Redis: redis@dbgate-plugin-redis | "" | +| app.service.name | | "" | +| app.service.namespace | | "" | +| app.authSecret.name | | "" | Specify each parameter using the `--set key=value[,key=value]` argument to `helm upgrade -i`. For example: diff --git a/charts/dbgate/ci/ci-values.yaml b/charts/dbgate/ci/ci-values.yaml index 91704494c..e86231b47 100644 --- a/charts/dbgate/ci/ci-values.yaml +++ b/charts/dbgate/ci/ci-values.yaml @@ -4,3 +4,10 @@ namespace: # securityContext: # seccompProfile: # type: RuntimeDefault +app: + kind: "Postgres" + service: + name: "pg" + namespace: "demo" + authSecret: + name: "pg-auth" diff --git a/charts/dbgate/templates/deployment.yaml b/charts/dbgate/templates/deployment.yaml index e8dcebffe..5de62d2fc 100644 --- a/charts/dbgate/templates/deployment.yaml +++ b/charts/dbgate/templates/deployment.yaml @@ -1,3 +1,11 @@ +{{ $engines := dict }} +{{ $_ := set $engines "MicrosoftSQLServer" (dict "name" "mssql@dbgate-plugin-mssql") }} +{{ $_ := set $engines "MySQL" (dict "name" "mysql@dbgate-plugin-mysql") }} +{{ $_ := set $engines "MariaDB" (dict "name" "mariadb@dbgate-plugin-mysql") }} +{{ $_ := set $engines "Postgres" (dict "name" "postgres@dbgate-plugin-postgres") }} +{{ $_ := set $engines "MongoDB" (dict "name" "mongo@dbgate-plugin-mongo") }} +{{ $_ := set $engines "Redis" (dict "name" "redis@dbgate-plugin-redis") }} + apiVersion: apps/v1 kind: Deployment metadata: @@ -38,22 +46,22 @@ spec: - name: CONNECTIONS value: "PRIMARY" - name: ENGINE_PRIMARY - value: "postgres@dbgate-plugin-postgres" + value: {{ dig .Values.app.kind "name" "" $engines | quote }} - name: SERVER_PRIMARY - value: "pg-a.app-a.svc" + value: "{{ .Values.app.service.name }}.{{ .Values.app.service.namespace }}.svc" - name: PORT_PRIMARY value: "5432" - name: LABEL_PRIMARY - value: "pg-a" + value: "{{ .Values.app.service.name }}" - name: USER_PRIMARY valueFrom: secretKeyRef: - name: pg-a-auth + name: {{ .Values.app.authSecret.name }} key: username - name: PASSWORD_PRIMARY valueFrom: secretKeyRef: - name: pg-a-auth + name: {{ .Values.app.authSecret.name }} key: password ports: - name: http diff --git a/charts/dbgate/values.yaml b/charts/dbgate/values.yaml index 8475749ec..f98e47d02 100644 --- a/charts/dbgate/values.yaml +++ b/charts/dbgate/values.yaml @@ -107,6 +107,13 @@ autoscaling: # authSecret, Bind CR, HelmRelease CR in same namespace # db could be in cross namespace app: + # MicrosoftSQLServer: mssql@dbgate-plugin-mssql + # MySQL: mysql@dbgate-plugin-mysql + # MariaDB: mariadb@dbgate-plugin-mysql + # Postgres: postgres@dbgate-plugin-postgres + # MongoDB: mongo@dbgate-plugin-mongo + # Redis: redis@dbgate-plugin-redis + kind: "" service: name: "" namespace: ""