Skip to content

Commit 7c2d395

Browse files
committed
KEP-5339: define extensions-based per-cluster plugin configuration
Signed-off-by: kahirokunn <[email protected]>
1 parent 11b6321 commit 7c2d395

File tree

1 file changed

+47
-2
lines changed
  • keps/sig-multicluster/5339-clusterprofile-plugin-credentials

1 file changed

+47
-2
lines changed

keps/sig-multicluster/5339-clusterprofile-plugin-credentials/README.md

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ SIG Architecture for cross-cutting KEPs).
7272
- [External credentials Provider plugin mechanism](#external-credentials-provider-plugin-mechanism)
7373
- [Standardizing the Provider definition](#standardizing-the-provider-definition)
7474
- [Cluster Data](#cluster-data)
75+
- [Passing plugin configuration via extensions](#passing-plugin-configuration-via-extensions)
7576
- [ClusterProfile Example](#clusterprofile-example)
7677
- [Configuring plugins in the controller](#configuring-plugins-in-the-controller)
7778
- [Plugin Examples](#plugin-examples)
@@ -208,7 +209,8 @@ The library implementation flow is expected to be as follows:
208209
1. Build the endpoint details of the cluster by reading properties of the ClusterProfile
209210
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)
210211
(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
212214

213215
#### External credentials Provider plugin mechanism
214216

@@ -290,10 +292,30 @@ In this structure, not all fields would apply, such as:
290292

291293
* `CertificateAuthority`, which points to a file (and a ClusterProfile doesn't have a filesystem)
292294

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+
```
293314

294315
#### ClusterProfile Example
295316

296317
Example of a GKE ClusterProfile, which would map to a plugin providing credentials of type `google`:
318+
297319
```
298320
apiVersion: multicluster.x-k8s.io/v1alpha1
299321
kind: ClusterProfile
@@ -317,6 +339,29 @@ status:
317339
server: https://connectgateway.googleapis.com/v1/projects/123456789/locations/us-central1/gkeMemberships/my-cluster-1
318340
```
319341

342+
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+
320365

321366
### Configuring plugins in the controller
322367

@@ -350,7 +395,7 @@ version of the code and structures to convey the idea and not be an implementati
350395

351396
This plugin assumes the controller is aware of the list of clusters ahead of time and has created secrets for them in its namespace.
352397
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`.
354399

355400
```
356401
func GetToken(namespace, clusterName string) string {

0 commit comments

Comments
 (0)