你正在查看的文档所针对的是 Kubernetes 版本: v1.32
Kubernetes v1.32 版本的文档已不再维护。你现在看到的版本来自于一份静态的快照。如需查阅最新文档,请点击 最新版本。
ServiceAccount
apiVersion: v1
import "k8s.io/api/core/v1"
ServiceAccount
ServiceAccount 将以下内容绑定在一起:
- 用户可以理解的名称,也可能是外围系统理解的身份标识
- 可以验证和授权的主体
- 一组 Secret
- apiVersion: v1 
- kind: ServiceAccount 
- metadata (ObjectMeta) - 标准对象的元数据,更多信息: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 
- automountServiceAccountToken (boolean) - AutomountServiceAccountToken 指示作为此服务帐户运行的 Pod 是否应自动挂载 API 令牌, 可以在 Pod 级别覆盖。 
- imagePullSecrets ([]LocalObjectReference) - 原子:将在合并期间被替换 - imagePullSecrets 是对同一命名空间中 Secret 的引用列表,用于拉取引用此 ServiceAccount 的 Pod 中的任何镜像。 imagePullSecrets 与 Secret 不同,因为 Secret 可以挂载在 Pod 中,但 imagePullSecrets 只能由 kubelet 访问。更多信息: https://kubernetes.io/zh-cn/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod 
- secrets ([]ObjectReference) - 补丁策略:基于键 - name合并- 映射:键 - name的唯一值将在合并过程中保留- secrets 是允许使用此 ServiceAccount 运行的 Pod 使用的同一命名空间中的秘密列表。 仅当此服务帐户的 “kubernetes.io/enforce-mountable-secrets” 注释设置为 “true” 时,Pod 才限于此列表。 **已弃用:**自 v1.32 起, - kubernetes.io/enforce-mountable-secrets注解已被弃用。 建议使用单独的命名空间来隔离对挂载密钥的访问。 此字段不应用于查找自动生成的服务帐户令牌机密以在 Pod 之外使用。 相反,可以使用 TokenRequest API 直接请求令牌,或者可以手动创建服务帐户令牌 Secret。 更多信息:https://kubernetes.io/zh-cn/docs/concepts/configuration/secret
ServiceAccountList
ServiceAccountList 是 ServiceAccount 对象的列表
- apiVersion: v1 
- kind: ServiceAccountList 
- metadata (ListMeta) - 标准列表元数据, 更多信息: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds 
- items ([]ServiceAccount),必需 - ServiceAccount 列表,更多信息: https://kubernetes.io/zh-cn/docs/tasks/configure-pod-container/configure-service-account/ 
操作
get 读取指定的 ServiceAccount
HTTP 请求
GET /api/v1/namespaces/{namespace}/serviceaccounts/{name}
参数
- name (路径参数): string,必需 - ServiceAccount 的名称。 
- namespace (路径参数): string,必需 
- pretty (查询参数): string 
响应
200 (ServiceAccount): OK
401: Unauthorized
list 列出或监控 ServiceAccount 类型的对象
HTTP 请求
GET /api/v1/namespaces/{namespace}/serviceaccounts
参数
- namespace (路径参数): string,必需 
- allowWatchBookmarks (查询参数): boolean 
- continue (查询参数): string 
- fieldSelector (查询参数): string 
- labelSelector (查询参数): string 
- limit (查询参数): integer 
- pretty (查询参数): string 
- resourceVersion (查询参数): string 
- resourceVersionMatch (查询参数): string 
- sendInitialEvents (查询参数): boolean
- timeoutSeconds (查询参数): integer 
- watch (查询参数): boolean 
响应
200 (ServiceAccountList): OK
401: Unauthorized
list 列出或监控 ServiceAccount 类型的对象
HTTP 请求
GET /api/v1/serviceaccounts
参数
- allowWatchBookmarks (查询参数): boolean 
- continue (查询参数): string 
- fieldSelector (查询参数): string 
- labelSelector (查询参数): string 
- limit (查询参数): integer 
- pretty (查询参数): string 
- resourceVersion (查询参数): string 
- resourceVersionMatch (查询参数): string 
- sendInitialEvents (查询参数): boolean 
- timeoutSeconds (查询参数): integer 
- watch (查询参数): boolean 
响应
200 (ServiceAccountList): OK
401: Unauthorized
create 创建一个 ServiceAccount
HTTP 请求
POST /api/v1/namespaces/{namespace}/serviceaccounts
参数
- namespace (路径参数): string,必需 
- body: ServiceAccount,必需
- dryRun (查询参数): string 
- fieldManager (查询参数): string 
- fieldValidation (查询参数): string 
- pretty (查询参数): string 
响应
200 (ServiceAccount): OK
201 (ServiceAccount): Created
202 (ServiceAccount): Accepted
401: Unauthorized
update 替换指定的 ServiceAccount
HTTP 请求
PUT /api/v1/namespaces/{namespace}/serviceaccounts/{name}
参数
- name (路径参数): string,必需 - ServiceAccount 的名称。 
- namespace (路径参数): string,必需 
- body: ServiceAccount,必需
- dryRun (查询参数): string 
- fieldManager (查询参数): string 
- fieldValidation (查询参数): string 
- pretty (查询参数): string 
响应
200 (ServiceAccount): OK
201 (ServiceAccount): Created
401: Unauthorized
patch 部分更新指定的 ServiceAccount
HTTP 请求
PATCH /api/v1/namespaces/{namespace}/serviceaccounts/{name}
参数
- name (路径参数): string,必需 - ServiceAccount 的名称。 
- dryRun (查询参数): string 
- fieldManager (查询参数): string 
- fieldValidation (查询参数): string 
- force (查询参数): boolean 
- pretty (查询参数): string 
响应
200 (ServiceAccount): OK
201 (ServiceAccount): Created
401: Unauthorized
delete 删除一个 ServiceAccount
HTTP 请求
DELETE /api/v1/namespaces/{namespace}/serviceaccounts/{name}
参数
- name (路径参数): string,必需 - ServiceAccount 的名称。 
- namespace (路径参数): string,必需 
- body: DeleteOptions 
- dryRun (查询参数): string 
- gracePeriodSeconds (查询参数): integer 
- ignoreStoreReadErrorWithClusterBreakingPotential (查询参数): boolean 
- pretty (查询参数): string 
- propagationPolicy (in query): string 
响应
200 (ServiceAccount): OK
202 (ServiceAccount): Accepted
401: Unauthorized
deletecollection 删除 ServiceAccount 的集合
HTTP 请求
DELETE /api/v1/namespaces/{namespace}/serviceaccounts
参数
- namespace (路径参数): string,必需 
- body: DeleteOptions 
- continue (查询参数): string 
- dryRun (查询参数): string 
- fieldSelector (查询参数): string 
- gracePeriodSeconds (查询参数): integer 
- ignoreStoreReadErrorWithClusterBreakingPotential (查询参数): boolean 
- labelSelector (查询参数): string 
- limit (查询参数): integer 
- pretty (查询参数): string 
- propagationPolicy (查询参数): string 
- resourceVersion (查询参数): string 
- resourceVersionMatch (查询参数): string 
- sendInitialEvents (查询参数): boolean
- timeoutSeconds (查询参数): integer 
响应
200 (Status): OK
401: Unauthorized