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

chore: Allow to set automountServiceAccountToken in ServiceAccount #1619

Merged
merged 1 commit into from
Jun 16, 2023

Conversation

kahirokunn
Copy link
Contributor

@kahirokunn kahirokunn commented May 29, 2023

Is this a bug fix or adding new feature?

new feature

What is this PR about? / Why do we need it?

https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.24.md#urgent-upgrade-notes

The LegacyServiceAccountTokenNoAutoGeneration feature gate is beta, and enabled by default. When enabled, Secret API objects containing service account tokens are no longer auto-generated for every ServiceAccount. Use the TokenRequest API to acquire service account tokens, or if a non-expiring token is required, create a Secret API object for the token controller to populate with a service account token by following this guide. (kubernetes/kubernetes#108309, @zshihang)

Since k8s 1.24, TOKEN is not mounted automatically.
If you want to access with IRSA, you need to use a token.

Allow to set automountServiceAccountToken in ServiceAccount
https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/

What testing is done?

done.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 29, 2023
@k8s-ci-robot
Copy link
Contributor

Welcome @kahirokunn!

It looks like this is your first PR to kubernetes-sigs/aws-ebs-csi-driver 🎉. 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/aws-ebs-csi-driver 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 needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 29, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @kahirokunn. 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 k8s-ci-robot requested review from gtxu and rdpsin May 29, 2023 04:16
@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label May 29, 2023
Copy link
Contributor

@ConnorJC3 ConnorJC3 left a comment

Choose a reason for hiding this comment

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

Needs testing with IRSA:

If this breaks IRSA, it should default on

If this doesn't break IRSA, I think we should consider just setting it to false directly, rather than exposing an option (as the option should never matter)

Otherwise lgtm, I'll test and report back on IRSA interactions

@kahirokunn
Copy link
Contributor Author

@ConnorJC3
In ServiceAccounts that use IRSA in the world, everyone has the accountServiceAccountToken set to True by default.
I actually think it is better that way.
Would you change it that way?

Copy link
Contributor

@ConnorJC3 ConnorJC3 left a comment

Choose a reason for hiding this comment

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

Actually, upon further reflection, I think this is fine as is. There are usecases where we need the creds, such as the node untainting feature, so this config should be left up to the user.

lgtm, cc @torredil for review

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

/retest
/lgtm

Hey there, thanks for your contribution. Just one quick thing from me:

  • Could we update the docs? the parameter name is pretty intuitive, but ideally new configurable parameters should be documented as it helps other users understand what the parameter does (and why they might want to set it to true or false).

Some general feedback: Suggest providing more context in the PR description. We mention that we're allowing users to configure the parameter and link to the relevant docs -- which is very helpful -- but it would be excellent to explain why a user might want to configure this setting and the implications for doing so. I've had some success in situations like this in the past by spending a few extra minutes providing clarity which might help reviewers get your changes merged in a timely manner 👍

@ConnorJC3
Copy link
Contributor

/ok-to-test
/retest

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 14, 2023
@kahirokunn kahirokunn changed the title chore: Allow to set accountServiceAccountToken in ServiceAccount chore: Allow to set automountServiceAccountToken in ServiceAccount Jun 15, 2023
@k8s-ci-robot k8s-ci-robot added do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Jun 15, 2023
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jun 15, 2023
@kahirokunn
Copy link
Contributor Author

@torredil Okay. How about now?

Copy link
Member

@torredil torredil 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 @kahirokunn /lgtm

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

@torredil https://github.com/aws/eks-charts/blob/620e0169ec96d79086f004235d7b1764a60dbc40/stable/aws-load-balancer-controller/values.yaml#L25
By the way, aws-load-balancer-controller was true by default.
I think the same default of true would be fine, what do you think?

@kahirokunn
Copy link
Contributor Author

Since there are other environments than the EKS environment, default false may be acceptable.

@kahirokunn
Copy link
Contributor Author

Either is fine.
Can't wait to be merged. 🙌

@ConnorJC3
Copy link
Contributor

/hold

@kahirokunn yeah, I think we should set this to default true. The large majority of our users use IRSA, so changing this out from under them would be a poor experience.

Once the default is changed (don't forget to regenerate the kustomize files too), I can merge this in 👍

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 15, 2023
@kahirokunn
Copy link
Contributor Author

@ConnorJC3 thx. done. 👍

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 15, 2023
@kahirokunn kahirokunn force-pushed the master branch 2 times, most recently from 4ff7a8c to 9a30a54 Compare June 16, 2023 00:26
@k8s-ci-robot
Copy link
Contributor

@kahirokunn: 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
pull-aws-ebs-csi-driver-test-e2e-external-eks-windows 9a30a54 link false /test pull-aws-ebs-csi-driver-test-e2e-external-eks-windows

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

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Jun 16, 2023
@ConnorJC3
Copy link
Contributor

I went ahead and manually cleaned the commit message to make the bot happy.

/remove-hold
/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Jun 16, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ConnorJC3

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 Jun 16, 2023
@k8s-ci-robot k8s-ci-robot merged commit 2f6d226 into kubernetes-sigs:master Jun 16, 2023
@liggitt
Copy link

liggitt commented Jul 13, 2023

Since k8s 1.24, TOKEN is not mounted automatically.

This is not accurate, kubernetes 1.24 still mounts tokens as it did before. Those tokens are no longer stored in Secret API objects, but are still mounted by default.

@@ -29,7 +29,8 @@ For more information, review ["Creating the Amazon EBS CSI driver IAM role for s

There are several methods to grant the driver IAM permissions:
* Using IAM [instance profile](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2_instance-profiles.html) - attach the policy to the instance profile IAM role and turn on access to [instance metadata](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html) for the instance(s) on which the driver Deployment will run
* EKS only: Using [IAM roles for ServiceAccounts](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html) - create an IAM role, attach the policy to it, then follow the IRSA documentation to associate the IAM role with the driver Deployment service account, which if you are installing via Helm is determined by value `controller.serviceAccount.name`, `ebs-csi-controller-sa` by default
* EKS only: Using [IAM roles for ServiceAccounts](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html) - create an IAM role, attach the policy to it, then follow the IRSA documentation to associate the IAM role with the driver Deployment service account, which if you are installing via Helm is determined by value `controller.serviceAccount.name`, `ebs-csi-controller-sa` by default. If you are using k8s 1.24 or higher, the ServiceAccountToken is not mounted because the `LegacyServiceAccountTokenNoAutoGeneration` feature gate is enabled.
Therefore, if you are using k8s 1.24 or higher, you need to set `true` to `controller.serviceAccount.autoMountServiceAccountToken`.
Copy link

@namgk namgk Sep 5, 2023

Choose a reason for hiding this comment

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

what if you don't install using HELM, what's the way to set this automountServiceAccountToken? For example, people might install through aws eks create-addon --addon-name aws-ebs-csi-driver.

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'd like to know too.

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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants