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-auth/4412-projected-service-account-tokens-for-kubelet-image-credential-providers/README.md
+20-4Lines changed: 20 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -316,6 +316,7 @@ the design is written to meet the following criteria:
316
316
- No changes to any registry
317
317
- Minimal changes to Kubelet
318
318
- Minimal changes to Kubelet credential providers
319
+
- Minimal changes to Kube API Server
319
320
320
321
## Design Details
321
322
@@ -333,9 +334,10 @@ Adding a new field `TokenAttributes` to the `CredentialProvider` struct in the k
333
334
1.`ServiceAccountTokenAudience` is the intended audience for the credentials. If set, the kubelet will generate a service account token for the audience and pass it to the plugin.
334
335
1. Only a single audience can be configured.
335
336
2. The credential provider can be set up multiple times for each audience.
337
+
1. The name in the credential provider config must match the name of the provider executable as seen by the kubelet. To configure multiple instances of the same provider with different audiences, the name of the provider executable must be different and this can be done by creating a symlink to the same executable with a different name.
336
338
3. By setting this field, the credential provider is opting into using service account tokens for image pull.
337
339
2.`ServiceAccountAnnotationKeys` is the list of annotation keys that the plugin is interested in. The keys defined in this list will be extracted from the corresponding service account
338
-
and passed to the plugin as part of `CredentialProviderRequest`. Plugins can use to extract additional information required to fetch credentials. The plugin is responsible for validating the existence of annotations and their values.
340
+
and passed to the plugin as part of `CredentialProviderRequest`. Plugins can use to extract additional information required to fetch credentials. The plugin is responsible for validating the existence of annotations and their values. There are existing integrations like Azure and GCP that use the extra metadata to link the KSA name to a cloud identity, and this field will allow them to continue to do so. None of the existing integrations use this metadata as any form of security decision, it is simply to aid in doing token exchanges with the KSA token.
339
341
1. Service account annotations are significantly more stable (and map naturally to the service account being the partioning dimension).
340
342
2. This field makes the provider opt into getting the annotations it wants, avoids sending arbitrary annotation contents down to the plugin (including stuff like client-side apply annotations) and shrinks the set of annotations that could invalidate the cache.
341
343
3. This field can't be set without setting the `ServiceAccountTokenAudience` field.
@@ -357,7 +359,7 @@ The configuration will not support a plugin to function in 2 modes simultaneousl
357
359
+ //
358
360
+ // The service account metadata and token attributes will be used as a dimension to cache
359
361
+ // the credentials in kubelet. The cache key is generated by combining the service account metadata
360
-
+ // (namespace, name, UID, and annotations map with keys defined in ServiceAccountTokenAttribute.serviceAccountAnnotationKeys).
362
+
+ // (namespace, name, UID, and annotations key+value for the keys defined in ServiceAccountTokenAttribute.serviceAccountAnnotationKeys).
361
363
+ TokenAttributes *ServiceAccountTokenAttributes
362
364
+}
363
365
+
@@ -397,6 +399,7 @@ providers:
397
399
serviceAccountAnnotationKeys:
398
400
- domain.io/identity-id
399
401
- domain.io/identity-type
402
+
- domain.io/annotation-that-does-not-exist
400
403
```
401
404
402
405
##### Kubernetes API Server (KAS) Changes
@@ -406,6 +409,9 @@ Add a new flag `--allowed-kubelet-audiences` to KAS to allow configuring the lis
406
409
The node audience restriction will be enforced by the [NodeRestriction admission controller](https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#noderestriction)
407
410
and kubelet will only be allowed to generate a service account token for the audience configured in the credential provider configuration if it is present in the list of audiences configured in KAS.
408
411
412
+
Today we only verify the SA in KAS and allow the kubelet to generate a token for any audience. We want to start verifying the audience as well, so we need to be explicit here about what audiences are allowed.
413
+
The other sources of audiences for the SA token can be observed via the Kubernetes API but this one can't, so we're adding the flag.
414
+
409
415
#### Credential Provider Request API
410
416
411
417
Add `ServiceAccountToken` and `ServiceAccountAnnotations` fields to `CredentialProviderRequest`.
@@ -460,6 +466,10 @@ Example credential provider request:
460
466
"serviceAccountAnnotations": {
461
467
"domain.io/identity-id": "12345",
462
468
"domain.io/identity-type": "user"
469
+
// In the tokenAttributes.serviceAccountAnnotationKeys field in the credential provider configuration above we have configured
470
+
// domain.io/annotation-that-does-not-exist which is not present in the service account annotations. Because of this, this annotation
471
+
// will not be passed to the plugin. The plugin is responsible for validating the existence of annotations and their values that's required
472
+
// to fetch credentials.
463
473
}
464
474
}
465
475
```
@@ -955,6 +965,7 @@ Focusing mostly on:
955
965
-->
956
966
957
967
Yes. Kubelet will request a KSA token from KAS for pod + KSA for every provider (audience) that is configured to use service account tokens for image pull.
968
+
The load is small because the token generation happens only once during pod startup.
958
969
959
970
###### Will enabling / using this feature result in introducing new API types?
960
971
@@ -975,7 +986,10 @@ Describe them, providing:
975
986
- Estimated increase:
976
987
-->
977
988
978
-
No.
989
+
This depends on the credential provider plugin implementation on how it fetches the credentials using the service account token.
990
+
The plugin will now be called for every unique KSA + (image/registry) combination that is being pulled if not already cached unlike
991
+
today where the cache is based on the image/registry URL. This could result in more calls to the cloud provider from the plugin to
992
+
exchange the KSA token for the credentials.
979
993
980
994
###### Will enabling / using this feature result in increasing size or count of the existing API objects?
981
995
@@ -999,7 +1013,9 @@ Think about adding additional work or introducing new steps in between
0 commit comments