File: README.md

package info (click to toggle)
cloudsql-proxy 1.33.14-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 900 kB
  • sloc: sh: 57; makefile: 25
file content (70 lines) | stat: -rw-r--r-- 3,300 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Cloud SQL proxy health checks

Kubernetes supports three types of health checks.
1. Startup probes determine whether a container is done starting up. As soon as this probe succeeds, Kubernetes switches over to using liveness and readiness probing.
2. Liveness probes determine whether a container is healthy. When this probe is unsuccessful, the container is restarted.
3. Readiness probes determine whether a container can serve new traffic. When this probe fails, Kubernetes will wait to send requests to the container.

## Running Cloud SQL proxy with health checks in Kubernetes
1. Configure your Cloud SQL proxy container to include health check probes. 
    > [proxy_with_http_health_check.yaml](proxy_with_http_health_check.yaml#L77-L111)
     ```yaml
        # Recommended configurations for health check probes.
        # Probe parameters can be adjusted to best fit the requirements of your application.
        # For details, see https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/
        livenessProbe:
          httpGet:
            path: /liveness
            port: 8090
          # Number of seconds after the container has started before the first probe is scheduled. Defaults to 0.
          # Not necessary when the startup probe is in use.
          initialDelaySeconds: 0
          # Frequency of the probe. Defaults to 10.
          periodSeconds: 10
          # Number of seconds after which the probe times out. Defaults to 1.
          timeoutSeconds: 5
          # Number of times the probe is allowed to fail before the transition from healthy to failure state. 
          # Defaults to 3.
          failureThreshold: 1
        readinessProbe:
          httpGet:
            path: /readiness
            port: 8090
          initialDelaySeconds: 0
          periodSeconds: 10
          timeoutSeconds: 5
          # Number of times the probe must report success to transition from failure to healthy state.
          # Defaults to 1 for readiness probe.
          successThreshold: 1
          failureThreshold: 1
        startupProbe:
          httpGet:
            path: /startup
            port: 8090
          periodSeconds: 1
          timeoutSeconds: 5
          failureThreshold: 20
     ```

2. Add `-use_http_health_check` and `-health-check-port` (optional) to your proxy container configuration under `command: `.
    > [proxy_with_http_health_check.yaml](proxy_with_http_health_check.yaml#L39-L55)
    ```yaml
        command:
          - "/cloud_sql_proxy"

          # If connecting from a VPC-native GKE cluster, you can use the
          # following flag to have the proxy connect over private IP
          # - "-ip_address_types=PRIVATE"

          # Replace DB_PORT with the port the proxy should listen on
          # Defaults: MySQL: 3306, Postgres: 5432, SQLServer: 1433
          - "-instances=<INSTANCE_CONNECTION_NAME>=tcp:<DB_PORT>"
          # Enables HTTP health checks.
          - "-use_http_health_check"
          # Specifies the health check server port.
          # Defaults to 8090.
          - "-health_check_port=<YOUR-HEALTH-CHECK-PORT>"
          # This flag specifies where the service account key can be found
          - "-credential_file=/secrets/service_account.json"
    ```