Skip to content

Commit 245e8a2

Browse files
committed
Add blog post for PSAT for Kubelet Image Credential Providers
Signed-off-by: Anish Ramasekar <[email protected]>
1 parent 1a27571 commit 245e8a2

File tree

1 file changed

+162
-0
lines changed

1 file changed

+162
-0
lines changed
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
---
2+
layout: blog
3+
title: "From Secrets to Service Accounts: Kubernetes Image Pulls Evolved"
4+
date: 2025-04-15
5+
slug: wi-for-image-pulls
6+
author: >
7+
[Anish Ramasekar](https://github.com/aramase) (Microsoft)
8+
---
9+
10+
Kubernetes has steadily evolved to reduce reliance on long-lived credentials
11+
stored in the API.
12+
A prime example of this shift is the transition of Kubernetes Service Account (KSA) tokens
13+
from long-lived, static tokens to ephemeral, automatically rotated tokens
14+
with OpenID Connect (OIDC)-compliant semantics.
15+
This advancement enables workloads to securely authenticate with external services
16+
without needing persistent secrets.
17+
18+
However, one major gap remains: **image pull authentication**.
19+
Today, Kubernetes clusters rely on image pull secrets stored in the API,
20+
which are long-lived and difficult to rotate,
21+
or on node-level kubelet credential providers,
22+
which allow any pod running on a node to access the same credentials.
23+
This presents security and operational challenges.
24+
25+
To address this, Kubernetes is introducing **Service Account Token Integration
26+
for Kubelet Credential Providers**, now available in **alpha**.
27+
This enhancement allows credential providers to use pod-specific service account tokens
28+
to obtain registry credentials, which kubelet can then use for image pulls —
29+
eliminating the need for long-lived image pull secrets.
30+
31+
## The problem with image pull secrets
32+
33+
Currently, Kubernetes administrators have two primary options
34+
for handling private container image pulls:
35+
36+
1. **Image pull secrets stored in the Kubernetes API**
37+
- These secrets are often long-lived because they are hard to rotate.
38+
- They must be explicitly attached to a service account or pod.
39+
- Compromise of a pull secret can lead to unauthorized image access.
40+
41+
2. **Kubelet credential providers**
42+
- These providers fetch credentials dynamically at the node level.
43+
- Any pod running on the node can access the same credentials.
44+
- There’s no per-workload isolation, increasing security risks.
45+
46+
Neither approach aligns with the principles of **least privilege**
47+
or **ephemeral authentication**, leaving Kubernetes with a security gap.
48+
49+
## The Solution: Service Account Token Integration for Kubelet Credential Providers
50+
51+
This new enhancement enables kubelet credential providers
52+
to use **workload identity** when fetching image registry credentials.
53+
Instead of relying on long-lived secrets, credential providers can use
54+
service account tokens to request short-lived credentials
55+
tied to a specific pod’s identity.
56+
57+
This approach provides:
58+
59+
- **Workload-specific authentication**:
60+
Image pull credentials are scoped to a particular workload.
61+
- **Ephemeral credentials**:
62+
Tokens are automatically rotated, eliminating the risks of long-lived secrets.
63+
- **Seamless integration**:
64+
Works with existing Kubernetes authentication mechanisms,
65+
aligning with cloud-native security best practices.
66+
67+
## How it works
68+
69+
### 1. Service Account tokens for credential providers
70+
71+
Kubelet generates **short-lived, automatically rotated** tokens for service accounts
72+
if the credential provider it communicates with has opted into receiving
73+
a service account token for image pulls.
74+
These tokens conform to OIDC ID token semantics
75+
and are provided to the credential provider
76+
as part of the `CredentialProviderRequest`.
77+
The credential provider can then use this token
78+
to authenticate with an external service.
79+
80+
### 2. Image registry authentication flow
81+
82+
- When a pod starts, the kubelet requests credentials from a **credential provider**.
83+
- If the credential provider has opted in,
84+
the kubelet generates a **service account token** for the pod.
85+
- The **service account token is included in the `CredentialProviderRequest`**,
86+
allowing the credential provider to authenticate
87+
and exchange it for **temporary image pull credentials**
88+
from a registry (e.g. AWS ECR, GCP Artifact Registry, Azure ACR).
89+
- The kubelet then uses these credentials
90+
to pull images on behalf of the pod.
91+
92+
## Benefits of this approach
93+
94+
- **Security**:
95+
Eliminates long-lived image pull secrets, reducing attack surfaces.
96+
- **Granular Access Control**:
97+
Credentials are tied to individual workloads rather than entire nodes or clusters.
98+
- **Operational Simplicity**:
99+
No need for administrators to manage and rotate image pull secrets manually.
100+
- **Improved Compliance**:
101+
Helps organizations meet security policies
102+
that prohibit persistent credentials in the cluster.
103+
104+
## What's next?
105+
106+
For Kubernetes **v1.34**, we expect to ship this feature in **beta**
107+
while continuing to gather feedback from users.
108+
109+
In the coming releases, we will focus on:
110+
111+
- Implementing **caching mechanisms**
112+
to improve performance for token generation.
113+
- Giving more **flexibility to credential providers**
114+
to decide how the registry credentials returned to the kubelet are cached.
115+
- Making the feature work with
116+
[Ensure Secret Pulled Images](https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/2535-ensure-secret-pulled-images)
117+
to ensure pods that use an image
118+
are authorized to access that image
119+
when service account tokens are used for authentication.
120+
121+
You can learn more about this feature
122+
on the [service account token for image pulls](/docs/tasks/administer-cluster/kubelet-credential-provider/#service-account-token-for-image-pulls)
123+
page in the Kubernetes documentation.
124+
125+
You can also follow along on the
126+
[KEP-4412](https://kep.k8s.io/4412)
127+
to track progress across the coming Kubernetes releases.
128+
129+
## Try it out
130+
131+
To try out this feature:
132+
133+
1. **Ensure you are running Kubernetes v1.33 or later**.
134+
2. **Enable the `ServiceAccountTokenForKubeletCredentialProviders` feature gate**
135+
on the kubelet.
136+
3. **Ensure credential provider support**:
137+
Modify or update your credential provider
138+
to use service account tokens for authentication.
139+
4. **Update the credential provider configuration**
140+
to opt into receiving service account tokens
141+
for the credential provider by configuring the `tokenAttributes` field.
142+
5. **Deploy a pod**
143+
that uses the credential provider to pull images from a private registry.
144+
145+
We would love to hear your feedback on this feature.
146+
Please reach out to us on the
147+
[#sig-auth-authenticators-dev](https://kubernetes.slack.com/archives/C04UMAUC4UA)
148+
channel on Kubernetes Slack
149+
(for an invitation, visit [https://slack.k8s.io/](https://slack.k8s.io/)).
150+
151+
## How to get involved
152+
153+
If you are interested in getting involved
154+
in the development of this feature,
155+
sharing feedback, or participating in any other ongoing **SIG Auth** projects,
156+
please reach out on the
157+
[#sig-auth](https://kubernetes.slack.com/archives/C0EN96KUY)
158+
channel on Kubernetes Slack.
159+
160+
You are also welcome to join the bi-weekly
161+
[SIG Auth meetings](https://github.com/kubernetes/community/blob/master/sig-auth/README.md#meetings),
162+
held every other Wednesday.

0 commit comments

Comments
 (0)