Skip to content

Commit 49094d3

Browse files
committed
review feedback
Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com>
1 parent c44af73 commit 49094d3

File tree

2 files changed

+23
-5
lines changed
  • keps/sig-auth/4412-projected-service-account-tokens-for-kubelet-image-credential-providers

2 files changed

+23
-5
lines changed

keps/sig-auth/4412-projected-service-account-tokens-for-kubelet-image-credential-providers/README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ the design is written to meet the following criteria:
316316
- No changes to any registry
317317
- Minimal changes to Kubelet
318318
- Minimal changes to Kubelet credential providers
319+
- Minimal changes to Kube API Server
319320

320321
## Design Details
321322

@@ -333,9 +334,10 @@ Adding a new field `TokenAttributes` to the `CredentialProvider` struct in the k
333334
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.
334335
1. Only a single audience can be configured.
335336
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.
336338
3. By setting this field, the credential provider is opting into using service account tokens for image pull.
337339
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.
339341
1. Service account annotations are significantly more stable (and map naturally to the service account being the partioning dimension).
340342
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.
341343
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
357359
+ //
358360
+ // The service account metadata and token attributes will be used as a dimension to cache
359361
+ // 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).
361363
+ TokenAttributes *ServiceAccountTokenAttributes
362364
+}
363365
+
@@ -397,6 +399,7 @@ providers:
397399
serviceAccountAnnotationKeys:
398400
- domain.io/identity-id
399401
- domain.io/identity-type
402+
- domain.io/annotation-that-does-not-exist
400403
```
401404
402405
##### Kubernetes API Server (KAS) Changes
@@ -406,6 +409,9 @@ Add a new flag `--allowed-kubelet-audiences` to KAS to allow configuring the lis
406409
The node audience restriction will be enforced by the [NodeRestriction admission controller](https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#noderestriction)
407410
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.
408411

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+
409415
#### Credential Provider Request API
410416

411417
Add `ServiceAccountToken` and `ServiceAccountAnnotations` fields to `CredentialProviderRequest`.
@@ -460,6 +466,10 @@ Example credential provider request:
460466
"serviceAccountAnnotations": {
461467
"domain.io/identity-id": "12345",
462468
"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.
463473
}
464474
}
465475
```
@@ -955,6 +965,7 @@ Focusing mostly on:
955965
-->
956966

957967
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.
958969

959970
###### Will enabling / using this feature result in introducing new API types?
960971

@@ -975,7 +986,10 @@ Describe them, providing:
975986
- Estimated increase:
976987
-->
977988

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

980994
###### Will enabling / using this feature result in increasing size or count of the existing API objects?
981995

@@ -999,7 +1013,9 @@ Think about adding additional work or introducing new steps in between
9991013
[existing SLIs/SLOs]: https://git.k8s.io/community/sig-scalability/slos/slos.md#kubernetes-slisslos
10001014
-->
10011015

1002-
No.
1016+
SLIs/SLOs for image pull times might be impacted with the credential plugin using KSA token for fetching credentials. The credentials are
1017+
granular in scope (per service account) like image pull secrets, but the plugin must dynamically fetch the credentials using the KSA token
1018+
and these credentials could have shorter TTLs resulting in more frequent fetching of credentials.
10031019

10041020
###### Will enabling / using this feature result in non-negligible increase of resource usage (CPU, RAM, disk, IO, ...) in any components?
10051021

keps/sig-auth/4412-projected-service-account-tokens-for-kubelet-image-credential-providers/kep.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
title: Projected Service Account Tokens for Kubelet Image Credential Providers
2-
kep-number: "4412"
2+
kep-number: 4412
33
authors:
44
- "@aramase"
55
- "@mainred"
@@ -12,6 +12,8 @@ reviewers:
1212
approvers:
1313
- "@enj"
1414
- "@liggitt"
15+
see-also:
16+
- "/keps/sig-node/2535-ensure-secret-pulled-images"
1517
creation-date: "2024-09-09"
1618
status: implementable
1719
stage: alpha

0 commit comments

Comments
 (0)