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

--as-uid flag in kubectl and kubeconfigs. #105794

Merged
merged 1 commit into from Nov 8, 2021

Conversation

margocrawf
Copy link
Contributor

What type of PR is this?

kind/feature

What this PR does / why we need it:

Adds --as-uid flag in kubectl and user.as-uid key for kubeconfigs.

This corresponds to previous work to allow impersonating UIDs:

This change includes:

  • Changes to config_flags.go to allow the as-uid flag to be set
  • Changes to api.AuthInfo to add the ImpersonateUID field
  • Changes to v1.AuthInfo to add ImpersonateUID field
  • Integration tests for the flag and the kubeconfig value that create a CertificateSigningRequest and ensure that the API server populates the correct impersonated spec.uid upon creation.

Which issue(s) this PR fixes:

This is further work towards #93699

Does this PR introduce a user-facing change?

Adds --as-uid flag to kubectl to allow uid impersonation in the same way as user and group impersonation.

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


@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. 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. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 20, 2021
@k8s-ci-robot
Copy link
Contributor

Hi @margocrawf. 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 the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Oct 20, 2021
@k8s-ci-robot k8s-ci-robot added area/test sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/cli Categorizes an issue or PR as relevant to SIG CLI. sig/testing Categorizes an issue or PR as relevant to SIG Testing. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Oct 20, 2021
@enj
Copy link
Member

enj commented Oct 21, 2021

/triage accepted
/assign
/ok-to-test
/milestone v1.23
/priority important-longterm
/kind feature
/sig auth

@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. triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 21, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.23 milestone Oct 21, 2021
@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. sig/auth Categorizes an issue or PR as relevant to SIG Auth. and removed 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. do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Oct 21, 2021
@enj enj added this to Needs Triage in SIG Auth Old Oct 25, 2021
@enj enj moved this from Needs Triage to In Review in SIG Auth Old Oct 25, 2021
Copy link
Member

@enj enj left a comment

Choose a reason for hiding this comment

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

Minor stuff.

@@ -63,6 +63,13 @@ run_impersonation_tests() {
kube::test::get_object_assert 'csr/foo' '{{len .spec.groups}}' '4'
kube::test::get_object_assert 'csr/foo' '{{range .spec.groups}}{{.}} {{end}}' 'group2 group1 ,,,chameleon system:authenticated '
kubectl delete -f hack/testdata/csr.yml "${kube_flags_with_token[@]:?}"

# --as-uid
Copy link
Member

Choose a reason for hiding this comment

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

Add a failure case for validation errors.

Comment on lines +273 to +275
as-groups:
- group2
- group1
Copy link
Member

Choose a reason for hiding this comment

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

Also impersonate extra and assert it below.

kubectl config view --raw > "${TMPDIR:-/tmp}"/impersonateconfig.yaml
cat << EOF >> "${TMPDIR:-/tmp}"/impersonateconfig.yaml
users:
- name: admin-as-userb
Copy link
Member

Choose a reason for hiding this comment

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

Add a failing test case for impersonating uid without user here as well.

config.AuthInfos["user"] = &clientcmdapi.AuthInfo{
Impersonate: "user",
ImpersonateUID: "abc123",
ImpersonateGroups: []string{"group-1", "group-2"},
Copy link
Member

Choose a reason for hiding this comment

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

extra?

SIG Auth Old automation moved this from In Review to Changes Requested Nov 5, 2021
@enj enj moved this from Changes Requested to In Review in SIG Auth Old Nov 5, 2021
@enj
Copy link
Member

enj commented Nov 5, 2021

/lgtm
/approve

/assign @soltysh @liggitt
(for cli-runtime and client-go changes)

@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, 2021
This corresponds to previous work to allow impersonating UIDs:
* Introduce Impersonate-UID header: kubernetes#99961
* Add UID to client-go impersonation config kubernetes#104483

Signed-off-by: Margo Crawford <margaretc@vmware.com>
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 5, 2021
@enj
Copy link
Member

enj commented Nov 5, 2021

/lgtm

@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, 2021
@liggitt
Copy link
Member

liggitt commented Nov 8, 2021

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: enj, liggitt, margocrawf

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 8, 2021
@k8s-ci-robot k8s-ci-robot merged commit c9baa14 into kubernetes:master Nov 8, 2021
SIG Auth Old automation moved this from In Review to Closed / Done Nov 8, 2021
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/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. 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/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/cli Categorizes an issue or PR as relevant to SIG CLI. 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.
Projects
Archived in project
SIG Auth Old
Closed / Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants