Skip to content

DNM: [wip] Use CCO credentials for CCM via CredentialsRequest - #495

Draft
mfbonfigli wants to merge 1 commit into
openshift:mainfrom
mfbonfigli:SPLAT-2862/use-cco-for-ccm-aws-creds
Draft

DNM: [wip] Use CCO credentials for CCM via CredentialsRequest#495
mfbonfigli wants to merge 1 commit into
openshift:mainfrom
mfbonfigli:SPLAT-2862/use-cco-for-ccm-aws-creds

Conversation

@mfbonfigli

@mfbonfigli mfbonfigli commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Do not merge - WIP

AWS Cloud Controller Manager currently reads credentials from the EC2 instance metadata service (IMDS) via the master node IAM instance role, which is static from install time. This prevents new IAM permissions required by new CCM features from being granted on upgraded clusters (OCPBUGS-98763).

This commit migrates CCM to the Cloud Credential Operator (CCO) model:

  • Add a CredentialsRequest manifest for CCM with the scoped set of EC2 and ELB permissions it actually needs, including elasticloadbalancing:SetSecurityGroups for BYO Security Group NLB support and elasticloadbalancing:SetIpAddressType for dual-stack NLBs. In Mint mode CCO mints a dedicated IAM user; in Manual+STS mode CCO writes role_arn + web_identity_token_file for IRSA.

  • Mount the resulting credentials secret and a projected ServiceAccount token (audience: sts.amazonaws.com) into the CCM Deployment, and point the AWS SDK at the credentials file via AWS_SHARED_CREDENTIALS_FILE.

  • Add unit test assertions verifying the new volumes, mounts, and env var are present in the rendered Deployment.

Summary by CodeRabbit

  • New Features

    • Added AWS credential configuration for the cloud controller manager.
    • Enabled secure access to AWS credentials and projected service account tokens for AWS STS integration.
    • Added permissions for EC2 and Elastic Load Balancing operations.
  • Tests

    • Expanded resource validation to verify the required credentials, token mounts, and deployment configuration.

AWS Cloud Controller Manager currently reads credentials from the EC2
instance metadata service (IMDS) via the master node IAM instance role,
which is static from install time. This prevents new IAM permissions
required by new CCM features from being granted on upgraded clusters
(OCPBUGS-98763).

This commit migrates CCM to the Cloud Credential Operator (CCO) model:

- Add a CredentialsRequest manifest for CCM with the scoped set of EC2
  and ELB permissions it actually needs, including
  elasticloadbalancing:SetSecurityGroups for BYO Security Group NLB
  support and elasticloadbalancing:SetIpAddressType for dual-stack NLBs.
  In Mint mode CCO mints a dedicated IAM user; in Manual+STS mode CCO
  writes role_arn + web_identity_token_file for IRSA.

- Mount the resulting credentials secret and a projected ServiceAccount
  token (audience: sts.amazonaws.com) into the CCM Deployment, and point
  the AWS SDK at the credentials file via AWS_SHARED_CREDENTIALS_FILE.

- Add unit test assertions verifying the new volumes, mounts, and env
  var are present in the rendered Deployment.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 28, 2026
@openshift-ci

openshift-ci Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Walkthrough

Adds an AWS CredentialsRequest with EC2 and Elastic Load Balancing permissions, then mounts the resulting credentials secret and an STS-audience service account token into the cloud controller manager deployment. Rendering tests verify the environment variable, mounts, and volumes.

Changes

AWS credential integration

Layer / File(s) Summary
AWS credentials request
manifests/0000_26_cloud-controller-manager-operator_19_credentialsrequest-aws.yaml
Defines the AWS CredentialsRequest, target secret, service account, STS configuration, and EC2 and Elastic Load Balancing IAM permissions.
Deployment credential wiring
pkg/cloud/aws/assets/deployment.yaml, pkg/cloud/aws/aws_test.go
Configures the credentials file and projected STS token mounts, with rendering assertions for the environment variable, mounts, and pod volumes.

Estimated code review effort: 3 (Moderate) | ~20 minutes


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error)

