Skip to content

Conversation

pmalek
Copy link
Member

@pmalek pmalek commented May 22, 2025

What this PR does / why we need it:

This PR adds a ControlPlane version: v2alpha1 which contains the following breaking changes with respect to v1beta1:

  • removal of deployment field
  • changing dataplane field from *string to a typed union field which can be set to either a url (of Admin API) or a name of DataPlane resource (the same use case as with old dataplane field)
  • adding featureGates, controllers and adminAPI fields. The first 2 have string based arrays instead of strongly types fields (most likely the direction we'll move forward with but can potentially be changed based on feedback).

CRD validation tests have not been added (yet) to allow feedback which could influence the design.

Which issue this PR fixes

Part of Kong/kong-operator#1358

Special notes for your reviewer:

Further changes to the new v2alpha1 API (like new, individual fields) will be added when this PR gets reviewed so that throw away work is avoided.

PR Readiness Checklist:

Complete these before marking the PR as ready to review:

  • the CHANGELOG.md release notes have been updated to reflect significant changes

@pmalek pmalek added this to the KO v2.0.0-alpha.1 milestone May 22, 2025
@pmalek pmalek self-assigned this May 22, 2025
@pmalek pmalek force-pushed the ko-controlplane-crd branch 3 times, most recently from a60ec58 to 179dde6 Compare May 28, 2025 14:48
@pmalek pmalek force-pushed the ko-controlplane-crd branch from 179dde6 to 72293bb Compare May 28, 2025 14:55
@pmalek pmalek marked this pull request as ready for review May 28, 2025 15:04
@pmalek pmalek requested a review from a team as a code owner May 28, 2025 15:04
Copy link
Member

@programmer04 programmer04 left a comment

Choose a reason for hiding this comment

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

overall LGTM, nits

@pmalek pmalek requested a review from mlavacca June 2, 2025 16:17
@pmalek
Copy link
Member Author

pmalek commented Jun 2, 2025

Letting @mlavacca chip in on the review and thus leaving this unmerged for now.

Copy link
Member

@mlavacca mlavacca left a comment

Choose a reason for hiding this comment

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

Thanks for the effort on this, @pmalek!
I've left a few comments, curious to hear your opinion :)

requesting changes to avoid accidental merge.

@pmalek pmalek mentioned this pull request Jun 3, 2025
1 task
@pmalek pmalek requested a review from mlavacca June 4, 2025 09:10
@pmalek pmalek requested a review from randmonkey June 4, 2025 09:53
…at enabled is set for controllers and featureGates
@pmalek pmalek requested a review from mlavacca June 4, 2025 10:53
@pmalek pmalek force-pushed the ko-controlplane-crd branch from 45fa28a to 01289db Compare June 6, 2025 11:18
@pmalek pmalek force-pushed the ko-controlplane-crd branch from 01289db to bc8a3b1 Compare June 6, 2025 11:31
@pmalek
Copy link
Member Author

pmalek commented Jun 6, 2025

@mlavacca This is ready for review once more. PTAL.

Comment on lines +164 to +168
// ControlPlaneDataPlaneTargetManagedByType indicates that the DataPlane target
// is managed by the owner of the ControlPlane.
// This is the case when using a Gateway resource to manage the DataPlane
// and the ControlPlane is responsible for configuring it.
ControlPlaneDataPlaneTargetManagedByType ControlPlaneDataPlaneTargetType = "managedByOwner"
Copy link
Member Author

Choose a reason for hiding this comment

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

I've tried constraining the created ControlPlane with this target type to ensure that it has an owner set but CEL doesn't allow it for some reason:

The CustomResourceDefinition "controlplanes.gateway-operator.konghq.com" is invalid: spec.versions[1].schema.openAPIV3Schema.x-kubernetes-validations[0].rule: Invalid value: apiextensions.ValidationRule{Rule:"self.spec.dataplane.type != 'managedByOwner' || self.ownerReferences[0].kind == 'Gateway'", Message:"X", MessageExpression:"", Reason:(*apiextensions.FieldValueErrorReason)(nil), FieldPath:"", OptionalOldSelf:(*bool)(nil)}: compilation failed: ERROR: <input>:1:53: undefined field 'ownerReferences'
 | self.spec.dataplane.type != 'managedByOwner' || self.ownerReferences[0].kind == 'Gateway'
 | ....................................................^

slack thread asking about the reason and the comprehensive list of allowed metadata fields to use in CEL: https://kubernetes.slack.com/archives/C0EG7JC6T/p1749212565802129

Copy link
Member Author

Choose a reason for hiding this comment

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

This is explained in https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/

The apiVersion, kind, metadata.name and metadata.generateName are always accessible from the root of the object and from any x-kubernetes-embedded-resource annotated objects. No other metadata properties are accessible.

So we can't do this validation (at this moment) via CEL.

Copy link
Member

@mlavacca mlavacca left a comment

Choose a reason for hiding this comment

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

Mostly lgtm, just one nit about validation

@pmalek pmalek requested a review from mlavacca June 6, 2025 13:18
Copy link
Member

@mlavacca mlavacca left a comment

Choose a reason for hiding this comment

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

I think we are good to go 🚀 Thanks for putting this together, @pmalek!

@pmalek pmalek merged commit 3aecd47 into main Jun 6, 2025
19 checks passed
@pmalek pmalek deleted the ko-controlplane-crd branch June 6, 2025 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

☔ Revamped v2alpha1 ControlPlane API for Kong Operator v2alpha1 ControlPlane CRD API is added to the kong/kubernetes-configuration repository

6 participants