Skip to content

chore: add v2alpha1 group and add ControlPlane type - #441

Merged
pmalek merged 20 commits into
mainfrom
ko-controlplane-crd
Jun 6, 2025
Merged

chore: add v2alpha1 group and add ControlPlane type#441
pmalek merged 20 commits into
mainfrom
ko-controlplane-crd

Conversation

@pmalek

@pmalek pmalek commented May 22, 2025

Copy link
Copy Markdown
Member

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
Comment thread api/gateway-operator/v1beta1/controlplane_types.go

@programmer04 programmer04 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

overall LGTM, nits

Comment thread api/gateway-operator/v2alpha1/controlplane_types.go Outdated
Comment thread api/gateway-operator/v2alpha1/controlplane_types.go Outdated
Comment thread api/gateway-operator/v2alpha1/doc.go
Comment thread api/gateway-operator/v2alpha1/groupversion_info.go Outdated
pmalek and others added 2 commits June 2, 2025 14:08
Co-authored-by: Jakub Warczarek <jakub.warczarek@gmail.com>
@pmalek
pmalek requested a review from mlavacca June 2, 2025 16:17
@pmalek

pmalek commented Jun 2, 2025

Copy link
Copy Markdown
Member Author

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

Comment thread api/gateway-operator/v2alpha1/controlplane_types.go Outdated
Comment thread api/gateway-operator/v2alpha1/controlplane_types.go
pmalek and others added 2 commits June 3, 2025 09:59
Comment thread api/gateway-operator/v2alpha1/controlplane_types.go Outdated

@mlavacca mlavacca left a comment

Copy link
Copy Markdown
Member

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.

Comment thread api/gateway-operator/v2alpha1/controlplane_types.go
Comment thread api/gateway-operator/v2alpha1/controlplane_types.go
Comment thread api/gateway-operator/v2alpha1/controlplane_types.go Outdated
Comment thread api/gateway-operator/v2alpha1/controlplane_types.go Outdated
Comment thread api/gateway-operator/v2alpha1/controlplane_types.go Outdated
Comment thread api/gateway-operator/v2alpha1/controlplane_types.go Outdated
Comment thread api/gateway-operator/v2alpha1/controlplane_types.go
Comment thread api/gateway-operator/v2alpha1/controlplane_types.go Outdated
Comment thread api/gateway-operator/v2alpha1/controlplane_types.go
@pmalek pmalek mentioned this pull request Jun 3, 2025
1 task
Comment thread docs/all-api-reference.md
Comment thread docs/gateway-operator-api-reference.md
Comment thread docs/gateway-operator-api-reference.md
@pmalek
pmalek requested a review from mlavacca June 4, 2025 09:10
Comment thread api/gateway-operator/v2alpha1/controlplane_types.go Outdated
Comment thread api/gateway-operator/v2alpha1/controlplane_types.go Outdated
Comment thread api/gateway-operator/v2alpha1/controlplane_types.go Outdated
@pmalek
pmalek requested a review from randmonkey June 4, 2025 09:53
Comment thread api/gateway-operator/v2alpha1/controlplane_types.go
Comment thread api/gateway-operator/v2alpha1/controlplane_types.go
Comment thread api/gateway-operator/v2alpha1/controlplane_types.go Outdated
Comment thread api/gateway-operator/v2alpha1/controlplane_types.go Outdated
Comment thread api/gateway-operator/v2alpha1/controlplane_types.go
Comment thread api/gateway-operator/v2alpha1/controlplane_types.go
…at enabled is set for controllers and featureGates
@pmalek
pmalek requested a review from mlavacca June 4, 2025 10:53
Comment thread docs/all-api-reference.md
@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

pmalek commented Jun 6, 2025

Copy link
Copy Markdown
Member Author

@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
Copy Markdown
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
Copy Markdown
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.

@mlavacca mlavacca left a comment

Copy link
Copy Markdown
Member

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

Comment thread api/gateway-operator/v2alpha1/controlplane_types.go
@pmalek
pmalek requested a review from mlavacca June 6, 2025 13:18

@mlavacca mlavacca left a comment

Copy link
Copy Markdown
Member

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!

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.

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

6 participants