@@ -670,6 +670,64 @@ type CredentialProvider struct {
670
670
// to pass argument to the plugin.
671
671
// +optional
672
672
Env []ExecEnvVar
673
+
674
+ // tokenAttributes is the configuration for the service account token that will be passed to the plugin.
675
+ // The credential provider opts in to using service account tokens for image pull by setting this field.
676
+ // When this field is set, kubelet will generate a service account token bound to the pod for which the
677
+ // image is being pulled and pass to the plugin as part of CredentialProviderRequest along with other
678
+ // attributes required by the plugin.
679
+ //
680
+ // The service account metadata and token attributes will be used as a dimension to cache
681
+ // the credentials in kubelet. The cache key is generated by combining the service account metadata
682
+ // (namespace, name, UID, and annotations key+value for the keys defined in
683
+ // serviceAccountTokenAttribute.requiredServiceAccountAnnotationKeys and serviceAccountTokenAttribute.optionalServiceAccountAnnotationKeys).
684
+ // The pod metadata (namespace, name, UID) that are in the service account token are not used as a dimension
685
+ // to cache the credentials in kubelet. This means workloads that are using the same service account
686
+ // could end up using the same credentials for image pull. For plugins that don't want this behavior, or
687
+ // plugins that operate in pass-through mode; i.e., they return the service account token as-is, they
688
+ // can set the credentialProviderResponse.cacheDuration to 0. This will disable the caching of
689
+ // credentials in kubelet and the plugin will be invoked for every image pull. This does result in
690
+ // token generation overhead for every image pull, but it is the only way to ensure that the
691
+ // credentials are not shared across pods (even if they are using the same service account).
692
+ // +optional
693
+ TokenAttributes * ServiceAccountTokenAttributes
694
+ }
695
+
696
+ // ServiceAccountTokenAttributes is the configuration for the service account token that will be passed to the plugin.
697
+ type ServiceAccountTokenAttributes struct {
698
+ // serviceAccountTokenAudience is the intended audience for the projected service account token.
699
+ // +required
700
+ ServiceAccountTokenAudience string
701
+
702
+ // requireServiceAccount indicates whether the plugin requires the pod to have a service account.
703
+ // If set to true, kubelet will only invoke the plugin if the pod has a service account.
704
+ // If set to false, kubelet will invoke the plugin even if the pod does not have a service account
705
+ // and will not include a token in the CredentialProviderRequest in that scenario. This is useful for plugins that
706
+ // are used to pull images for pods without service accounts (e.g., static pods).
707
+ // +required
708
+ RequireServiceAccount * bool
709
+
710
+ // requiredServiceAccountAnnotationKeys is the list of annotation keys that the plugin is interested in
711
+ // and that are required to be present in the service account.
712
+ // The keys defined in this list will be extracted from the corresponding service account and passed
713
+ // to the plugin as part of the CredentialProviderRequest. If any of the keys defined in this list
714
+ // are not present in the service account, kubelet will not invoke the plugin and will return an error.
715
+ // This field is optional and may be empty. Plugins may use this field to extract
716
+ // additional information required to fetch credentials or allow workloads to opt in to
717
+ // using service account tokens for image pull.
718
+ // If non-empty, requireServiceAccount must be set to true.
719
+ // +optional
720
+ RequiredServiceAccountAnnotationKeys []string
721
+
722
+ // optionalServiceAccountAnnotationKeys is the list of annotation keys that the plugin is interested in
723
+ // and that are optional to be present in the service account.
724
+ // The keys defined in this list will be extracted from the corresponding service account and passed
725
+ // to the plugin as part of the CredentialProviderRequest. The plugin is responsible for validating
726
+ // the existence of annotations and their values.
727
+ // This field is optional and may be empty. Plugins may use this field to extract
728
+ // additional information required to fetch credentials.
729
+ // +optional
730
+ OptionalServiceAccountAnnotationKeys []string
673
731
}
674
732
675
733
// ExecEnvVar is used for setting environment variables when executing an exec-based
0 commit comments