Skip to content

migrate CRD generation to controller-gen and automate Helm RBAC sync#2269

Merged
knative-prow[bot] merged 4 commits intoknative:mainfrom
kahirokunn:migrate-crd-to-controller-gen
Apr 14, 2026
Merged

migrate CRD generation to controller-gen and automate Helm RBAC sync#2269
knative-prow[bot] merged 4 commits intoknative:mainfrom
kahirokunn:migrate-crd-to-controller-gen

Conversation

@kahirokunn
Copy link
Copy Markdown
Member

@kahirokunn kahirokunn commented Apr 7, 2026

Changes

  • Migrate hand-maintained CRD YAMLs to controller-gen auto-generation from Go types
  • Generate CRD YAMLs via controller-gen into config/crd/bases/
  • Add hack/sync-helm-crds.sh to auto-sync Helm chart CRDs from controller-gen output
    (split out from operator.yaml)
  • Add hack/sync-helm-rbac.sh to auto-sync Helm chart RBAC ClusterRoles from
    config/rbac/role.yaml into separate per-operator files
    (rbac/serving-operator-role.yaml, rbac/eventing-operator-role.yaml)
  • Integrate controller-gen execution, Helm CRD sync, and Helm RBAC sync into
    hack/update-codegen.sh and hack/verify-codegen.sh

Why

The old hand-maintained CRDs had diverged from Go type definitions:

  • Istio TLS fields were defined in camelCase (credentialName) but Go struct JSON tags use
    snake_case (credential_name); values were silently ignored on deserialization
  • workloads[].version, workloads[].volumeMounts existed in CRD but had no backing Go
    struct fields. Setting them had no effect.
  • tls.mode was string in CRD but int32 in Go

Similarly, the Helm chart's operator.yaml contained hand-maintained ClusterRole definitions
that could diverge from config/rbac/role.yaml.

Generating from Go types with controller-gen and syncing from a single source of truth
eliminates these inconsistencies and prevents future drift.

Release Note

Migrate CRD generation from hand-maintained YAML to controller-gen, and automate Helm chart CRD/RBAC sync from generated sources.
spec.ingress.* sub-fields (istio, kourier, contour, gateway-api) are now optional in the CRD schema, a backward-compatible validation change.

@knative-prow knative-prow bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Apr 7, 2026
@knative-prow knative-prow bot requested review from aliok and houshengbo April 7, 2026 04:10
Copy link
Copy Markdown

@knative-prow knative-prow bot left a comment

Choose a reason for hiding this comment

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

@kahirokunn: 0 warnings.

Details

In response to this:

Fixes #

Proposed Changes

Release Note


Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 7, 2026

Codecov Report

❌ Patch coverage is 95.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.58%. Comparing base (043a222) to head (956e019).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/reconciler/knativeserving/ingress/istio.go 95.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2269      +/-   ##
==========================================
+ Coverage   63.97%   64.58%   +0.60%     
==========================================
  Files          51       51              
  Lines        1960     1999      +39     
==========================================
+ Hits         1254     1291      +37     
- Misses        605      606       +1     
- Partials      101      102       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kahirokunn kahirokunn force-pushed the migrate-crd-to-controller-gen branch from 64fda73 to 51abee7 Compare April 7, 2026 05:26
@kahirokunn kahirokunn changed the title migrate CRD generation to controller-gen v0.20.1 migrate CRD generation to controller-gen Apr 7, 2026
@kahirokunn kahirokunn force-pushed the migrate-crd-to-controller-gen branch from 51abee7 to 552a8a9 Compare April 7, 2026 06:11
@kahirokunn kahirokunn changed the title migrate CRD generation to controller-gen [WIP] migrate CRD generation to controller-gen Apr 7, 2026
@knative-prow knative-prow bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 7, 2026
@kahirokunn kahirokunn force-pushed the migrate-crd-to-controller-gen branch from 552a8a9 to cf94405 Compare April 7, 2026 12:06
@kahirokunn kahirokunn changed the title [WIP] migrate CRD generation to controller-gen migrate CRD generation to controller-gen Apr 7, 2026
@knative-prow knative-prow bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 7, 2026
@kahirokunn kahirokunn force-pushed the migrate-crd-to-controller-gen branch 4 times, most recently from 3b7b007 to baf6c99 Compare April 8, 2026 06:00
@kahirokunn kahirokunn changed the title migrate CRD generation to controller-gen migrate CRD generation to controller-gen and automate Helm RBAC sync Apr 8, 2026
@kahirokunn kahirokunn force-pushed the migrate-crd-to-controller-gen branch 3 times, most recently from 786194b to 4582245 Compare April 14, 2026 07:32
Copy link
Copy Markdown

@houshengbo houshengbo 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 this PR — the goal of migrating to controller-gen and automating Helm sync is valuable. However, the generated CRD schema introduces backward-incompatible changes that will break existing user CRs on upgrade. The CRD schema must not change field names, remove existing fields, or change field types.

Specific blockers:

  1. Istio TLS field renames (12 fields): The Istio proto Go types use snake_case JSON tags (json:"credential_name"), so controller-gen generates snake_case field names. The existing CRD uses camelCase (credentialName, httpsRedirect, etc.). This rename breaks any existing CR that uses these fields. Additionally, tls.mode changes from string to int32.

  2. Ghost fields removed: workloads[].version and workloads[].volumeMounts exist in the current CRD but have no backing Go struct fields. controller-gen drops them. Existing CRs that set these fields will fail validation.

Suggested approach: Create operator-local wrapper types for the Istio Server/Port/ServerTLSSettings structs with camelCase JSON tags matching the existing schema, and add the ghost fields to WorkloadOverride with deprecation comments. This preserves backward compatibility while achieving the controller-gen automation goal.

See inline comments for details.

Comment thread pkg/apis/operator/base/ingressconfiguration.go
Comment thread pkg/apis/operator/base/common.go
Copy link
Copy Markdown

@houshengbo houshengbo left a comment

Choose a reason for hiding this comment

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

A few additional non-blocking suggestions below.

Comment thread hack/sync-helm-crds.sh Outdated
Comment thread hack/update-codegen.sh
Comment thread pkg/apis/operator/v1beta1/knativeserving_types.go
@kahirokunn kahirokunn force-pushed the migrate-crd-to-controller-gen branch 3 times, most recently from 19b1507 to f9f7647 Compare April 14, 2026 16:06
Signed-off-by: kahirokunn <okinakahiro@gmail.com>
Signed-off-by: kahirokunn <okinakahiro@gmail.com>
Signed-off-by: kahirokunn <okinakahiro@gmail.com>
Signed-off-by: kahirokunn <okinakahiro@gmail.com>
@kahirokunn kahirokunn force-pushed the migrate-crd-to-controller-gen branch from f9f7647 to 956e019 Compare April 14, 2026 16:21
@kahirokunn kahirokunn requested a review from houshengbo April 14, 2026 16:38
@houshengbo
Copy link
Copy Markdown

/lgtm
/approve

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Apr 14, 2026
@knative-prow
Copy link
Copy Markdown

knative-prow bot commented Apr 14, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: houshengbo, kahirokunn

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

The pull request process is described here

Details 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

@knative-prow knative-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 14, 2026
@knative-prow knative-prow bot merged commit d61290e into knative:main Apr 14, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants