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
889 stars 218 forks source link

feat: simplify the schema of NamespacedControllerReconciler #2024

Closed jingyih closed 3 months ago

jingyih commented 3 months ago

Example NamespacedControllerReconciler CR:

apiVersion: customize.core.cnrm.cloud.google.com/v1alpha1
kind: NamespacedControllerReconciler
metadata:
  name: cnrm-controller-manager # name should not contain the namespace ID suffix
  namespace: config-control
spec:
  rateLimit:
    qps: 80
    burst: 30

Prior to applying the example NamespacedControllerReconciler CR:

$ kubectl get pods cnrm-controller-manager-o6k4tubitdex7vqqw6xa-0 -n cnrm-system -oyaml
...
uid: bd11f23d-4ab7-4459-a08a-b684b1a8b787
spec:
  containers:
  - args:
    - --scoped-namespace=config-control
    - --prometheus-scrape-endpoint=:8888
    command:
    - /configconnector/manager
    image: gcr.io/gke-release/cnrm/controller:fd4c42c
    imagePullPolicy: Always
    name: manager
    ports:
    - containerPort: 23232
      protocol: TCP
...

After applying the example NamespacedControllerReconciler CR:

$ kubectl get pods cnrm-controller-manager-o6k4tubitdex7vqqw6xa-0 -n cnrm-system -oyaml
...
uid: ba7a7b87-f9ad-4e15-b40c-cf008b70265f
spec:
  containers:
  - args:
    - --qps=80
    - --burst=30
    - --scoped-namespace=config-control
    - --prometheus-scrape-endpoint=:8888
    command:
    - /configconnector/manager
    image: gcr.io/gke-release/cnrm/controller:fd4c42c
    imagePullPolicy: Always
    name: manager
    ports:
    - containerPort: 23232
      protocol: TCP
...

The status of NamespacedControllerReconciler CR:

Spec:
  Rate Limit:
    Burst:  30
    Qps:    80
Status:
  Healthy:  true
Events:     <none>

Applying an invalid CR with the wrong name:

apiVersion: customize.core.cnrm.cloud.google.com/v1alpha1
kind: NamespacedControllerReconciler
metadata:
  name: some-controller  # invalid controller name
  namespace: config-control
spec:
  rateLimit:
    qps: 80

The status of the invalid CR:

Spec:
  Rate Limit:
    Burst:  30
    Qps:    80
Status:
  Errors:
    failed to apply rate limit customization some-controller: rate limit customization for some-controller is not supported. Supported controllers: cnrm-controller-manager
  Healthy:  false
Events:     <none>
jingyih commented 3 months ago

/assign @yuwenma

yuwenma commented 3 months ago

/lgtm /approve

Looks great! I like the new CRD and the error messages.

google-oss-prow[bot] commented 3 months ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: yuwenma

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/GoogleCloudPlatform/k8s-config-connector/blob/master/OWNERS)~~ [yuwenma] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment