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

separate RootCAConfigMap from BoundServiceAccountTokenVolume #96197

Merged
merged 1 commit into from Nov 5, 2020

Conversation

zshihang
Copy link
Contributor

@zshihang zshihang commented Nov 3, 2020

What type of PR is this?

/kind feature

What this PR does / why we need it:
before BoundServiceAccountTokenVolume graduate to Beta, kube-controller-manager needs to publish kube-root-ca.crt to every namespace. In the multi-server cluster upgrade, a leading old kube-controller-manager might not publish the configmap for a short period of time. However, during the period, new pods may have the new projected tokens and as a result, those pods will fail to start.

Which issue(s) this PR fixes:

Special notes for your reviewer:

Does this PR introduce a user-facing change?:
-->

The beta `RootCAConfigMap` feature gate is enabled by default and causes kube-controller-manager to publish a "kube-root-ca.crt" ConfigMap to every namespace. This ConfigMap contains a CA bundle used for verifying connections to the kube-apiserver.

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

- [KEP]: https://github.com/kubernetes/enhancements/tree/master/keps/sig-auth/1205-bound-service-account-tokens

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. 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. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Nov 3, 2020
@zshihang
Copy link
Contributor Author

zshihang commented Nov 3, 2020

/cc @liggitt @mikedanese

@zshihang
Copy link
Contributor Author

zshihang commented Nov 3, 2020

/sig auth
/priority important-soon
/triage accepted

@k8s-ci-robot k8s-ci-robot added sig/auth Categorizes an issue or PR as relevant to SIG Auth. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Nov 3, 2020
@k8s-ci-robot k8s-ci-robot added the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Nov 3, 2020
@k8s-ci-robot k8s-ci-robot added area/test sig/testing Categorizes an issue or PR as relevant to SIG Testing. labels Nov 3, 2020
@zshihang
Copy link
Contributor Author

zshihang commented Nov 3, 2020

/cc @neolit123

@neolit123
Copy link
Member

neolit123 commented Nov 3, 2020

suggesting minor reword of the release note:

separate a new feature gate RootCAConfigMap from the BoundServiceAccountTokenVolume feature gate and graduate it to Beta. kube-controller-manager will now publish a "kube-root-ca.crt" ConfigMap to every namespace by default.

//
// Allows kube-controller-manager to publish kube-root-ca.crt configmap to
// every namespace. This feature is separated from BoundServiceAccountTokenVolume
// to solve multi-server cluster upgrade issue.
Copy link
Member

Choose a reason for hiding this comment

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

potentially we can omit the second sentence here that explains the upgrade issue and instead include a mention that BoundServiceAccountTokenVolume requires RootCAConfigMap.

deferring to sig-auth, though.

Copy link
Member

Choose a reason for hiding this comment

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

agree the separation is not important, just that it is a prereq of BoundServiceAccountTokenVolume

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

- events
verbs:
- create
- patch
Copy link
Member

Choose a reason for hiding this comment

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

does rootcacertpublisher need "patch" for events?

Copy link
Member

Choose a reason for hiding this comment

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

yes, that's part of the standard event permissions used by the event recorder:

func eventsRule() rbacv1.PolicyRule {
return rbacv1helpers.NewRule("create", "update", "patch").Groups(legacyGroup, eventsGroup).Resources("events").RuleOrDie()
}

Copy link
Member

@liggitt liggitt left a comment

Choose a reason for hiding this comment

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

add validation that makes sure RootCAConfigMap is enabled if BoundServiceAccountTokenVolume is enabled, and update the doc on RootCAConfigMap as noted

lgtm otherwise

- events
verbs:
- create
- patch
Copy link
Member

Choose a reason for hiding this comment

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

yes, that's part of the standard event permissions used by the event recorder:

func eventsRule() rbacv1.PolicyRule {
return rbacv1helpers.NewRule("create", "update", "patch").Groups(legacyGroup, eventsGroup).Resources("events").RuleOrDie()
}

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. area/apiserver and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 4, 2020
@zshihang
Copy link
Contributor Author

zshihang commented Nov 4, 2020

/retest

ginkgo.It("should guarantee kube-root-ca.crt exist in any namespace", func() {
const rootCAConfigMapName = "kube-root-ca.crt"

_, err := f.ClientSet.CoreV1().ConfigMaps(f.Namespace.Name).Get(context.TODO(), rootCAConfigMapName, metav1.GetOptions{})
Copy link
Member

Choose a reason for hiding this comment

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

the configmap might not exist instantly in the new test namespace (it's created by a controller), so this should be a wait.PollImmediate with a wait.ForeverTestTimeout

framework.ExpectNoError(wait.PollImmediate(time.Second, wait.ForeverTestTimetout, func() (bool, error) {
  _, err := f.ClientSet.CoreV1().ConfigMaps(f.Namespace.Name).Get(context.TODO(), rootCAConfigMapName, metav1.GetOptions{})
  if err == nil {
    return true, nil
  }
  if errors.IsNotFound(err) {
    framework.Logf("root ca configmap not found, retrying")
    return false, nil
  }
  return false, err
}))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

test/e2e/auth/service_accounts.go Outdated Show resolved Hide resolved
test/e2e/auth/service_accounts.go Outdated Show resolved Hide resolved
test/e2e/auth/service_accounts.go Outdated Show resolved Hide resolved
test/e2e/auth/service_accounts.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added the sig/apps Categorizes an issue or PR as relevant to SIG Apps. label Nov 4, 2020
@zshihang
Copy link
Contributor Author

zshihang commented Nov 4, 2020

/retest

1 similar comment
@zshihang
Copy link
Contributor Author

zshihang commented Nov 5, 2020

/retest

@liggitt
Copy link
Member

liggitt commented Nov 5, 2020

Both e2e failures look related. The config map quota test might need to be adjusted. I'm surprised we have a conformance test that fails if anything else creates a config map in the name space. That does not seem right

@zshihang
Copy link
Contributor Author

zshihang commented Nov 5, 2020

the config map quota test is just flaky.

defaultConfigMaps := fmt.Sprintf("%d", found)

if found does count the kube-root-ca.crt, then the test will pass. otherwise not.

@liggitt
Copy link
Member

liggitt commented Nov 5, 2020

bazel failure is #96243
/retest

@liggitt
Copy link
Member

liggitt commented Nov 5, 2020

/lgtm
/approve

please open a doc update against the dev-1.20 branch of the website, adding details about this feature gate and beta status

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: liggitt, zshihang

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 Nov 5, 2020
@k8s-ci-robot k8s-ci-robot merged commit 8bdd10b into kubernetes:master Nov 5, 2020
@liggitt
Copy link
Member

liggitt commented Nov 5, 2020

opened #96265 to reduce the test flake, but the mechanism that test uses to detect existing configmaps is questionable

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/apiserver area/test 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. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Development

Successfully merging this pull request may close these issues.

None yet

4 participants