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

Add feature gate to disable in-tree credential providers #102507

Conversation

ostrain
Copy link
Contributor

@ostrain ostrain commented Jun 1, 2021

What type of PR is this?

/kind feature

What this PR does / why we need it:

Implementing DisableKubeletCloudCredentialProviders FG according to proposal kubernetes/enhancements#2443

Which issue(s) this PR fixes:

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Introduce a feature gate DisableKubeletCloudCredentialProviders which allows disabling the in-tree kubelet credential providers.

The DisableKubeletCloudCredentialProviders FeatureGate is currently in Alpha, which means is currently disabled by default. Once the FeatureGate moves to beta, in-tree credential providers will be disabled by default, and users will need to migrate to using external credential providers.

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

- [KEP]: https://github.com/kubernetes/enhancements/pull/2443
- [KEP]: https://github.com/kubernetes/enhancements/tree/1a66671cf0e01ceb19f56bfb563100909cb67867/keps/sig-cloud-provider/2133-out-of-tree-credential-provider

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. kind/feature Categorizes issue or PR as related to a new feature. labels Jun 1, 2021
@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


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 added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jun 1, 2021
@k8s-ci-robot
Copy link
Contributor

Welcome @ostrain!

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

Hi @ostrain. Thanks for your PR.

I'm waiting for a kubernetes 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 added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jun 1, 2021
@ostrain
Copy link
Contributor Author

ostrain commented Jun 2, 2021

I believe the CLA should be all set now, commenting to trigger the bot again.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jun 2, 2021
@DangerOnTheRanger
Copy link
Contributor

/ok-to-test

@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 3, 2021
@ostrain
Copy link
Contributor Author

ostrain commented Jun 4, 2021

/sig cloud-provider

@k8s-ci-robot k8s-ci-robot added sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jun 4, 2021
@ostrain ostrain changed the title [WIP] Add feature gate to disable in-tree credential providers Add feature gate to disable in-tree credential providers Jun 4, 2021
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 4, 2021
@cheftako
Copy link
Member

@ostrain
Copy link
Contributor Author

ostrain commented Jul 19, 2021

/retest

pkg/credentialprovider/plugins.go Outdated Show resolved Hide resolved
pkg/credentialprovider/gcp/metadata.go Outdated Show resolved Hide resolved
@ostrain ostrain force-pushed the feature/ostrain/legacy-credential-provider-fg branch from 49f16ae to 8571113 Compare July 19, 2021 20:03
@@ -142,7 +145,17 @@ func onGCEVM() bool {

// Enabled implements DockerConfigProvider for all of the Google implementations.
func (g *MetadataProvider) Enabled() bool {
return onGCEVM()
if credentialprovider.AreLegacyCloudCredentialProvidersDisabled() {
Copy link
Member

Choose a reason for hiding this comment

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

Not sure I agree with this ordering. I agree about the relative costs but if we need to enter either switch the system is miconfigured. At the point the cost seems like a non issue. For the good case you need to pass both switched anyway. In this case we may have a misleading error message suggesting you are on GCP. I think it would be better to put back the original order and add a warning you are attempting to use a GCP credential provider on a non GCP VM to the !onGCEVM case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Avoiding the misleading error message was my original thinking, happy to switch it back.

I'm not sure if the other warning you propose would add much value though: IIUC these credential providers are on by default (thus the need for this PR) so it's not like the user misconfigured something if we're getting this far on a non-GCP VM. The warning would just get logged all the time and wouldn't be actionable.

Copy link
Member

Choose a reason for hiding this comment

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

I thought we would only have this on if it was configured. If thats not true, then I think its even more important to switch back. (As you say to avoid the misleading error message)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switched this back around.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not following the logic here to switch the order back to run onGCEVM first. If the feature gate is enabled (i.e. disabled), then there's no reason to ever call onGCEVM, because the plugin is explicitly disabled. In this case, the warning message makes sense too, because the plugin is disabled anyways. When it is disabled, why bother running onGCEVM which is a relatively expensive operation that reads a file from disk?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With the in-tree cloud providers, you have to pass --cloud-provider=foo to enable them so it makes sense to print a warning if you pass that flag while the feature gate that disables them is turned on, since that's obviously a misconfiguration of either the flag or the feature gate.

With the in-tree credential providers OTOH, there's no flag to enable them (as far as I'm aware) -- we just rely on the onGCEVM check alone. So if the feature gate is turned on but we're not on a GCP VM, there's no reason to print a warning about the GCP provider being disabled... Nothing is misconfigured in that case, the warning is just confusing and unactionable.

Copy link
Member

Choose a reason for hiding this comment

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

Gotcha, thanks for clarifying.

@ostrain
Copy link
Contributor Author

ostrain commented Jul 19, 2021

/retest

@ostrain ostrain force-pushed the feature/ostrain/legacy-credential-provider-fg branch from 8571113 to 5932233 Compare July 19, 2021 22:17
@ostrain
Copy link
Contributor Author

ostrain commented Jul 19, 2021

/retest

@cheftako
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 20, 2021
Copy link
Member

@andrewsykim andrewsykim left a comment

Choose a reason for hiding this comment

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

/assign @liggitt

pkg/credentialprovider/gcp/metadata.go Show resolved Hide resolved
@ostrain ostrain requested a review from liggitt August 2, 2021 18:47
@ostrain ostrain force-pushed the feature/ostrain/legacy-credential-provider-fg branch from 5932233 to 16ce57f Compare August 4, 2021 20:22
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 4, 2021
@ostrain ostrain force-pushed the feature/ostrain/legacy-credential-provider-fg branch from 16ce57f to c1515ad Compare August 4, 2021 20:51
@ostrain
Copy link
Contributor Author

ostrain commented Aug 4, 2021

/retest

2 similar comments
@ostrain
Copy link
Contributor Author

ostrain commented Aug 4, 2021

/retest

@ostrain
Copy link
Contributor Author

ostrain commented Aug 5, 2021

/retest

@ostrain ostrain force-pushed the feature/ostrain/legacy-credential-provider-fg branch from c1515ad to a947c32 Compare August 5, 2021 16:50
@liggitt
Copy link
Member

liggitt commented Aug 5, 2021

/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 Aug 5, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: andrewsykim, Danil-Grigorev, liggitt, ostrain

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 Aug 5, 2021
@k8s-ci-robot k8s-ci-robot merged commit 542829d into kubernetes:master Aug 5, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.23 milestone Aug 5, 2021
@@ -595,6 +595,12 @@ const (
// Disable any functionality in kube-apiserver, kube-controller-manager and kubelet related to the `--cloud-provider` component flag.
DisableCloudProviders featuregate.Feature = "DisableCloudProviders"

// owner: @andrewsykim
// alpha: v1.22
Copy link
Member

Choose a reason for hiding this comment

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

NIT: just see this: it would be 1.23

Copy link
Member

Choose a reason for hiding this comment

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

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. 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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants