Skip to content

Commit 8dc510f

Browse files
committed
Add docs for PSAT for Kubelet Image Credential Providers alpha
Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com>
1 parent e63cc33 commit 8dc510f

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
title: KubeletServiceAccountTokenForCredentialProviders
3+
content_type: feature_gate
4+
_build:
5+
list: never
6+
render: false
7+
8+
stages:
9+
- stage: alpha
10+
defaultValue: false
11+
fromVersion: "1.33"
12+
---
13+
Enable kubelet to send the service account token bound to the pod for which the image is being pulled to the credential provider plugin.

content/en/docs/tasks/administer-cluster/kubelet-credential-provider.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,24 @@ You may be interested in using this capability if any of the below are true:
2626

2727
This guide demonstrates how to configure the kubelet's image credential provider plugin mechanism.
2828

29+
## Service Account Token for Image Pulls
30+
{{< feature-state feature_gate_name="KubeletServiceAccountTokenForCredentialProviders" >}}
31+
32+
Starting from Kubernetes v1.33, the kubelet can be configured to send the projected service account token bound to the pod for which the image pull is being performed to the credential provider plugin. This allows the plugin to exchange the token for credentials to access the image registry.
33+
34+
To enable this feature, the `KubeletServiceAccountTokenForCredentialProviders` feature gate must be enabled on the kubelet and the `tokenAttributes` field must be set in the `CredentialProviderConfig` file for the plugin. The `tokenAttributes` field contains information about the service account token that will be passed to the plugin, including the intended audience for the token and whether the plugin requires the pod to have a service account.
35+
36+
You may be interested in using this feature if any of the below are true:
37+
38+
* Avoid needing a kubelet/node based identity to pull images from a registry.
39+
* Allow workloads to pull images based on their own runtime identity without long lived/persisted secrets.
40+
2941
## {{% heading "prerequisites" %}}
3042

3143
* You need a Kubernetes cluster with nodes that support kubelet credential
3244
provider plugins. This support is available in Kubernetes {{< skew currentVersion >}};
3345
Kubernetes v1.24 and v1.25 included this as a beta feature, enabled by default.
46+
* If you are configuring a credential provider plugin that requires the service account token, you need a Kubernetes cluster with nodes running Kubernetes v1.33 or later and the `KubeletServiceAccountTokenForCredentialProviders` feature gate enabled on the kubelet.
3447
* A working implementation of a credential provider exec plugin. You can build your own plugin or use one provided by cloud providers.
3548

3649
{{< version-check >}}
@@ -115,6 +128,49 @@ providers:
115128
env:
116129
- name: AWS_PROFILE
117130
value: example_profile
131+
132+
# tokenAttributes is the configuration for the service account token that will be passed to the plugin.
133+
# The credential provider opts in to using service account tokens for image pull by setting this field.
134+
# if this field is set without the `KubeletServiceAccountTokenForCredentialProviders` feature gate enabled,
135+
# kubelet will fail to start with invalid configuration error.
136+
# +optional
137+
tokenAttributes:
138+
# serviceAccountTokenAudience is the intended audience for the projected service account token.
139+
# +required
140+
serviceAccountTokenAudience: "<audience for the token>"
141+
# requireServiceAccount indicates whether the plugin requires the pod to have a service account.
142+
# If set to true, kubelet will only invoke the plugin if the pod has a service account.
143+
# If set to false, kubelet will invoke the plugin even if the pod does not have a service account
144+
# and will not include a token in the CredentialProviderRequest. This is useful for plugins
145+
# that are used to pull images for pods without service accounts (e.g., static pods).
146+
# +required
147+
requireServiceAccount: true
148+
# requiredServiceAccountAnnotationKeys is the list of annotation keys that the plugin is interested in
149+
# and that are required to be present in the service account.
150+
# The keys defined in this list will be extracted from the corresponding service account and passed
151+
# to the plugin as part of the CredentialProviderRequest. If any of the keys defined in this list
152+
# are not present in the service account, kubelet will not invoke the plugin and will return an error.
153+
# This field is optional and may be empty. Plugins may use this field to extract additional information
154+
# required to fetch credentials or allow workloads to opt in to using service account tokens for image pull.
155+
# If non-empty, requireServiceAccount must be set to true.
156+
# The keys defined in this list must be unique and not overlap with the keys defined in the
157+
# optionalServiceAccountAnnotationKeys list.
158+
# +optional
159+
requiredServiceAccountAnnotationKeys:
160+
- "example.com/required-annotation-key-1"
161+
- "example.com/required-annotation-key-2"
162+
# optionalServiceAccountAnnotationKeys is the list of annotation keys that the plugin is interested in
163+
# and that are optional to be present in the service account.
164+
# The keys defined in this list will be extracted from the corresponding service account and passed
165+
# to the plugin as part of the CredentialProviderRequest. The plugin is responsible for validating the
166+
# existence of annotations and their values. This field is optional and may be empty.
167+
# Plugins may use this field to extract additional information required to fetch credentials.
168+
# The keys defined in this list must be unique and not overlap with the keys defined in the
169+
# requiredServiceAccountAnnotationKeys list.
170+
# +optional
171+
optionalServiceAccountAnnotationKeys:
172+
- "example.com/optional-annotation-key-1"
173+
- "example.com/optional-annotation-key-2"
118174
```
119175
120176
The `providers` field is a list of enabled plugins used by the kubelet. Each entry has a few required fields:
@@ -130,6 +186,10 @@ The `providers` field is a list of enabled plugins used by the kubelet. Each ent
130186
Each credential provider can also be given optional args and environment variables as well.
131187
Consult the plugin implementors to determine what set of arguments and environment variables are required for a given plugin.
132188

189+
If you are using the `KubeletServiceAccountTokenForCredentialProviders` feature gate and configuring the plugin to use the service account token by setting the `tokenAttributes` field, the following fields are required:
190+
* `serviceAccountTokenAudience`: the intended audience for the projected service account token. This cannot be the empty string.
191+
* `requireServiceAccount`: whether the plugin requires the pod to have a service account. If set to true, kubelet will only invoke the plugin if the pod has a service account. If set to false, kubelet will invoke the plugin even if the pod does not have a service account and will not include a token in the CredentialProviderRequest. This is useful for plugins that are used to pull images for pods without service accounts (e.g., static pods).
192+
133193
#### Configure image matching
134194

135195
The `matchImages` field for each credential provider is used by the kubelet to determine whether a plugin should be invoked

0 commit comments

Comments
 (0)