Skip to content

Commit 5fc767f

Browse files
liggittk8s-ci-robot
authored andcommitted
client exec auth: updates for 1.11 (#9154)
1 parent 3301a33 commit 5fc767f

File tree

1 file changed

+27
-51
lines changed

1 file changed

+27
-51
lines changed

content/en/docs/reference/access-authn-authz/authentication.md

+27-51
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ rules:
664664

665665
## client-go credential plugins
666666

667-
{{< feature-state for_k8s_version="v1.10" state="alpha" >}}
667+
{% assign for_k8s_version="v1.11" %}{% include feature-state-beta.md %}
668668

669669
`k8s.io/client-go` and tools using it such as `kubectl` and `kubelet` are able to execute an
670670
external command to receive user credentials.
@@ -675,8 +675,6 @@ protocol specific logic, then returns opaque credentials to use. Almost all cred
675675
use cases require a server side component with support for the [webhook token authenticator](#webhook-token-authentication)
676676
to interpret the credential format produced by the client plugin.
677677

678-
As of 1.10 only bearer tokens are supported. Support for client certs may be added in a future release.
679-
680678
### Example use case
681679

682680
In a hypothetical use case, an organization would run an external service that exchanges LDAP credentials
@@ -707,11 +705,13 @@ users:
707705
# Command to execute. Required.
708706
command: "example-client-go-exec-plugin"
709707
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.
712711
#
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"
715715
716716
# Environment variables to set when executing the plugin. Optional.
717717
env:
@@ -745,88 +745,64 @@ the binary `/home/jane/bin/example-client-go-exec-plugin` is executed.
745745
exec:
746746
# Path relative to the directory of the kubeconfig
747747
command: "./bin/example-client-go-exec-plugin"
748-
apiVersion: "client.authentication.k8s.io/v1alpha1"
748+
apiVersion: "client.authentication.k8s.io/v1beta1"
749749
```
750750

751751
### Input and output formats
752752

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`.
767755

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.
770759

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`.
773761

774762
```json
775763
{
776-
"apiVersion": "client.authentication.k8s.io/v1alpha1",
764+
"apiVersion": "client.authentication.k8s.io/v1beta1",
777765
"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"
788768
}
789769
}
790770
```
791771

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.
799779

800780
```json
801781
{
802-
"apiVersion": "client.authentication.k8s.io/v1alpha1",
782+
"apiVersion": "client.authentication.k8s.io/v1beta1",
803783
"kind": "ExecCredential",
804784
"status": {
805-
"token": "my-bearer-token",
806785
"clientCertificateData": "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----",
807786
"clientKeyData": "-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----"
808787
}
809788
}
810789
```
811790

812791
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:
814793

815794
- If an expiry is included, the bearer token and TLS credentials are cached until
816795
the expiry time is reached, or if the server responds with a 401 HTTP status code,
817796
or when the process exits.
818797
- If an expiry is omitted, the bearer token and TLS credentials are cached until
819798
the server responds with a 401 HTTP status code or until the process exits.
820799

821-
822800
```json
823801
{
824-
"apiVersion": "client.authentication.k8s.io/v1alpha1",
802+
"apiVersion": "client.authentication.k8s.io/v1beta1",
825803
"kind": "ExecCredential",
826804
"status": {
827805
"token": "my-bearer-token",
828-
"clientCertificateData": "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----",
829-
"clientKeyData": "-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----",
830806
"expirationTimestamp": "2018-03-05T17:30:20-08:00"
831807
}
832808
}

0 commit comments

Comments
 (0)