Update exec credential provider KEP after convo with sig-auth#2023
Update exec credential provider KEP after convo with sig-auth#2023k8s-ci-robot merged 1 commit intokubernetes:masterfrom
Conversation
|
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 Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
| // 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 |
There was a problem hiding this comment.
Open question: is it OK to not include InsecureSkipTLSVerify here? Need to think through what guidance to exec plugins would be.
90a570a to
f204c7a
Compare
|
/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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
ACK. @enj may slay me when he returns, but I'll add this into the struct. :)
There was a problem hiding this comment.
One upside of including
InsecureSkipTLSVerifyinfo 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
| // KUBERNETES_EXEC_INFO environment variable. The KUBERNETES_EXEC_INFO environment | ||
| // variable is expected to contains a serialized client.authentication.k8s.io ExecCredential | ||
| // object. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
might consider names like LoadExecCredentialFromEnv / LoadExecCredential instead
There was a problem hiding this comment.
ACK. I'll rev this description tonight.
There was a problem hiding this comment.
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 |
| // 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). |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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...
| @@ -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. | |||
There was a problem hiding this comment.
nit: note this is only set if provideClusterInfo: true in the exec provider config
|
/ok-to-test /hold go ahead and squash commits, and add the doc to the |
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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>
e93db7b to
433394d
Compare
|
Thanks @liggitt - I updated the |
|
/hold cancel |
Signed-off-by: Andrew Keesler akeesler@vmware.com