Skip to content

Commit

Permalink
feat(gcloud-sqlproxy): support cloudproxysql v2 (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
mclavel authored Aug 7, 2023
1 parent 67e7d5d commit 7c9d9cf
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 29 deletions.
4 changes: 2 additions & 2 deletions stable/gcloud-sqlproxy/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
appVersion: 1.33.4
appVersion: 2.6.0
description: Google Cloud SQL Proxy
engine: gotpl
home: https://cloud.google.com/sql/docs/postgres/sql-proxy
Expand All @@ -19,4 +19,4 @@ name: gcloud-sqlproxy
sources:
- https://github.com/rimusz/charts
type: application
version: 0.24.2
version: 0.25.0
21 changes: 16 additions & 5 deletions stable/gcloud-sqlproxy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,31 +104,38 @@ The following table lists the configurable parameters of the `gcloud-sqlproxy` c
| `extraFlags` | Additional container flags | `[]` |
| `podSecurityContext` | Configure Pod Security Context | `{}` |
| `containerSecurityContext` | Configure Container Security Context | `{}` |
| `httpPortProbe` | The port to check liveness, readiness & startup probe | 9090 |
| `livenessProbe.enabled` | Would you like a livenessProbe to be enabled | `false` |
| `livenessProbe.port` | The port which will be checked by the probe | 5432 |
| `livenessProbe.port` | The port which will be checked by the probe | 9090 |
| `livenessProbe.initialDelaySeconds` | Delay before liveness probe is initiated | 30 |
| `livenessProbe.periodSeconds` | How often to perform the probe | 10 |
| `livenessProbe.timeoutSeconds` | When the probe times out | 5 |
| `livenessProbe.failureThreshold` | Minimum consecutive failures for the probe to be considered failed after having succeeded. | 18 |
| `livenessProbe.successThreshold` | Minimum consecutive successes for the probe to be considered successful after having failed | 1 |
| `readinessProbe.enabled` | would you like a readinessProbe to be enabled | `false` |
| `readinessProbe.port` | The port which will be checked by the probe | 5432 |
| `readinessProbe.port` | The port which will be checked by the probe | 9090 |
| `readinessProbe.initialDelaySeconds` | Delay before readiness probe is initiated | 5 |
| `readinessProbe.periodSeconds` | How often to perform the probe | 10 |
| `readinessProbe.timeoutSeconds` | When the probe times out | 5 |
| `readinessProbe.failureThreshold` | Minimum consecutive failures for the probe to be considered failed after having succeeded. | 6 |
| `readinessProbe.successThreshold` | Minimum consecutive successes for the probe to be considered successful after having failed | 1 |
| `startupProbe.enabled` | would you like a startupProbe to be enabled | `false` |
| `startupProbe.port` | The port which will be checked by the probe | 9090 |
| `startupProbe.initialDelaySeconds` | Delay before startup probe is initiated | 5 |
| `startupProbe.periodSeconds` | How often to perform the probe | 10 |
| `startupProbe.timeoutSeconds` | When the probe times out | 5 |
| `startupProbe.failureThreshold` | Minimum consecutive failures for the probe to be considered failed after having succeeded. | 1 |
| `startupProbe.successThreshold` | Minimum consecutive successes for the probe to be considered successful after having failed | 1 |
| `useStatefulset` | Deploy as a statefulset rather than a deployment | false |
| `httpReadinessProbe.enabled` | Enables http readiness probe | `false` |
| `httpReadinessProbe.port` | Overrides the default http port | 8090 |
| `httpLivenessProbe.enabled` | Enables http liveness probe | `false` |
| `httpLivenessProbe.port` | Overrides the default http port | 8090 |
| `httpStartupProbe.enabled` | Enables http startup probe | `false` |
| `topologySpreadConstraints` | List of TopologySpreadConstraints | `[]` |


Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`.

The `extraArgs` can be provided via dot notation, e.g. `--set extraArgs.log_debug_stdout=true` passes `--log_debug_stdout=true` to the SQL Proxy command.
The `extraArgs` can be provided via dot notation, e.g. `--set extraArgs.admin-port=8091` passes `--admin-port=8091` to the SQL Proxy command.

Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example,

Expand All @@ -154,6 +161,10 @@ GCP does not support more than 5 endpoints on an Internal Load Balancer. To work

## Upgrading

**From <= 0.24.2 to >= 0.25.0**

Please note, as of `0.25.0` use [cloud-sql-proxy v2](https://github.com/GoogleCloudPlatform/cloud-sql-proxy/blob/main/migration-guide.md). The `httpPortProbe` replaced `httpLivenessProbe.port` & `httpReadinessProbe.port`.

**From <= 0.22.2 to >= 0.23.0**

Please note, the `securityContext` has been renamed into `podSecurityContext`.
Expand Down
44 changes: 30 additions & 14 deletions stable/gcloud-sqlproxy/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,26 @@ spec:
{{- end }}
resources:
{{ toYaml .Values.resources | indent 10 }}
command:
- /cloud_sql_proxy
{{- if .Values.httpLivenessProbe.enabled }}
- -use_http_health_check
{{- if ne (int .Values.httpLivenessProbe.port) 8090 }}
- -health_check_port={{ .Values.httpLivenessProbe.port }}
args:
- {{- range .Values.cloudsql.instances }}
{{ .project }}:{{ .region }}:{{ .instance }}?port={{ .port }}&address=0.0.0.0
{{- end }}
- --http-address=0.0.0.0
{{- if or .Values.httpLivenessProbe.enabled .Values.httpReadinessProbe.enabled .Values.httpStartupProbe.enabled }}
- --health-check
{{- if ne (int .Values.httpPortProbe) 9090 }}
- --http-port={{ .Values.httpPortProbe }}
{{- end }}
{{- end }}
- --dir=/cloudsql
- -instances={{- range .Values.cloudsql.instances -}}
{{ .project }}:{{ .region }}:{{ .instance }}=tcp:0.0.0.0:{{ .port }},
{{- end }}
- --unix-socket=/cloudsql
{{ if $hasCredentials -}}
- -credential_file=/secrets/cloudsql/{{ include "gcloud-sqlproxy.secretKey" . }}
- --credentials-file=/secrets/cloudsql/{{ include "gcloud-sqlproxy.secretKey" . }}
{{ end -}}
{{- range $key, $value := .Values.extraArgs }}
- --{{ $key }}={{ $value }}
{{- end }}
{{- range .Values.extraFlags }}
- -{{ . }}
- --{{ . }}
{{- end }}
{{- if .Values.env }}
env:
Expand All @@ -98,7 +98,7 @@ spec:
{{- if .Values.httpLivenessProbe.enabled }}
httpGet:
path: /liveness
port: {{ .Values.httpLivenessProbe.port }}
port: {{ .Values.httpPortProbe }}
{{- else }}
tcpSocket:
port: {{ .Values.livenessProbe.port }}
Expand All @@ -114,7 +114,7 @@ spec:
{{- if .Values.httpReadinessProbe.enabled }}
httpGet:
path: /readiness
port: {{ .Values.httpReadinessProbe.port }}
port: {{ .Values.httpPortProbe }}
{{- else }}
tcpSocket:
port: {{ .Values.readinessProbe.port }}
Expand All @@ -125,6 +125,22 @@ spec:
successThreshold: {{ .Values.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
{{- end }}
{{- if .Values.startupProbe.enabled }}
startupProbe:
{{- if .Values.httpStartupProbe.enabled }}
httpGet:
path: /startup
port: {{ .Values.httpPortProbe }}
{{- else }}
tcpSocket:
port: {{ .Values.startupProbe.port }}
{{- end }}
initialDelaySeconds: {{ .Values.startupProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.startupProbe.periodSeconds }}
timeoutSeconds: {{ .Values.startupProbe.timeoutSeconds }}
successThreshold: {{ .Values.startupProbe.successThreshold }}
failureThreshold: {{ .Values.startupProbe.failureThreshold }}
{{- end }}
volumeMounts:
{{ if $hasCredentials -}}
- name: cloudsql-oauth-credentials
Expand Down
30 changes: 22 additions & 8 deletions stable/gcloud-sqlproxy/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## ref: https://cloud.google.com/sql/docs/mysql/sql-proxy
## ref: https://cloud.google.com/sql/docs/postgres/sql-proxy
image:
repository: gcr.io/cloudsql-docker/gce-proxy
repository: gcr.io/cloud-sql-connectors/cloud-sql-proxy
# Note that by default we use appVersion to get image tag
# tag:
## Specify a imagePullPolicy
Expand Down Expand Up @@ -116,35 +116,48 @@ resources: {}
# memory: 256Mi
# cpu: 256m

# Port to check liveness, readiness & startup
httpPortProbe: 9090

livenessProbe:
enabled: false
port: 5432
port: 9090
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 18
successThreshold: 1


# Http Liveness Probe if enabled will override default tcp port check
httpLivenessProbe:
enabled: false
port: 8090

# Http Readiness Probe if enabled will override default tcp port check
httpReadinessProbe:
enabled: false
port: 8090

readinessProbe:
enabled: false
port: 5432
port: 9090
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 6
successThreshold: 1

# Http Startup Probe if enabled will override default tcp port check
httpStartupProbe:
enabled: false

startupProbe:
enabled: false
port: 9090
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 1

## Configure a HorizontalPodAutoscaler for pod autoscaling.
## Requires that resources requests are set above.
autoscaling:
Expand Down Expand Up @@ -209,12 +222,13 @@ podDisruptionBudget: |
## Additional container arguments
## Uncomment the term_timeout line for the proxy to wait your chosen time before terminating connections
extraArgs: {}
# term_timeout: 30s
# admin-port: 8091

## Additional container flags (single-hypen '-' arguments)
## Uncomment the log_debug_stdout line if you don't want connection-related messages to log as errors
extraFlags: []
# - log_debug_stdout
# - private-ip
# - run-connection-test

topologySpreadConstraints: []
## e.g.
Expand Down

0 comments on commit 7c9d9cf

Please sign in to comment.