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
-[Configuring plugins in the controller](#configuring-plugins-in-the-controller)
77
78
-[Plugin Examples](#plugin-examples)
@@ -208,7 +209,8 @@ The library implementation flow is expected to be as follows:
208
209
1. Build the endpoint details of the cluster by reading properties of the ClusterProfile
209
210
2. Call the CredentialsExternalProviders, following the same flow defined in [KEP 541](https://github.com/kubernetes/enhancements/blob/master/keps/sig-auth/541-external-credential-providers/README.md)
210
211
(giving the ability to reuse the code in [client-go's exec package](https://github.com/kubernetes/client-go/blob/master/plugin/pkg/client/auth/exec/exec.go#L159))
211
-
3. Build the rest.Config and return it to the caller
212
+
3. If the `Cluster` includes an `extensions` entry named `client.authentication.k8s.io/exec`, pass its `extension` object through to `ExecCredential.Spec.Cluster.Config` as plugin configuration.
213
+
4. Build the rest.Config and return it to the caller
@@ -290,10 +292,30 @@ In this structure, not all fields would apply, such as:
290
292
291
293
*`CertificateAuthority`, which points to a file (and a ClusterProfile doesn't have a filesystem)
292
294
295
+
#### Passing plugin configuration via extensions
296
+
297
+
Some credential providers require cluster-specific, non-secret parameters (for example, a `clusterName`) in order to obtain credentials. To standardize how this information is conveyed from a `ClusterProfile` to a plugin, the library follows the existing convention defined by the client authentication API:
298
+
299
+
- Optional: when a plugin needs per-cluster, non-secret config, set an extension entry with `name: client.authentication.k8s.io/exec` under `Cluster.extensions`.
300
+
- The library reads only the `extension` field of that entry and passes it through verbatim to `ExecCredential.Spec.Cluster.Config`.
301
+
- The content must be non-secret and cluster-specific. Controller- or environment-specific data must not be placed here.
302
+
- Plugins may read values (e.g. `clusterName`) from `ExecCredential.Spec.Cluster.Config`.
303
+
304
+
Reference: [client.authentication.k8s.io/v1 Cluster: `config` sourced from `extensions[client.authentication.k8s.io/exec]`](https://kubernetes.io/docs/reference/config-api/client-authentication.v1/#client-authentication-k8s-io-v1beta1-Cluster)
305
+
306
+
Example (embedded in `ClusterProfile.status.credentialProviders[].cluster`):
307
+
308
+
```
309
+
extensions:
310
+
- name: client.authentication.k8s.io/exec
311
+
extension:
312
+
clusterName: spoke-1
313
+
```
293
314
294
315
#### ClusterProfile Example
295
316
296
317
Example of a GKE ClusterProfile, which would map to a plugin providing credentials of type `google`:
Example of a SecretReader ClusterProfile using the `extensions` convention to pass `clusterName` to the plugin:
343
+
344
+
```
345
+
apiVersion: multicluster.x-k8s.io/v1alpha1
346
+
kind: ClusterProfile
347
+
metadata:
348
+
name: my-cluster-1
349
+
spec:
350
+
displayName: my-cluster-1
351
+
clusterManager:
352
+
name: inhouse-manager
353
+
status:
354
+
credentialProviders:
355
+
- name: secretreader
356
+
cluster:
357
+
server: https://<spoke-server>
358
+
certificate-authority-data: <BASE64_CA>
359
+
extensions:
360
+
- name: client.authentication.k8s.io/exec
361
+
extension:
362
+
clusterName: spoke-1
363
+
```
364
+
320
365
321
366
### Configuring plugins in the controller
322
367
@@ -350,7 +395,7 @@ version of the code and structures to convey the idea and not be an implementati
350
395
351
396
This plugin assumes the controller is aware of the list of clusters ahead of time and has created secrets for them in its namespace.
352
397
It simply reads the token from the secret mapped to the cluster specifically for this controller. Note that namespace comes from the
353
-
controller config while clusterName comes from the clusterProfile.
398
+
controller config while `clusterName` is read by the plugin from `ExecCredential.Spec.Cluster.Config`, which the library populates from the `Cluster.extensions` entry named `client.authentication.k8s.io/exec`.
0 commit comments