Check name Status Explanation Resolution
Container-Privileges ❌ Error pkg/cloud/aws/assets/deployment.yaml sets hostNetwork: true, which violates the container-privileges check. Remove hostNetwork from the Deployment or justify it; also verify no privileged/root/allowPrivilegeEscalation/SYS_ADMIN settings are present.
✅ Passed checks (14 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: switching CCM to CCO credentials via a CredentialsRequest.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed No Ginkgo titles were added; the new subtests use static names ('Empty config', 'Minimal allowed config') with no dynamic values.
Test Structure And Quality ✅ Passed The new unit test matches existing smoke-test patterns, has no cluster interactions/timeouts, and its assertions target one rendered Deployment behavior.
Microshift Test Compatibility ✅ Passed Only a standard Go unit test was added; no Ginkgo e2e tests, MicroShift guards, or unsupported OpenShift APIs/resources appear in the changed tests.
Single Node Openshift (Sno) Test Compatibility ✅ Passed PASS: The only test change is a plain Go unit test; no new Ginkgo e2e tests or multi-node/SNO assumptions were added.
Topology-Aware Scheduling Compatibility ✅ Passed The PR only adds CCO credentials wiring (secret, projected token, env var); it does not change replicas, node selectors, anti-affinity, or spread constraints.
Ote Binary Stdout Contract ✅ Passed PASS: The patch only changes a manifest, deployment YAML, and a unit test; no main/init/TestMain/BeforeSuite code or stdout-printing calls were added.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No new Ginkgo/e2e tests were added; the only test is a Go unit smoke test with no IPv4-only or external-network assumptions.
No-Weak-Crypto ✅ Passed Scans of the changed files found no MD5/SHA1/DES/RC4/3DES/Blowfish/ECB, custom crypto, or non-constant-time secret/token comparisons.
No-Sensitive-Data-In-Logs ✅ Passed No new logging was added; the changes only add manifests, mounts, env vars, and assertions, with no code that logs secrets or tokens.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@openshift-ci

openshift-ci Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign elmiko 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

@mfbonfigli

Copy link
Copy Markdown
Contributor Author

/hold

@openshift-ci openshift-ci Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 28, 2026
@mfbonfigli

Copy link
Copy Markdown
Contributor Author

/test all

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
pkg/cloud/aws/aws_test.go (1)

72-77: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert each volume’s source configuration, not only its name.

These assertions pass if aws-credentials points to the wrong Secret or if bound-sa-token has the wrong token path/audience, breaking the CredentialsRequest-to-pod contract.

Suggested test expansion
-			volumeNames := make([]string, 0, len(deploy.Spec.Template.Spec.Volumes))
+			volumes := make(map[string]corev1.Volume, len(deploy.Spec.Template.Spec.Volumes))
 			for _, v := range deploy.Spec.Template.Spec.Volumes {
-				volumeNames = append(volumeNames, v.Name)
+				volumes[v.Name] = v
 			}
-			assert.Contains(t, volumeNames, "aws-credentials")
-			assert.Contains(t, volumeNames, "bound-sa-token")
+
+			credentials := volumes["aws-credentials"]
+			require.NotNil(t, credentials.Secret)
+			assert.Equal(t, "cloud-controller-manager-credentials", credentials.Secret.SecretName)
+
+			token := volumes["bound-sa-token"]
+			require.NotNil(t, token.Projected)
+			require.Len(t, token.Projected.Sources, 1)
+			tokenSource := token.Projected.Sources[0].ServiceAccountToken
+			require.NotNil(t, tokenSource)
+			assert.Equal(t, "token", tokenSource.Path)
+			assert.Equal(t, "sts.amazonaws.com", tokenSource.Audience)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/cloud/aws/aws_test.go` around lines 72 - 77, Strengthen the volume
assertions in the deployment test by locating the volumes named
“aws-credentials” and “bound-sa-token” and validating their source
configurations. Assert that aws-credentials references the expected Secret, and
that bound-sa-token uses the required token path and audience, rather than
checking names alone.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@pkg/cloud/aws/aws_test.go`:
- Around line 72-77: Strengthen the volume assertions in the deployment test by
locating the volumes named “aws-credentials” and “bound-sa-token” and validating
their source configurations. Assert that aws-credentials references the expected
Secret, and that bound-sa-token uses the required token path and audience,
rather than checking names alone.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c4b8ddaa-223c-42c5-9ae1-e05b43e45dde

📥 Commits

Reviewing files that changed from the base of the PR and between 38f5e00 and 2d69730.

📒 Files selected for processing (3)
  • manifests/0000_26_cloud-controller-manager-operator_19_credentialsrequest-aws.yaml
  • pkg/cloud/aws/assets/deployment.yaml
  • pkg/cloud/aws/aws_test.go

@mfbonfigli

Copy link
Copy Markdown
Contributor Author

Walkthrough

Adds an AWS CredentialsRequest with EC2 and Elastic Load Balancing permissions, then mounts the resulting credentials secret and an STS-audience service account token into the cloud controller manager deployment. Rendering tests verify the environment variable, mounts, and volumes.

Changes

AWS credential integration
Layer / File(s) Summary
AWS credentials request
manifests/0000_26_cloud-controller-manager-operator_19_credentialsrequest-aws.yaml Defines the AWS CredentialsRequest, target secret, service account, STS configuration, and EC2 and Elastic Load Balancing IAM permissions.
Deployment credential wiring
pkg/cloud/aws/assets/deployment.yaml, pkg/cloud/aws/aws_test.go Configures the credentials file and projected STS token mounts, with rendering assertions for the environment variable, mounts, and pod volumes.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error)

