Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Watch policies configured by Gateway params #621

Merged
merged 2 commits into from
Oct 12, 2023

Conversation

sergioifg94
Copy link
Contributor

Description

Add new policiesToSync field to the GatewayClass parameters, which allows users to specify GVRs of policies to watch

Verification steps

Currently the watch only adds a log message when an event is triggered

  1. Start the development environment
  2. Apply the ConfigMap with the updated parameters to watch AuthPolicies:
    kubectl apply -f config/quick-start/control-cluster/cluster-config/configmap.yaml
  3. Edit the GatewayClass to reference the parameters
    kubectl edit gatewayclass kuadrant-multi-cluster-gateway-instance-per-cluster -o yaml
    spec:
      controllerName: kuadrant.io/mgc-gw-controller
      parametersRef:
        group: ""
        kind: ConfigMap
        name: gateway-params
        namespace: multi-cluster-gateways
  4. Ensure the AuthPolicies CRD is installed
    kubectl apply -f https://raw.githubusercontent.com/Kuadrant/kuadrant-operator/main/config/crd/bases/kuadrant.io_authpolicies.yaml 
  5. Edit the controller ClusterRole to have the ability of watching AuthPolicies
    kubectl edit clusterroles mgc-manager-role 
    Add the following rule
    - apiGroups:
      - kuadrant.io
      resources:
      - authpolicies
      - ratelimitpolicies
      verbs:
      - get
      - list
      - watch
  6. Run the controller from this branch (either build new image or run locally ensuring no other instance of the controller is running in cluster)
  7. Create an AuthPolicy
    kubectl apply -f https://raw.githubusercontent.com/Kuadrant/kuadrant-operator/main/config/samples/kuadrant_v1beta1_authpolicy.yaml
  8. Verify the event is logged in the controller
    2023-10-10T10:00:30Z    INFO    Got watch event for policy      {"controller": "gateway", "controllerGroup": "gateway.networking.k8s.io", "controllerKind": "Gateway", "Gateway": {"name":"prod-web","namespace":"multi-cluster-gateways"}, "namespace": "multi-cluster-gateways", "name": "prod-web", "reconcileID": "a3277e6e-51c3-4cd8-bdea-d6b8b81e4606", "obj": {"apiVersion": "kuadrant.io/v1beta1", "kind": "AuthPolicy", "namespace": "default", "name": "toystore"}}
    ...
    2023-10-10T10:00:30Z    INFO    Syncing policy  {"policy": {"apiVersion":"kuadrant.io/v1beta1","kind":"AuthPolicy", ...
    

@sergioifg94 sergioifg94 temporarily deployed to e2e-internal October 10, 2023 10:28 — with GitHub Actions Inactive
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 10, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sergioifg94

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:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sergioifg94 sergioifg94 temporarily deployed to e2e-internal October 10, 2023 15:04 — with GitHub Actions Inactive
@sergioifg94 sergioifg94 marked this pull request as ready for review October 10, 2023 15:23
@R-Lawton
Copy link
Contributor

👀

@R-Lawton
Copy link
Contributor

Tested locally works as expect saw the logs

@sergioifg94 sergioifg94 temporarily deployed to e2e-internal October 12, 2023 08:16 — with GitHub Actions Inactive
@sergioifg94
Copy link
Contributor Author

Thanks @R-Lawton I just pushed a commit with small improvements including the suggestion you made

@R-Lawton
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Oct 12, 2023
@openshift-ci openshift-ci bot merged commit 5194972 into Kuadrant:main Oct 12, 2023
9 checks passed
@sergioifg94 sergioifg94 temporarily deployed to e2e-internal October 13, 2023 08:33 — with GitHub Actions Inactive
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants