You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: keps/sig-multicluster/5339-clusterprofile-plugin-credentials/README.md
+76-60Lines changed: 76 additions & 60 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -291,79 +291,95 @@ In this structure, not all fields would apply, such as:
291
291
292
292
*`CertificateAuthority`, which points to a file (and a ClusterProfile doesn't have a filesystem)
293
293
294
-
##### About the `Extensions` field
295
-
296
-
The `Cluster` type defined in `client-go` ([link](https://github.com/kubernetes/client-go/blob/d32752779319f587c42ff9edbc6ed533575f2136/tools/clientcmd/api/types.go#L69)),
297
-
which is also a struct in use by the `CredentialsConfig` type from this KEP,
298
-
features a field, `extensions`, for holding additional information about the cluster, with each extension associated with a name.
299
-
[KEP-541](https://github.com/kubernetes/enhancements/blob/master/keps/sig-auth/541-external-credential-providers/README.md) further reserves a name,
300
-
`client.authentication.k8s.io/exec`, for per-cluster additional information for authentication exec plugins.
301
-
Per KEP-541's explanation, if the `client.authentication.k8s.io/exec` extension has been set in the `Cluster` struct, the data shall be
302
-
parsed and populated into the `Config` field of the `ExecConfig` struct (also defined in the `client-go` package, see [link](https://github.com/kubernetes/client-go/blob/d32752779319f587c42ff9edbc6ed533575f2136/tools/clientcmd/api/types.go#L209)).
303
-
If the `ExecConfig` struct has its `ProvideClusterInfo` flag set to true, the `client-go` package, upon invocation of an exec plugin, will build a
304
-
`Cluster` struct (from the `client.authentication.k8s.io` API group, see [link](https://pkg.go.dev/k8s.io/client-go/pkg/apis/clientauthentication#Cluster)),
305
-
which includes the parsed extension data (`Config` field in the `ExecConfig` struct), and save it to an environment variable, `KUBERNETES_EXEC_INFO`.
306
-
307
-
For the workflow defined in this KEP, however, as described earlier in this document, it is up to the community-provided library to build a
308
-
`rest.Config` and return it to the caller based on some user-supplied exec plugin information, which already features an `ExecConfig` struct
309
-
(with the path to the exec plugin, arguments, environment variables, etc.) before it reads a `ClusterProfile` object; if the `ClusterProfile` object
310
-
has extensions set, it might be in conflict with the `ExecConfig.Config` field that the community-provided library sees (typically, as KEP-541 dictates, data
311
-
in `ExecConfig.Config` should be sourced from `Cluster.Extensions`). To address this conflict, this KEP proposes that:
312
-
313
-
* If the `Cluster` struct in a `ClusterProfile` object already features some extension data under the name `client.authentication.k8s.io/exec`, the community
314
-
library will overwrite the `ExecConfig.Config` field with the data from the `ClusterProfile` object. It is up to the `ProvideClusterInfo` flag, which is
315
-
set exclusively on the community-provided library side, to decide whether this extension data will be provided as a part of the environment variable, `KUBERNETES_EXEC_INFO`.
316
-
317
-
In addition, as the extension data under the name `client.authentication.k8s.io/exec` is provided in the form of a `runtime.RawExtension` struct, and the
318
-
`ExecConfig.Config` field accepts only a `runtime.Object` interface, the community-provided library will attempt to bridge the two by saving the extension data as a
319
-
`runtime.Unknown` struct. It is up to the user to ensure that the extension data is of a correct format that can be serialized/deserialized when being saved as the
320
-
`KUBERNETES_EXEC_INFO` environment variable, and can be processed properly by the target exec plugin. The community-provided library will not perform
321
-
additional validation on the extension data.
322
-
323
-
##### Supplying additional CLI arguments and environment variables to the exec plugin
324
-
325
-
The current `Extensions` interface for passing additional cluster-specific authentication information might not be very easy for users to use. The presence
326
-
of the `KUBERNETES_EXEC_INFO` environment variable is purely optional; if the `ProvideClusterInfo` flag is unset (the default), this variable will be absent.
327
-
There are a few cases where the variable cannot be easily set: for example, the `KUBERNETES_EXEC_INFO` environment variable does feature the CA bundle for the
328
-
target cluster, which can potentially get quite large; depending on the target environment, it might not be OK to write such data as an environment variable.
329
-
Exec plugins are not mandated to support this environment variable either; even for those that do read this environment variable, it is not guaranteed that any
330
-
embedded extension data will be properly extracted.
331
-
332
-
On the other hand, it is quite common for multi-cluster users to have a need for specifying cluster-specific information when performing the authentication
333
-
workflow: the authentication solution in use by a cluster might be expecting a token of a specific audience, or a token from a specific identity. Most, if not
334
-
all, exec plugins would expect such information from the CLI arguments or some environment variables. In a single-cluster setup, it is trivial to set them up, as the
335
-
user has direct control over the `ExecConfig` struct; however, for the multi-cluster setup, since the `Cluster` struct does not feature any fields for additional
336
-
CLI arguments or environment variables, it would be fairly difficult to achieve this when using the Cluster Profile API and community-provided library.
294
+
And there are fields that require special attention:
295
+
296
+
*`Extensions`, which holds additional, usually cluster-specific information, that might help authenticate with the cluster.
297
+
298
+
For more information about these fields and how they are handled, see the section below:
299
+
300
+
##### The `Extensions` field
301
+
302
+
The `Extensions` field in the `Cluster` struct, can hold various form of data, each associated with an extension name.
further reserves a an extension name, `client.authentication.k8s.io/exec`, that can be used to pass cluster-specific
305
+
information to exec plugins. Data under this specific extension name shall be parsed and populated into a `ExecConfig`
306
+
struct (specifically its `Config` field), which libraries such as `client-go` will read when calling an exec plugin
307
+
for authentication purposes. The `ExecConfig` struct features a flag, `ProvideClusterInfo`, that controls whether the
308
+
extension data can be seen by an exec plugin; if the flag is set, right before the exec plugin is invoked, `client-go`
309
+
will save the extension data (along with other various pieces of information, such as the API server address of the
310
+
cluster and its CA bundle), to an environment variable, `KUBERNETES_EXEC_INFO`. An exec plugin may choose to read
311
+
the environment variable, and make use of the extension data as it sees fit.
312
+
313
+
For the authentication workflow described in this KEP, users may, too, choose to specify a `client.authentication.k8s.io/exec`
314
+
extension in the `Cluster` struct from a `ClusterProfile` API object. If the extension has been set, and the community-provided
315
+
library is provided with an `ExecConfig` with the `ProvideClusterInfo` flag set, the library will overwrite the
316
+
`ExecConfig.Config` field with the extension data, in consistency with the aforementioned processes.
317
+
318
+
Note also that the `Cluster` struct in the Cluster Profile API has the extension data stored in the free form
319
+
(`runtime.RawExtension`), but the `ExecConfig.Config` field accepts only `runtime.Object` data. As the community-provided
320
+
library has no way to know beforehand how to marshal raw data into Kubernetes objects (or in other words, the library
321
+
does not know which scheme to use for the conversion), the library might fall back to `runtime.Unknown` objects so that
322
+
it could bridge the gaps. No validation will be performed on the library end. It is up to the user to make sure that
323
+
the data can be unmarshalled properly when it is saved to the `KUBERNETES_EXEC_INFO` environment variable, and that
324
+
the data can be marshalled and processed properly by the exec plugin in use when it is being read from the same
325
+
environment variable.
326
+
327
+
###### Supplying additional CLI arguments and environment variables to the exec plugin
328
+
329
+
The current `Extensions` interface for passing additional cluster-specific authentication information might not be very
330
+
easy for users to use. The presence of the `KUBERNETES_EXEC_INFO` environment variable is purely optional; if the
331
+
`ProvideClusterInfo` flag is unset (the default), this variable will be absent. There are a few cases where the
332
+
variable cannot be easily set: for example, the `KUBERNETES_EXEC_INFO` environment variable does feature the CA bundle for the
333
+
target cluster, which can potentially get quite large; depending on the target environment, it might not be OK to
334
+
write such data as an environment variable. Exec plugins are not mandated to support this environment variable either;
335
+
even for those that do read this environment variable, it is not guaranteed that the included extension data can be
336
+
properly extracted.
337
+
338
+
On the other hand, it is quite common for multi-cluster users to have a need for specifying cluster-specific information
339
+
when performing the authentication workflow: the authentication solution in use by a cluster might be expecting a token of
340
+
a specific audience, or a token from a specific identity. Most, if not all, exec plugins would expect such information
341
+
from the CLI arguments or some environment variables. In a single-cluster setup, it is trivial to set them up, as the
342
+
user has direct control over the `ExecConfig` struct; however, for the multi-cluster setup, since the `Cluster` struct
343
+
does not feature any fields for additional CLI arguments or environment variables, it would be fairly difficult to achieve
344
+
this when using the Cluster Profile API and community-provided library.
337
345
338
346
To address this decifiency, we further proposes that:
339
347
340
-
* this KEP reserve a name in the extensions, `multicluster.x-k8s.io/clusterprofiles/auth/exec/additional-args`, which holds additional CLI arguments that need to be
341
-
supplied to the exec plugin when the Cluster Profile API and community-provided library are used for authentication.
348
+
* this KEP reserve a name in the extensions, `multicluster.x-k8s.io/clusterprofiles/auth/exec/additional-args`, which holds
349
+
additional CLI arguments that need to be supplied to the exec plugin when the Cluster Profile API and community-provided
350
+
library are used for authentication.
342
351
343
-
If an extension under this name is present, the community-provided library will extract the data, and append the additional arguments to the `ExecConfig` struct
344
-
(specifically the `ExecConfig.Args` field) that will be used to prepare the `rest.Config` output. The arguments will then be used to invoke the exec plugin.
352
+
If an extension under this name is present, the community-provided library will extract the data, and append the
353
+
additional arguments to the `ExecConfig` struct (specifically the `ExecConfig.Args` field) that will be used to
354
+
prepare the `rest.Config` output. The arguments will then be used to invoke the exec plugin.
345
355
346
-
The additional arguments should be represented as a string array in the YAML format.
356
+
The additional arguments shall be saved as a string array in the YAML format.
347
357
348
-
For simplicity reasons, the community-provided library will not perform any de-duplication on the CLI arguments after appending the additional arguments.
358
+
For simplicity reasons, the community-provided library will not perform any de-duplication on the CLI arguments
359
+
after the additional arguments are appended.
349
360
350
-
* this KEP reserve another name in the extensions, `multicluster.x-k8s.io/clusterprofiles/auth/exec/additional-envs`, which holds additional environment variables
351
-
that need to be supplied upon calling the exec plugin when the Cluster Profile API and community-provided library are used for authentication.
361
+
* this KEP reserve another name in the extensions, `multicluster.x-k8s.io/clusterprofiles/auth/exec/additional-envs`, which
362
+
holds additional environment variables that need to be supplied upon calling the exec plugin when the Cluster Profile API
363
+
and community-provided library are used for authentication.
352
364
353
-
If an extension under this name is present, the community-provided library will extract the data, and add the additional variables to the `ExecConfig` struct
354
-
(specifically the `ExecConfig.Env` field) that will be used to prepare the `rest.Config` output. The variables will then be set when invoking the exec plugin.
365
+
If an extension under this name is present, the community-provided library will extract the data, and add the additional
366
+
variables to the `ExecConfig` struct (specifically the `ExecConfig.Env` field) that will be used to prepare the
367
+
`rest.Config` output. The variables will then be set when invoking the exec plugin.
355
368
356
-
The additional environment variables should be represented as a mapping between strings in the YAML format.
369
+
The additional environment variables shall be represented as a string map in the YAML format.
357
370
358
-
The community-provided library will de-duplicate the list of environment variables when adding the additional variables; if two entries are present under the
359
-
same name, the one from the extension will prevail.
371
+
The community-provided library will de-duplicate the list of environment variables when adding the additional variables;
372
+
if two entries are present under the same name, the one from the extension will prevail.
360
373
361
374
###### Security concerns
362
375
363
-
With the addition of newly reserved extensions, understandably there might be situations where users might want to block additional CLI arguments or
364
-
environment variables from being set due to security reasons. To solve this, the KEP proposes that the community-provided library implementation must provide
365
-
two flags, `allowAdditionalCLIArgsExtension` and `allowAdditionalEnvVarExtension`, that control whether additional CLI arguments or environment
366
-
variables will be read from a `ClusterProfile` object respectively. A reserved extension will be not processed if the corresponding flag is unset. By default both flags should be unset.
376
+
With the addition of newly reserved extensions, understandably there might be situations where users might want to block
377
+
additional CLI arguments or environment variables from being set due to security reasons. To resolve this, the KEP proposes
378
+
that the community-provided library implementation must allow users to specify whether additional CLI arguments or environment
379
+
variables can be set by a `ClusterProfile` object. Available options include:
380
+
381
+
*`Ignore`: ignore any `multicluster.x-k8s.io/clusterprofiles/auth/exec/additional-args` or `multicluster.x-k8s.io/clusterprofiles/auth/exec/additional-envs` extension; no additional CLI arguments or environment variables will be set.
382
+
*`Allow`: accept `multicluster.x-k8s.io/clusterprofiles/auth/exec/additional-args` and `multicluster.x-k8s.io/clusterprofiles/auth/exec/additional-envs` extensions; additional CLI arguments and environment variables may be set.
0 commit comments