cluster-api-provider-azure icon indicating copy to clipboard operation
cluster-api-provider-azure copied to clipboard

Remove projected service account volume for workload identity

Open JRBANCEL opened this issue 10 months ago • 11 comments

What type of PR is this?

/kind bug /kind cleanup

What this PR does / why we need it: See https://github.com/kubernetes-sigs/cluster-api-provider-azure/issues/4681.

Currently, in the manager spec, the projected volume for the service account token is manually specified.

The Workload Identity webhook takes care of this (and more) as seen here.

It is better to rely on the webhook because it is more future proof and removes YAML lines. Not only this, but as explained in https://github.com/kubernetes-sigs/cluster-api-provider-azure/issues/4681, not relying on the webhook makes it impossible to use cluster-api-provider-azure inside a vCluster on AKS with Workload Identity.

With this change, the resulting Pod spec in a vanilla case (i.e. not inside vCluster) is completely identical (webhook sets the volume), and it also works in vCluster because the Workload Identity webhook (on the host cluster) will do what is needed.

Which issue(s) this PR fixes: Fixes #4681

TODOs:

  • [X] squashed commits
  • [ ] includes documentation
  • [ ] adds unit tests

Release note:

NONE

JRBANCEL avatar Mar 28 '24 16:03 JRBANCEL

[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 timothysc for approval. For more information see the Kubernetes Code Review Process.

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

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

k8s-ci-robot avatar Mar 28 '24 16:03 k8s-ci-robot

Welcome @JRBANCEL!

It looks like this is your first PR to kubernetes-sigs/cluster-api-provider-azure 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/cluster-api-provider-azure has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. :smiley:

k8s-ci-robot avatar Mar 28 '24 16:03 k8s-ci-robot

Hi @JRBANCEL. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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/test-infra repository.

k8s-ci-robot avatar Mar 28 '24 16:03 k8s-ci-robot

/ok-to-test

dtzar avatar Mar 28 '24 16:03 dtzar

Since we don't currently install the webhooks in our e2e tests, I'd expect the existing Workload Identity test to fail:

/test pull-cluster-api-provider-azure-e2e-optional

Introducing a requirement to install the webhooks would be a breaking change. Is there a way we could instead annotate the CAPZ pod so that the webhook ignores it? That kind of change I'd feel okay about backporting now and would at least buy us some time to solicit feedback on requiring the WorkloadIdentity webhooks and planning a transition if we find that's a better long-term solution.

nojnhuh avatar Mar 28 '24 16:03 nojnhuh

Introducing a requirement to install the webhooks would be a breaking change.

Is using Workload Identity on AKS without the WI webhook even supported? Official documentation requires to specify --enable-workload-identity which installs the WI webhook, no?

Is there a way we could instead annotate the CAPZ pod so that the webhook ignores it?

For https://github.com/kubernetes-sigs/cluster-api-provider-azure/issues/4681, no. Because we need the WI magic to be done on the host cluster (via webhook) and not at the source (inside vCluster).

JRBANCEL avatar Mar 28 '24 16:03 JRBANCEL

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 62.73%. Comparing base (d0f78e0) to head (51f03e4). Report is 561 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4682      +/-   ##
==========================================
+ Coverage   62.71%   62.73%   +0.01%     
==========================================
  Files         192      192              
  Lines       15641    15641              
==========================================
+ Hits         9810     9812       +2     
+ Misses       5148     5146       -2     
  Partials      683      683              

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Mar 28 '24 16:03 codecov[bot]

@sonasingh46 do share your thoughts 🙏

mjnovice avatar Mar 28 '24 23:03 mjnovice

@JRBANCEL @mjnovice This change may work for vcluster scenarios, but it will break existing WI use cases in non-vcluster scenarios.

What are you doing right now to make this work? Are you manually updating the capz-controller-manager Deployment resource after you bootstrap your mgmt cluster on your vcluster?

jackfrancis avatar Apr 11 '24 16:04 jackfrancis

@jackfrancis we are currently using kyverno to do tylhe patching on the host cluster.

mjnovice avatar Apr 11 '24 22:04 mjnovice

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Jul 10 '24 22:07 k8s-triage-robot

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

Test name Commit Details Required Rerun command
pull-cluster-api-provider-azure-e2e-optional 51f03e426020d362bc6b736fd3a9429dcec2ed72 link false /test pull-cluster-api-provider-azure-e2e-optional
pull-cluster-api-provider-azure-e2e-aks 51f03e426020d362bc6b736fd3a9429dcec2ed72 link true /test pull-cluster-api-provider-azure-e2e-aks
pull-cluster-api-provider-azure-ci-entrypoint 51f03e426020d362bc6b736fd3a9429dcec2ed72 link true /test pull-cluster-api-provider-azure-ci-entrypoint

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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.

k8s-ci-robot avatar Jul 31 '24 21:07 k8s-ci-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle rotten
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot avatar Aug 30 '24 21:08 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Reopen this PR with /reopen
  • Mark this PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

k8s-triage-robot avatar Sep 29 '24 21:09 k8s-triage-robot

@k8s-triage-robot: Closed this PR.

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Reopen this PR with /reopen
  • Mark this PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

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.

k8s-ci-robot avatar Sep 29 '24 21:09 k8s-ci-robot