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

#118: Ability to handle parameters in GatewayClass #124

Merged
merged 1 commit into from
Apr 24, 2023

Conversation

sergioifg94
Copy link
Contributor

@sergioifg94 sergioifg94 commented Mar 20, 2023

Description

Closes #118

Ability to get parameters from a resourced referenced in the parametersRef of the GatewayClass

Verification steps

As the parameters are currently not used, in order to verify this functionality, ensure that the adequate status condition is reconciled when the parametersRef is misconfigured.

  1. Start the local development clusters

    MCTC_WORKLOAD_CLUSTERS_COUNT=1 make local-setup
  2. Run the controller

    (export $(cat ./controller-config.env | xargs) && export $(cat ./aws-credentials.env | xargs) && make build-controller install run-controller)
  3. Create the parameters ConfigMap

    kubectl create configmap gateway-params --from-file=params=config/samples/gatewayclass_params.json -n multi-cluster-traffic-controller-system
  4. Create the GatewayClass

    apiVersion: gateway.networking.k8s.io/v1beta1
    kind: GatewayClass
    metadata:
      name: mctc-gw-istio-external-instance-per-cluster
    spec:
      controllerName: "kuadrant.io/mctc-gw-controller"
      parametersRef:
        group: ""
        kind: "ConfigMap"
        namespace: "multi-cluster-traffic-controller-system"
        name: "gateway-params"
  5. Create the Gateway with .spec.gatewayClassName = mctc-gw-istio-external-instance-per-cluster

    kubectl create namespace mctc-tenant
    kubectl apply -n mctc-tenant -f gateway.yaml
  6. Verify that once reconciled, the annotation is set

    kubectl get gateway/example-gateway -n mctc-tenant
    metadata:
      name: example-gateway
      annotations:
        mctc-syncer-patch/kind-mctc-workload-1: [{"op":"replace","path":"/spec/gatewayClassName","value":"istio"}] 

@maksymvavilov
Copy link
Contributor

Verified GatewayClass gets InvalidParameters field
image

Copy link
Contributor

@maleck13 maleck13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a valid use case for the parameters in adding in the supported data plane gateway controller to use (istio)
So we could actually use the code here and create a default configmap params with the gateway controller to use. This param is set as a transform on the gateway resource

@maleck13
Copy link
Contributor

couple of code comments and a suggested change to make the code do some actual work for us

@sergioifg94 sergioifg94 force-pushed the GH-118 branch 3 times, most recently from 23e0fb0 to b8e52ba Compare March 24, 2023 13:15
@sergioifg94
Copy link
Contributor Author

Updated the PR with the suggestions, added some unit tests and updated the verification steps to verify that the patch annotation is set from the value specified in the parameters

@maleck13
Copy link
Contributor

@sergioifg94 just one question before merge. Prob worth having this params created as part of local set up so it is there and being used?

@sergioifg94
Copy link
Contributor Author

@maleck13 I added a commit to create the params in the local-setup and the parametersRef section filled by default in the sample gateway class


echo "Adding ${clusterName} to gatewayclass params"

${YQ_BIN} -i -P -o=json '.downstreamClasses["'$clusterName'"] = "istio"' config/samples/gatewayclass_params.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sergioifg94 why are we keying it off the cluster name? The idea with the gatewayclass params is it is configuration to be applied to gateways of this class, so I would expect all gateways of this class would have the same downstream class

@@ -164,6 +188,15 @@ func (r *GatewayReconciler) reconcileGateway(ctx context.Context, previous gatew
allHosts := trafficAccessor.GetHosts()
managedHosts := []ManagedHost{}

// Set the annotations to sync the class name from the parameters
for cluster, downstreamClass := range params.GetDownstreamClasses() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah same here, I think for the downstream class, each instance would have the same class

Copy link
Contributor

@maleck13 maleck13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the params should be keyed of the clustername, the idea with the params is it is additional config for a given gateway class and so generic

@mikenairn mikenairn mentioned this pull request Apr 14, 2023
2 tasks
@maleck13
Copy link
Contributor

@mikenairn I see your PR depends on this one. We can probably merge this, I would just prefer the params weren't keyed against a cluster. The gatewayclass params, IMO are intended as class level configuration rather than cluster level configuration cc @sergioifg94

@sergioifg94
Copy link
Contributor Author

I was planning on waiting until patching annotations for all clusters is supported, but we can merge this as is for now and make those changes later

@sergioifg94
Copy link
Contributor Author

@maleck13 I just updated the PR to follow your suggestion, so the parameter is now downstreamClass and the patch is applied to all clusters

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Apr 24, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: maleck13, 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:
  • OWNERS [maleck13,sergioifg94]

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

@openshift-ci openshift-ci bot merged commit 0b40a99 into Kuadrant:main Apr 24, 2023
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.

GatewayClass parameters
3 participants