Check name Status Explanation Resolution
Container-Privileges ❌ Error pkg/cloud/aws/assets/deployment.yaml sets hostNetwork: true, which violates the container-privileges check. Remove hostNetwork from the Deployment or justify it; also verify no privileged/root/allowPrivilegeEscalation/SYS_ADMIN settings are present.
✅ Passed checks (14 passed)

✨ Finishing Touches

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share

Comment @coderabbitai help to get the list of available commands.

This is a pre-existing configuration left untouched by this change.

hostNetwork was needed as previously CCM used IDMS to get the credentials, now maybe it's not needed anymore but it depends if on first boot the DNS and network is ready for the internal API endpoint to resolve correctly.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

@mfbonfigli Thanks for clarifying. Since hostNetwork is pre-existing and remains relevant to CCM’s early-startup networking requirements, it is outside this PR’s scope. I’m withdrawing that finding.


✏️ Learnings added
Learnt from: mfbonfigli
URL: https://github.com/openshift/cluster-cloud-controller-manager-operator/pull/495

Timestamp: 2026-07-28T12:02:50.433Z
Learning: In `pkg/cloud/aws/assets/deployment.yaml`, the cloud controller manager Deployment uses `hostNetwork: true` to support early startup when DNS and networking may not yet be ready to resolve or reach the internal API endpoint. Do not treat this pre-existing setting as part of AWS credential-wiring changes without evidence that the startup dependency has been removed.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

@mfbonfigli

Copy link
Copy Markdown
Contributor Author

/payload-job periodic-ci-openshift-hypershift-release-5.0-periodics-e2e-aws-ovn-conformance-ccm periodic-ci-openshift-release-main-ci-5.0-upgrade-from-stable-4.22-e2e-aws-ovn-upgrade

@openshift-ci

openshift-ci Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

@mfbonfigli: trigger 2 job(s) for the /payload-(with-prs|job|aggregate|job-with-prs|aggregate-with-prs) command

  • periodic-ci-openshift-hypershift-release-5.0-periodics-e2e-aws-ovn-conformance-ccm
  • periodic-ci-openshift-release-main-ci-5.0-upgrade-from-stable-4.22-e2e-aws-ovn-upgrade

See details on https://pr-payload-tests.ci.openshift.org/runs/ci/32a05960-8a8c-11f1-815a-380111e6c227-0

Comment on lines +57 to +58
- name: AWS_SHARED_CREDENTIALS_FILE
value: /etc/aws-credentials/credentials

@mfbonfigli mfbonfigli Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This variable is read automatically by the AWS SDK and takes precedence over master node IAM credentials retrieved via IMDS.

- name: bound-sa-token
mountPath: /var/run/secrets/openshift/serviceaccount
readOnly: true
hostNetwork: true

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I left this one but maybe can it be dropped? Not sure if CCM needs the hostNetwork for something other than IMDS calls which should become obsolete with this PR. Asking for feedback on this one.

