Skip to content

feat: add securityGroupRefs to MSK Cluster BrokerNodeGroupInfo - #104

Open
k1ranpk wants to merge 7 commits into
aws-controllers-k8s:mainfrom
k1ranpk:feat/add-securitygroup-refs-to-cluster
Open

k1ranpk wants to merge 7 commits into
aws-controllers-k8s:mainfrom
k1ranpk:feat/add-securitygroup-refs-to-cluster

Conversation

@k1ranpk

@k1ranpk k1ranpk commented Jun 15, 2026

Copy link
Copy Markdown

Description of changes

Adds support for adopting/referencing ACK-managed EC2 SecurityGroup resources from the MSK Cluster resource, resolving aws-controllers-k8s/community#2752.

Code generation

  • generator.yaml: adds a reference for BrokerNodeGroupInfo.SecurityGroups to the ec2 SecurityGroup resource (path: Status.ID), mirroring the existing clientSubnetRefs support for subnets.
  • Regenerated artifacts via make build-controller: API types + deepcopy, CRDs (config/crd, helm/crds), RBAC (adds securitygroups get/list), and pkg/resource/cluster/references.go.

This produces a securityGroupRefs field on Cluster.spec.brokerNodeGroupInfo that resolves to the referenced SecurityGroup's Status.ID. If the reference can't be resolved, the controller blocks creation (standard ACK reference behavior).

Tests

test/e2e/tests/test_cluster_references.py:

  • Negative test (active) — an unresolved securityGroupRefs reference blocks Cluster creation. No MSK cluster is ever created, so it is fast and incurs no AWS cost.
  • Positive test (currently SKIPPED, pending verification) — would create a Cluster referencing an ACK-managed ec2 SecurityGroup and verify the resolved security group is attached in BrokerNodeGroupInfo.SecurityGroups. This test has not yet been verified end-to-end against a live MSK cluster, so it is skipped via @pytest.mark.skip to avoid landing an unverified test that runs in CI. A TODO(community#2752) documents how to re-enable it: install the ec2-controller in the test cluster (add ec2-controller@<version> to cluster.configuration.additional_controllers in test_config.yaml), run it successfully, then remove the skip.

New test resource templates: cluster_security_group_ref.yaml, security_group.yaml.

Verification

  • go build ./cmd/controller passes.
  • check-breaking-changes clean (additive field only).
  • Negative e2e test logic validated; positive e2e test skipped pending an end-to-end run (see TODO).

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ack-prow
ack-prow Bot requested review from gustavodiaz7722 and sapphirew June 15, 2026 04:43
k1ranpk added a commit to k1ranpk/kafka-controller that referenced this pull request Jun 15, 2026
Adding the EC2 SecurityGroup reference to the shared BrokerNodeGroupInfo
type surfaced a securityGroupRefs field on the ServerlessCluster CRD, but
ServerlessCluster had no resolver for it, so the field was silently
ignored (asymmetric with the functional clientSubnetRefs).

Add the matching reference to ServerlessCluster's
Provisioned.BrokerNodeGroupInfo.SecurityGroups (preserving its existing
late_initialize) and regenerate, producing
resolveReferenceForProvisioned_BrokerNodeGroupInfo_SecurityGroups.

Addresses reviewer MUST FIX on PR aws-controllers-k8s#104.
@gustavodiaz7722

Copy link
Copy Markdown
Member

Should we also add e2e test for serverless cluster?

k1ranpk added 6 commits June 24, 2026 21:14
  Adds an EC2 SecurityGroup reference for Cluster.BrokerNodeGroupInfo.SecurityGroups,
  generating a securityGroupRefs field that resolves to Status.ID, mirroring the
  existing clientSubnetRefs support.

  Resolves aws-controllers-k8s/community#2752
Adds a negative test asserting that an unresolved securityGroupRefs
reference blocks MSK Cluster creation (no AWS cost), and a positive test
that creates a Cluster referencing an ACK-managed ec2 SecurityGroup and
verifies the resolved security group is attached. The positive test is
skipped when the ec2 SecurityGroup CRD is not installed.

Also ignores test/e2e/.venv/.

Resolves aws-controllers-k8s/community#2752
The positive test (creates a live MSK Cluster referencing an ACK-managed
ec2 SecurityGroup and verifies attachment) has not been verified
end-to-end. Skip it so an unverified test does not run in CI, and leave a
TODO to re-enable after a successful run. The no-cost negative test
(unresolved ref blocks create) remains active.

Re: aws-controllers-k8s/community#2752
Adding the EC2 SecurityGroup reference to the shared BrokerNodeGroupInfo
type surfaced a securityGroupRefs field on the ServerlessCluster CRD, but
ServerlessCluster had no resolver for it, so the field was silently
ignored (asymmetric with the functional clientSubnetRefs).

Add the matching reference to ServerlessCluster's
Provisioned.BrokerNodeGroupInfo.SecurityGroups (preserving its existing
late_initialize) and regenerate, producing
resolveReferenceForProvisioned_BrokerNodeGroupInfo_SecurityGroups.

Addresses reviewer MUST FIX on PR aws-controllers-k8s#104.
Adds a negative test asserting that an unresolved securityGroupRefs
reference on a provisioned ServerlessCluster (ClusterV2) blocks creation
(no AWS cost), and a positive test that creates a provisioned cluster
referencing an ACK-managed ec2 SecurityGroup and verifies the resolved
security group is attached under Provisioned.BrokerNodeGroupInfo.
SecurityGroups. The positive test is skipped pending end-to-end
verification against live MSK, mirroring the Cluster references suite.

Addresses reviewer comment on PR aws-controllers-k8s#104 requesting e2e coverage for the
ServerlessCluster securityGroupRefs resolver.

Re: aws-controllers-k8s/community#2752
Rebasing onto upstream/main pulled in the ACK runtime/code-generator
v0.60.0 bump (aws-controllers-k8s#108). Regenerate the kafka controller with
code-generator v0.60.0 so the generated reference resolvers and
ack-generate-metadata checksums are consistent with the merged
generator.yaml (which adds the BrokerNodeGroupInfo.SecurityGroups
reference for both Cluster and ServerlessCluster).
@k1ranpk
k1ranpk force-pushed the feat/add-securitygroup-refs-to-cluster branch from b830dce to 034e95a Compare June 24, 2026 21:23
@ack-prow

ack-prow Bot commented Jun 24, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: k1ranpk
Once this PR has been reviewed and has the lgtm label, please assign gustavodiaz7722 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

Remove the @pytest.mark.skip decorators and the _require_ec2_securitygroup_crd
runtime skip guard from the positive securityGroupRefs e2e tests for both
Cluster and ServerlessCluster. The positive tests now always run as canary
tests instead of being skipped.

These tests require the ec2-controller (SecurityGroup CRD) to be installed in
the test cluster via cluster.configuration.additional_controllers. If it is
absent the SecurityGroup fixture now fails loudly rather than silently
skipping, so the missing dependency is visible.

Re: aws-controllers-k8s/community#2752
@ack-prow

ack-prow Bot commented Jun 24, 2026

Copy link
Copy Markdown

@k1ranpk: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
kafka-kind-e2e 82c0f7e link true /test kafka-kind-e2e

Full PR test history. Your PR dashboard.

Details

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. I understand the commands that are listed here.

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.

we can't test cross controller references in e2e. the test infra only runs the local controller

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.

we may encounter issues like these for nested references: aws-controllers-k8s/community#1898

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@gustavodiaz7722 I believe this issue should addressed generally once runtime#267 and code-generator#738 have been merged and released to all service controllers.

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.

4 participants