GoogleCloudPlatform / k8s-config-connector

GCP Config Connector, a Kubernetes add-on for managing GCP resources
https://cloud.google.com/config-connector/docs/overview
Apache License 2.0
864 stars 202 forks source link

Add support for Google Cloud SQL Query Insights #385

Open ve6yeq opened 3 years ago

ve6yeq commented 3 years ago

Recently, a new feature Query Insights was added to Google Cloud SQL for PostgreSQL. This is enabled with the following new keys on the SQLInstance resource:

apiVersion: sql.cnrm.cloud.google.com/v1beta1
kind: SQLInstance
settings:
    insightsConfig:
      queryInsightsEnabled: true
      queryStringLength: 1024
      recordApplicationTags: true
      recordClientAddress: true

As there is strict checking of allowed keys, the following patch needs to be applied:

diff --git a/crds/sql_v1beta1_sqlinstance.yaml b/crds/sql_v1beta1_sqlinstance.yaml
index c20c085..24cc9c3 100644
--- a/crds/sql_v1beta1_sqlinstance.yaml
+++ b/crds/sql_v1beta1_sqlinstance.yaml
@@ -337,6 +337,21 @@ spec:
                     requireSsl:
                       type: boolean
                   type: object
+                insightsConfig:
+                  description: Query Insights helps you detect, diagnose, and prevent query performance problems.
+                  properties:
+                    queryInsightsEnabled:
+                      description: Enable Query Insights on this Instance.
+                      type: boolean
+                    queryStringLength:
+                      description: The query string length in bytes to be stored by the query insights feature. Default length is 1024 bytes. Allowed range: 256 to 4500 bytes.
+                      type: integer
+                    recordApplicationTags:
+                      description: Enable the storage of application tags.
+                      type: boolean
+                    recordClientAddress:
+                      description: Enable the storage client IP addresses.
+                      type: boolean
                 locationPreference:
                   properties:
                     followGaeApplication:
xiaobaitusi commented 3 years ago

Hi @ve6yeq, thanks for making the enhancement request.

Since Config Connector uses terraform provider under the hood, these fields should be added into Terraform first. Then our pipeline will introduce those fields on the next version.

Here is the Terraform feature request to track - https://github.com/hashicorp/terraform-provider-google/issues/8328