@JoelSpeed

Copy link
Copy Markdown
Contributor

@mfbonfigli Are you able to demonstrate through an installer PR what the impact of this would be on the node roles?

Have you considered what the migration path looks like for existing clusters at all?

@mfbonfigli

Copy link
Copy Markdown
Contributor Author

@JoelSpeed Working on the installer PR. I tested a IPI Mint and Manual+STS mode installs on a local cluster and both seemed to work just fine, but will try to confirm via e2e jobs with a joint PR.

Regarding the migration path, I suppose it's seamless on upgrades, as once CCO deploys credentials for CCM, this should just use them automatically over the instance ones. The part to clarify would be how to, after, remove now unnecessary old permissions from the master instance roles and most likely the answer is to ask the cluster admin to do that manually.

@mfbonfigli

Copy link
Copy Markdown
Contributor Author

/payload-job periodic-ci-openshift-hypershift-release-5.0-periodics-e2e-aws-ovn-conformance-ccm periodic-ci-openshift-release-main-ci-5.0-upgrade-from-stable-4.22-e2e-aws-ovn-upgrade

@openshift-ci

openshift-ci Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

@mfbonfigli: trigger 2 job(s) for the /payload-(with-prs|job|aggregate|job-with-prs|aggregate-with-prs) command

  • periodic-ci-openshift-hypershift-release-5.0-periodics-e2e-aws-ovn-conformance-ccm
  • periodic-ci-openshift-release-main-ci-5.0-upgrade-from-stable-4.22-e2e-aws-ovn-upgrade

See details on https://pr-payload-tests.ci.openshift.org/runs/ci/cbf8ff60-8b25-11f1-9ec0-d93ed0dd6ed0-0

@mfbonfigli

Copy link
Copy Markdown
Contributor Author

/payload-job-with-prs periodic-ci-openshift-release-main-ci-5.0-e2e-aws-ovn #495 openshift/installer#10727

@openshift-ci

openshift-ci Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

@mfbonfigli: trigger 1 job(s) for the /payload-(with-prs|job|aggregate|job-with-prs|aggregate-with-prs) command

  • periodic-ci-openshift-release-main-ci-5.0-e2e-aws-ovn

See details on https://pr-payload-tests.ci.openshift.org/runs/ci/601f4540-8b2c-11f1-9730-6cf5c066fa5a-0

@openshift-ci

openshift-ci Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

@mfbonfigli: This PR was included in a payload test run from #495
trigger 1 job(s) for the /payload-(with-prs|job|aggregate|job-with-prs|aggregate-with-prs) command

  • periodic-ci-openshift-release-main-ci-5.0-e2e-aws-ovn

See details on https://pr-payload-tests.ci.openshift.org/runs/ci/601f4540-8b2c-11f1-9730-6cf5c066fa5a-0

@mfbonfigli

Copy link
Copy Markdown
Contributor Author

/payload-job-with-prs periodic-ci-openshift-release-main-ci-5.0-upgrade-from-stable-4.22-e2e-aws-ovn-upgrade #495 openshift/installer#10727

@openshift-ci

openshift-ci Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

@mfbonfigli: trigger 1 job(s) for the /payload-(with-prs|job|aggregate|job-with-prs|aggregate-with-prs) command

  • periodic-ci-openshift-release-main-ci-5.0-upgrade-from-stable-4.22-e2e-aws-ovn-upgrade

See details on https://pr-payload-tests.ci.openshift.org/runs/ci/71101fa0-8b2c-11f1-9169-e7bbc2e6a60b-0

@openshift-ci

openshift-ci Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

@mfbonfigli: This PR was included in a payload test run from #495
trigger 1 job(s) for the /payload-(with-prs|job|aggregate|job-with-prs|aggregate-with-prs) command

  • periodic-ci-openshift-release-main-ci-5.0-upgrade-from-stable-4.22-e2e-aws-ovn-upgrade

See details on https://pr-payload-tests.ci.openshift.org/runs/ci/71101fa0-8b2c-11f1-9169-e7bbc2e6a60b-0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants