Skip to content

Commit dd7b9f6

Browse files
committed
Add service account token and annotation to v1 CredentialProviderRequest
Signed-off-by: Anish Ramasekar <[email protected]>
1 parent ba2eecc commit dd7b9f6

File tree

9 files changed

+109
-20
lines changed

9 files changed

+109
-20
lines changed

staging/src/k8s.io/kubelet/pkg/apis/credentialprovider/types.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ type CredentialProviderRequest struct {
3232
// credential provider plugin request. Plugins may optionally parse the image
3333
// to extract any information required to fetch credentials.
3434
Image string
35+
36+
// serviceAccountToken is the service account token bound to the pod for which
37+
// the image is being pulled. This token is only sent to the plugin if the
38+
// tokenAttributes.serviceAccountTokenAudience field is configured in the kubelet's credential provider configuration.
39+
ServiceAccountToken string
40+
41+
// serviceAccountAnnotations is a map of annotations on the service account bound to the
42+
// pod for which the image is being pulled. The list of annotations in the service account
43+
// that need to be passed to the plugin is configured in the kubelet's credential provider
44+
// configuration.
45+
ServiceAccountAnnotations map[string]string
3546
}
3647

3748
type PluginCacheKeyType string

staging/src/k8s.io/kubelet/pkg/apis/credentialprovider/v1/types.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ type CredentialProviderRequest struct {
3232
// credential provider plugin request. Plugins may optionally parse the image
3333
// to extract any information required to fetch credentials.
3434
Image string `json:"image"`
35+
36+
// serviceAccountToken is the service account token bound to the pod for which
37+
// the image is being pulled. This token is only sent to the plugin if the
38+
// tokenAttributes.serviceAccountTokenAudience field is configured in the kubelet's credential
39+
// provider configuration.
40+
ServiceAccountToken string `json:"serviceAccountToken,omitempty" datapolicy:"token"`
41+
42+
// serviceAccountAnnotations is a map of annotations on the service account bound to the
43+
// pod for which the image is being pulled. The list of annotations in the service account
44+
// that need to be passed to the plugin is configured in the kubelet's credential provider
45+
// configuration.
46+
ServiceAccountAnnotations map[string]string `json:"serviceAccountAnnotations,omitempty"`
3547
}
3648

3749
type PluginCacheKeyType string

staging/src/k8s.io/kubelet/pkg/apis/credentialprovider/v1/zz_generated.conversion.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

staging/src/k8s.io/kubelet/pkg/apis/credentialprovider/v1/zz_generated.deepcopy.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
Copyright 2025 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
"k8s.io/apimachinery/pkg/conversion"
21+
"k8s.io/kubelet/pkg/apis/credentialprovider"
22+
)
23+
24+
func Convert_credentialprovider_CredentialProviderRequest_To_v1alpha1_CredentialProviderRequest(in *credentialprovider.CredentialProviderRequest, out *CredentialProviderRequest, s conversion.Scope) error {
25+
// This conversion intentionally omits the serviceAccountToken and serviceAccountAnnotations fields which are only supported in v1 CredentialProviderRequest.
26+
return autoConvert_credentialprovider_CredentialProviderRequest_To_v1alpha1_CredentialProviderRequest(in, out, s)
27+
}

staging/src/k8s.io/kubelet/pkg/apis/credentialprovider/v1alpha1/zz_generated.conversion.go

Lines changed: 7 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
Copyright 2025 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1beta1
18+
19+
import (
20+
"k8s.io/apimachinery/pkg/conversion"
21+
"k8s.io/kubelet/pkg/apis/credentialprovider"
22+
)
23+
24+
func Convert_credentialprovider_CredentialProviderRequest_To_v1beta1_CredentialProviderRequest(in *credentialprovider.CredentialProviderRequest, out *CredentialProviderRequest, s conversion.Scope) error {
25+
// This conversion intentionally omits the serviceAccountToken and serviceAccountAnnotations fields which are only supported in v1 CredentialProviderRequest.
26+
return autoConvert_credentialprovider_CredentialProviderRequest_To_v1beta1_CredentialProviderRequest(in, out, s)
27+
}

staging/src/k8s.io/kubelet/pkg/apis/credentialprovider/v1beta1/zz_generated.conversion.go

Lines changed: 7 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

staging/src/k8s.io/kubelet/pkg/apis/credentialprovider/zz_generated.deepcopy.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)