...

Text file src/github.com/GoogleCloudPlatform/cloudsql-proxy/examples/k8s-health-check/README.md

Documentation: github.com/GoogleCloudPlatform/cloudsql-proxy/examples/k8s-health-check

     1# Cloud SQL proxy health checks
     2
     3Kubernetes supports three types of health checks.
     41. 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.
     52. Liveness probes determine whether a container is healthy. When this probe is unsuccessful, the container is restarted.
     63. Readiness probes determine whether a container can serve new traffic. When this probe fails, Kubernetes will wait to send requests to the container.
     7
     8## Running Cloud SQL proxy with health checks in Kubernetes
     91. Configure your Cloud SQL proxy container to include health check probes. 
    10    > [proxy_with_http_health_check.yaml](proxy_with_http_health_check.yaml#L77-L111)
    11     ```yaml
    12        # Recommended configurations for health check probes.
    13        # Probe parameters can be adjusted to best fit the requirements of your application.
    14        # For details, see https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/
    15        livenessProbe:
    16          httpGet:
    17            path: /liveness
    18            port: 8090
    19          # Number of seconds after the container has started before the first probe is scheduled. Defaults to 0.
    20          # Not necessary when the startup probe is in use.
    21          initialDelaySeconds: 0
    22          # Frequency of the probe. Defaults to 10.
    23          periodSeconds: 10
    24          # Number of seconds after which the probe times out. Defaults to 1.
    25          timeoutSeconds: 5
    26          # Number of times the probe is allowed to fail before the transition from healthy to failure state. 
    27          # Defaults to 3.
    28          failureThreshold: 1
    29        readinessProbe:
    30          httpGet:
    31            path: /readiness
    32            port: 8090
    33          initialDelaySeconds: 0
    34          periodSeconds: 10
    35          timeoutSeconds: 5
    36          # Number of times the probe must report success to transition from failure to healthy state.
    37          # Defaults to 1 for readiness probe.
    38          successThreshold: 1
    39          failureThreshold: 1
    40        startupProbe:
    41          httpGet:
    42            path: /startup
    43            port: 8090
    44          periodSeconds: 1
    45          timeoutSeconds: 5
    46          failureThreshold: 20
    47     ```
    48
    492. Add `-use_http_health_check` and `-health-check-port` (optional) to your proxy container configuration under `command: `.
    50    > [proxy_with_http_health_check.yaml](proxy_with_http_health_check.yaml#L39-L55)
    51    ```yaml
    52        command:
    53          - "/cloud_sql_proxy"
    54
    55          # If connecting from a VPC-native GKE cluster, you can use the
    56          # following flag to have the proxy connect over private IP
    57          # - "-ip_address_types=PRIVATE"
    58
    59          # Replace DB_PORT with the port the proxy should listen on
    60          # Defaults: MySQL: 3306, Postgres: 5432, SQLServer: 1433
    61          - "-instances=<INSTANCE_CONNECTION_NAME>=tcp:<DB_PORT>"
    62          # Enables HTTP health checks.
    63          - "-use_http_health_check"
    64          # Specifies the health check server port.
    65          # Defaults to 8090.
    66          - "-health_check_port=<YOUR-HEALTH-CHECK-PORT>"
    67          # This flag specifies where the service account key can be found
    68          - "-credential_file=/secrets/service_account.json"
    69    ```
    70

View as plain text