Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for azure workload identity #5390

Conversation

stijndehaes
Copy link
Contributor

Which component this PR applies to?

What type of PR is this?

/kind feature

What this PR does / why we need it:

It adds support for workload identity to the cluster autoscaler on azure

Which issue(s) this PR fixes:

None

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Added support for workload identity on azure to the cluster autoscaler 

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Dec 28, 2022
@k8s-ci-robot
Copy link
Contributor

Welcome @stijndehaes!

It looks like this is your first PR to kubernetes/autoscaler 🎉. 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/autoscaler 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. 😃

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Dec 28, 2022
@stijndehaes stijndehaes force-pushed the feature/add-support-for-workload-identity branch 3 times, most recently from f8126b7 to 8b045b1 Compare December 28, 2022 09:57
Copy link
Contributor

@tallaxes tallaxes left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution! Could you please describe the use case this is targeting (or link to an existing issue)?

Comment on lines +160 to +166
if tenantId := os.Getenv("AZURE_TENANT_ID"); tenantId != "" {
cfg.TenantID = tenantId
}
cfg.AADClientID = os.Getenv("ARM_CLIENT_ID")
if clientId := os.Getenv("AZURE_CLIENT_ID"); clientId != "" {
cfg.AADClientID = clientId
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This lets one override ARM_TENANT/CLIENT_ID with AZURE_TENANT/CLIENT_ID. It is not clear why supporting this is needed (if there is a good reason, please explain) and it introduces (an admittedly small) risk of breaking existing deployments. Most importantly, this is not related to introducing workload identity, which is the target of this PR. Please remove, and - if there is a good reason - introduce in a separate PR.

Copy link
Member

Choose a reason for hiding this comment

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

why doing an override here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These override are here because of the project https://github.com/Azure/azure-workload-identity,
The default environment values it sets are:

  • AZURE_TENANT_ID
  • AZURE_CLIENT_ID
  • AZURE_FEDERATED_TOKEN_FILE
  • AZURE_AUTHORITY_HOST

To have better interoperability I added these aliases. I can remove them though and add them in a new PR

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for sharing the contexts, it makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@feiskyer thank you for the feedback!

Comment on lines 98 to 102
# azureUseWorkloadIdentityExtension -- Whether to use Azure's workload identity extension for credentials.
azureUseWorkloadIdentityExtension: false

# azureUseManagedIdentityExtension -- Whether to use Azure's managed identity extension for credentials. If using MSI, ensure subscription ID, resource group, and azure AKS cluster name are set.
azureUseManagedIdentityExtension: false
Copy link
Contributor

Choose a reason for hiding this comment

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

Only one of these can be used at a time (if both are set, the current implementation will use workload identity). Please document (and consider adding a check in code that both are not set at the same time).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added an error in the code, and added documentation that you should not set both

@tallaxes
Copy link
Contributor

tallaxes commented Jan 9, 2023

/label area/provider/azure

@k8s-ci-robot
Copy link
Contributor

@tallaxes: The label(s) /label area/provider/azure cannot be applied. These labels are supported: api-review, tide/merge-method-merge, tide/merge-method-rebase, tide/merge-method-squash, team/katacoda, refactor. Is this label configured under labels -> additional_labels or labels -> restricted_labels in plugin.yaml?

In response to this:

/label area/provider/azure

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.

@feiskyer
Copy link
Member

/area provider/azure

@k8s-ci-robot k8s-ci-robot added the area/provider/azure Issues or PRs related to azure provider label Jan 10, 2023
@@ -95,6 +95,9 @@ azureClusterName: ""
# Required if `cloudProvider=azure`
azureNodeResourceGroup: ""

# azureUseWorkloadIdentityExtension -- Whether to use Azure's workload identity extension for credentials.
azureUseWorkloadIdentityExtension: false
Copy link
Member

Choose a reason for hiding this comment

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

+1 to mention here WorkloadIdentity couldn't be used together with other author approaches.

Copy link
Member

Choose a reason for hiding this comment

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

And how AADFederatedTokenFile could be set in the helm chart?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added documentation to the readme

@stijndehaes stijndehaes force-pushed the feature/add-support-for-workload-identity branch from 8b045b1 to 2f3fb3f Compare January 10, 2023 14:12
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 10, 2023
@stijndehaes stijndehaes force-pushed the feature/add-support-for-workload-identity branch 2 times, most recently from 24a3d4b to e9366fd Compare January 10, 2023 14:16
Copy link
Member

@feiskyer feiskyer left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 11, 2023
@feiskyer
Copy link
Member

@gjtempleton could you help to review the charts changes?

@stijndehaes stijndehaes requested review from tallaxes and removed request for gjtempleton January 19, 2023 15:20
@stijndehaes
Copy link
Contributor Author

@gjtempleton friendly reminder to help with the review of the chart changes :)
@tallaxes if you could give feedback on the changes I made on your feedback that would be great!

@tallaxes
Copy link
Contributor

/lgtm

@tallaxes
Copy link
Contributor

/assign @gjtempleton

Copy link
Contributor

@tallaxes tallaxes left a comment

Choose a reason for hiding this comment

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

/lgtm

@tallaxes
Copy link
Contributor

/assign @gjtempleton

Copy link
Member

@gjtempleton gjtempleton left a comment

Choose a reason for hiding this comment

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

One request and a couple of tiny typos, but otherwise this LGTM, thanks for the PR!

charts/cluster-autoscaler/Chart.yaml Outdated Show resolved Hide resolved
charts/cluster-autoscaler/values.yaml Outdated Show resolved Hide resolved
charts/cluster-autoscaler/values.yaml Outdated Show resolved Hide resolved
@stijndehaes stijndehaes force-pushed the feature/add-support-for-workload-identity branch from e9366fd to 5959e07 Compare January 23, 2023 09:13
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 23, 2023
@stijndehaes
Copy link
Contributor Author

One request and a couple of tiny typos, but otherwise this LGTM, thanks for the PR!

@gjtempleton I implemented the changes! Thank you for the review.

@stijndehaes
Copy link
Contributor Author

@gjtempleton @tallaxes @feiskyer Can you guys give me a last LGTM or tell me what needs to be changed still? :)

Copy link
Member

@feiskyer feiskyer left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 1, 2023
charts/cluster-autoscaler/Chart.yaml Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Feb 1, 2023
@stijndehaes stijndehaes force-pushed the feature/add-support-for-workload-identity branch from 704857d to ef295a3 Compare February 1, 2023 14:33
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 1, 2023
@stijndehaes
Copy link
Contributor Author

@gjtempleton thank you for checking, I have made the changes. If ok can you approve?

@feiskyer I am going to need your approval again sorry for this.

@gjtempleton
Copy link
Member

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 1, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: feiskyer, gjtempleton, stijndehaes, tallaxes

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

The pull request process is described 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 k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 1, 2023
@k8s-ci-robot k8s-ci-robot merged commit 9158196 into kubernetes:master Feb 1, 2023
@stijndehaes stijndehaes deleted the feature/add-support-for-workload-identity branch February 2, 2023 07:13
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. area/cluster-autoscaler area/helm-charts area/provider/azure Issues or PRs related to azure provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants