Skip to content

Update exec credential provider KEP after convo with sig-auth#2023

Merged
k8s-ci-robot merged 1 commit intokubernetes:masterfrom
ankeesler:more-exec-cred-updates
Oct 9, 2020
Merged

Update exec credential provider KEP after convo with sig-auth#2023
k8s-ci-robot merged 1 commit intokubernetes:masterfrom
ankeesler:more-exec-cred-updates

Conversation

@ankeesler
Copy link
Copy Markdown
Contributor

Signed-off-by: Andrew Keesler akeesler@vmware.com

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 28, 2020
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @ankeesler. 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.

Details

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-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Sep 28, 2020
@k8s-ci-robot k8s-ci-robot added kind/kep Categorizes KEP tracking issues and PRs modifying the KEP directory size/M Denotes a PR that changes 30-99 lines, ignoring generated files. sig/auth Categorizes an issue or PR as relevant to SIG Auth. labels Sep 28, 2020
// To ensure that this struct contains everything someone would need to communicate
// with a kubernetes cluster (just like they would via a kubeconfig), the fields
// should shadow "k8s.io/client-go/tools/clientcmd/api/v1".Cluster, with the exception
// of InsecureSkipVerify (in order to discourage its use) and CertificateAuthority
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Open question: is it OK to not include InsecureSkipTLSVerify here? Need to think through what guidance to exec plugins would be.

@ankeesler ankeesler force-pushed the more-exec-cred-updates branch from 90a570a to f204c7a Compare September 28, 2020 12:25
@ankeesler
Copy link
Copy Markdown
Contributor Author

/assign @liggitt

I'm also wondering if @mikedanese would be interested in taking a look at this since I believe he did a lot of the original review on this KEP.

To ensure that the `Cluster` struct maintains the same cluster connection
capabilities as one gets from a `kubeconfig`, the `Cluster` fields (Go and JSON) must
be named the same as `"k8s.io/client-go/tools/clientcmd/api/v1".Cluster`, with the
exception of `InsecureSkipTLSVerify`, which has been left out to discourage its use, and
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thinking about this more, I think we should include InsecureSkipTLSVerify.

If the kubeconfig has insecure-skip-tls-verify: true set, whatever credentials the auth plugin returns will be happily sent by client-go without verifying TLS.

If we omit this, I anticipate some auth plugins trying connections with insecure TLS as a fallback "just in case" that's how the user's kubeconfig was set up.

One upside of including InsecureSkipTLSVerify info is that it would allow credential providers to detect if replayable tokens they planned to return would be used in an insecure context, and to refuse.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ACK. @enj may slay me when he returns, but I'll add this into the struct. :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One upside of including InsecureSkipTLSVerify info is that it would allow credential providers to detect if replayable tokens they planned to return would be used in an insecure context, and to refuse.

That's how I talked myself into this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You speak truth!

Comment on lines +373 to +375
// KUBERNETES_EXEC_INFO environment variable. The KUBERNETES_EXEC_INFO environment
// variable is expected to contains a serialized client.authentication.k8s.io ExecCredential
// object.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

in the implementation, account for the fact that this envvar was already used in v1alpha1 and sent a serialized ExecCredential which did not include connection info

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

describe the behavior in the following scenarios (well-known error, etc?):

  • the envvar is not set
  • the envvar is set to an empty string
  • the envvar cannot be decoded (because it is malformed)
  • the envvar cannot be decoded (because it contains an unrecognized type)

or document that in LoadCluster and indicate this delegates to that

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

might consider names like LoadExecCredentialFromEnv / LoadExecCredential instead

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ACK. I'll rev this description tonight.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

well-known error

I am thinking here that a plugin that wants to use cluster info looks like this:

func main() {
  ec, rc, err := exec.LoadExecCredentialFromEnv()
  if err != nil {
    [0]
  }
  ...
}

The plugin will probably do something like fmt.Println(err); os.Exit(1); in [0]. I can't imagine that they would want to branch on what that error return is. If the exec plugin can't get the cluster information, I would hope that it doesn't sacrifice any security properties and just quits. Seems like it makes the package API surface easier to consume if we return opaque errors from these functions. If I am wrong about this assumption, then we should be able to update this package with those error helpers in a backwards compatible manner.

might consider names

I'll move forward with LoadExecCredential* to optimize for readability and speed of consensus, but I will mention that the original reason I went with Load is because the package name was exec and I had hoped that exec.Load() read as "load information necessary to do exec stuff".

in this new package and the new package can safely depend on
`k8s.io/client-go/rest`. The helper functions are as follows.

```golang
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: go

Comment on lines +384 to +385
// 2. a runtime.Object from the ExecCredential.Spec.Cluster.Config field into
// the provided into runtime.Object (into can be nil to ignore this field).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

would it be simpler to do

func LoadCluster(data []byte) (execCredential runtime.Object, *rest.Config, error)

and let them type-assert the version they expect and get their exec config from execCredential.spec.cluster.config themselves?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes? Probably? You would have a better gut feel for this so I am tempted to go with the function signature that you proposed.

Your function signature gets rid of an error case where someone calls LoadCluster(data, &corev1.Pod{}) on my function signature. So I think I do like your's better.

I suppose injecting references for return values is nice in situations where you want the caller to be able to allocate the memory necessary for an object, but I won't be able to outsmart the Go compiler here, and it's 2020 so why even worry about memory...

@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 Oct 9, 2020
@@ -253,38 +268,66 @@ type ExecCredential struct {
type ExecCredentialSpec struct {
// Cluster contains information to allow an exec plugin to communicate with the
// kubernetes cluster being authenticated to.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: note this is only set if provideClusterInfo: true in the exec provider config

@liggitt
Copy link
Copy Markdown
Member

liggitt commented Oct 9, 2020

/ok-to-test
/approve

/hold go ahead and squash commits, and add the doc to the *Cluster field about when it is populated

@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. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 9, 2020
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

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

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

The pull request process is described here

Details 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 Oct 9, 2020
Some specifics about the contents of this PR:
- refer to named extension correctly (see 3df8de5)
- update Config field with impl doc
- note that Cluster is kubeconfig shadow
- add Cluster reader helper method
- say when Cluster is set

Signed-off-by: Andrew Keesler <akeesler@vmware.com>
@ankeesler ankeesler force-pushed the more-exec-cred-updates branch from e93db7b to 433394d Compare October 9, 2020 14:48
@ankeesler
Copy link
Copy Markdown
Contributor Author

Thanks @liggitt - I updated the *Cluster doc and squashed into a single commit.

@liggitt
Copy link
Copy Markdown
Member

liggitt commented Oct 9, 2020

/hold cancel
/lgtm

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 9, 2020
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 9, 2020
@k8s-ci-robot k8s-ci-robot merged commit 118b30f into kubernetes:master Oct 9, 2020
@k8s-ci-robot k8s-ci-robot added this to the v1.20 milestone Oct 9, 2020
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/kep Categorizes KEP tracking issues and PRs modifying the KEP directory 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. sig/auth Categorizes an issue or PR as relevant to SIG Auth. 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.

3 participants