@@ -664,7 +664,7 @@ rules:
664
664
665
665
# # client-go credential plugins
666
666
667
- {{< feature-state for_k8s_version="v1.10" state="alpha" >} }
667
+ {% assign for_k8s_version="v1.11" %}{% include feature- state-beta.md % }
668
668
669
669
` k8s.io/client-go` and tools using it such as `kubectl` and `kubelet` are able to execute an
670
670
external command to receive user credentials.
@@ -675,8 +675,6 @@ protocol specific logic, then returns opaque credentials to use. Almost all cred
675
675
use cases require a server side component with support for the [webhook token authenticator](#webhook-token-authentication)
676
676
to interpret the credential format produced by the client plugin.
677
677
678
- As of 1.10 only bearer tokens are supported. Support for client certs may be added in a future release.
679
-
680
678
# ## Example use case
681
679
682
680
In a hypothetical use case, an organization would run an external service that exchanges LDAP credentials
@@ -707,11 +705,13 @@ users:
707
705
# Command to execute. Required.
708
706
command: "example-client-go-exec-plugin"
709
707
710
- # API version to use when encoding and decoding the ExecCredentials
711
- # resource. Required.
708
+ # API version to use when decoding the ExecCredentials resource. Required.
709
+ #
710
+ # The API version returned by the plugin MUST match the version listed here.
712
711
#
713
- # The API version returned by the plugin MUST match the version encoded.
714
- apiVersion: "client.authentication.k8s.io/v1alpha1"
712
+ # To integrate with tools that support multiple versions (such as client.authentication.k8s.io/v1alpha1),
713
+ # set an environment variable or pass an argument to the tool that indicates which version the exec plugin expects.
714
+ apiVersion: "client.authentication.k8s.io/v1beta1"
715
715
716
716
# Environment variables to set when executing the plugin. Optional.
717
717
env:
@@ -745,88 +745,64 @@ the binary `/home/jane/bin/example-client-go-exec-plugin` is executed.
745
745
exec:
746
746
# Path relative to the directory of the kubeconfig
747
747
command: "./bin/example-client-go-exec-plugin"
748
- apiVersion: "client.authentication.k8s.io/v1alpha1 "
748
+ apiVersion: "client.authentication.k8s.io/v1beta1 "
749
749
` ` `
750
750
751
751
# ## Input and output formats
752
752
753
- When executing the command, `k8s.io/client-go` sets the `KUBERNETES_EXEC_INFO` environment
754
- variable to a JSON serialized [`ExecCredential`](
755
- https://github.com/kubernetes/client-go/blob/master/pkg/apis/clientauthentication/v1alpha1/types.go)
756
- resource.
757
-
758
- ```
759
- KUBERNETES_EXEC_INFO='{
760
- "apiVersion": "client.authentication.k8s.io/v1alpha1",
761
- "kind": "ExecCredential",
762
- "spec": {
763
- "interactive": true
764
- }
765
- }'
766
- ```
753
+ The executed command prints an `ExecCredential` object to `stdout`. `k8s.io/client-go`
754
+ authenticates against the Kubernetes API using the returned credentials in the `status`.
767
755
768
- When plugins are executed from an interactive session, `stdin` and `stderr` are directly
769
- exposed to the plugin so the user can provide input for interactive logins.
756
+ When run from an interactive session, `stdin` is exposed directly to the plugin. Plugins should use a
757
+ [TTY check](https://godoc.org/golang.org/x/crypto/ssh/terminal#IsTerminal) to determine if it's
758
+ appropriate to prompt a user interactively.
770
759
771
- When responding to a 401 HTTP status code, which indicates invalid credentials, this object
772
- includes metadata about the response.
760
+ To use bearer token credentials, the plugin returns a token in the status of the `ExecCredential`.
773
761
774
762
` ` ` json
775
763
{
776
- "apiVersion": "client.authentication.k8s.io/v1alpha1 ",
764
+ "apiVersion": "client.authentication.k8s.io/v1beta1 ",
777
765
"kind": "ExecCredential",
778
- "spec": {
779
- "response": {
780
- "code": 401,
781
- "header": {
782
- "WWW-Authenticate": [
783
- "Bearer realm=ldap.example.com"
784
- ]
785
- },
786
- },
787
- "interactive": true
766
+ "status": {
767
+ "token": "my-bearer-token"
788
768
}
789
769
}
790
770
` ` `
791
771
792
- After the plugin outputs an ` ExecCredential ` structure to ` stdout ` , the ` k8s.io/cient-go ` library
793
- looks for a bearer token or client TLS key and certificate (or all three) in the
794
- ` status ` field and uses it to authenticate against the Kubernetes API. The library can
795
- use a bearer token on its own ( ` token ` ), a client TLS key and certificate
796
- ( ` clientKeyData ` and ` clientCertificateData ` ; both must be present), or a combination
797
- of both methods. ` clientCertificateData ` may contain additional intermediate
798
- certificates to send to the server.
772
+ Alternatively, a PEM-encoded client certificate and key can be returned to use TLS client auth.
773
+ If the plugin returns a different certificate and key on a subsequent call, `k8s.io/client-go`
774
+ will close existing connections with the server to force a new TLS handshake.
775
+
776
+ If specified, `clientKeyData` and `clientCertificateData` must both must be present.
777
+
778
+ ` clientCertificateData ` may contain additional intermediate certificates to send to the server.
799
779
800
780
` ` ` json
801
781
{
802
- "apiVersion" : " client.authentication.k8s.io/v1alpha1 " ,
782
+ "apiVersion": "client.authentication.k8s.io/v1beta1 ",
803
783
"kind": "ExecCredential",
804
784
"status": {
805
- "token" : " my-bearer-token" ,
806
785
"clientCertificateData": "-----BEGIN CERTIFICATE-----\n ...\n -----END CERTIFICATE-----",
807
786
"clientKeyData": "-----BEGIN RSA PRIVATE KEY-----\n ...\n -----END RSA PRIVATE KEY-----"
808
787
}
809
788
}
810
789
` ` `
811
790
812
791
Optionally, the response can include the expiry of the credential formatted as a
813
- RFC3339 timestamp. Presence or absense of an expiry has the following impact:
792
+ RFC3339 timestamp. Presence or absence of an expiry has the following impact :
814
793
815
794
- If an expiry is included, the bearer token and TLS credentials are cached until
816
795
the expiry time is reached, or if the server responds with a 401 HTTP status code,
817
796
or when the process exits.
818
797
- If an expiry is omitted, the bearer token and TLS credentials are cached until
819
798
the server responds with a 401 HTTP status code or until the process exits.
820
799
821
-
822
800
` ` ` json
823
801
{
824
- "apiVersion" : " client.authentication.k8s.io/v1alpha1 " ,
802
+ "apiVersion": "client.authentication.k8s.io/v1beta1 ",
825
803
"kind": "ExecCredential",
826
804
"status": {
827
805
"token": "my-bearer-token",
828
- "clientCertificateData" : " -----BEGIN CERTIFICATE-----\n ...\n -----END CERTIFICATE-----" ,
829
- "clientKeyData" : " -----BEGIN RSA PRIVATE KEY-----\n ...\n -----END RSA PRIVATE KEY-----" ,
830
806
"expirationTimestamp": "2018-03-05T17:30:20-08:00"
831
807
}
832
808
}
0 commit comments