ServiceAccount

ServiceAccount 绑定了以下内容:* 一个名称,供用户以及可能的周边系统理解,代表一个身份 * 一个可以认证和授权的主体 * 一组 Secret。

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 (布尔值)

    AutomountServiceAccountToken 指示以该 ServiceAccount 运行的 Pod 是否应该自动挂载 API Token。可以在 Pod 层面覆盖此设置。

  • imagePullSecrets ([]LocalObjectReference)

    Atomic:将在合并时替换

    ImagePullSecrets 是同一命名空间中 Secret 的引用列表,用于拉取引用此 ServiceAccount 的 Pod 中的任何镜像。ImagePullSecrets 与 Secret 不同,因为 Secret 可以挂载到 Pod 中,而 ImagePullSecrets 只能由 kubelet 访问。更多信息:https://kubernetes.ac.cn/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod

  • secrets ([]ObjectReference)

    Patch 策略:按键 name 合并

    Map:在合并时,按名称键确定的唯一值将被保留。

    Secrets 是同一命名空间中允许使用此 ServiceAccount 运行的 Pod 访问的 Secret 列表。仅当 ServiceAccount 具有注解 "kubernetes.io/enforce-mountable-secrets" 且其值为 "true" 时,Pod 的访问才会受限于此列表。"kubernetes.io/enforce-mountable-secrets" 注解自 v1.32 起已弃用。推荐使用单独的命名空间来隔离对挂载 Secret 的访问。此字段不应用于查找自动生成的用于 Pod 外部的 ServiceAccount Token Secret。相反,可以直接使用 TokenRequest API 请求 Token,或者手动创建 ServiceAccount Token Secret。更多信息:https://kubernetes.ac.cn/docs/concepts/configuration/secret

ServiceAccountList

ServiceAccountList 是 ServiceAccount 对象的列表


操作


get 读取指定的 ServiceAccount

HTTP 请求

GET /api/v1/namespaces/{namespace}/serviceaccounts/{name}

参数

  • name (在路径中): string,必需

    ServiceAccount 的名称

  • namespace (在路径中): string,必需

    命名空间

  • pretty (在查询参数中): string

    pretty

响应

200 (ServiceAccount): OK

401: 未授权

list 列出或监听类型为 ServiceAccount 的对象

HTTP 请求

GET /api/v1/namespaces/{namespace}/serviceaccounts

参数

响应

200 (ServiceAccountList): OK

401: 未授权

list 列出或监听类型为 ServiceAccount 的对象

HTTP 请求

GET /api/v1/serviceaccounts

参数

响应

200 (ServiceAccountList): OK

401: 未授权

create 创建一个 ServiceAccount

HTTP 请求

POST /api/v1/namespaces/{namespace}/serviceaccounts

参数

响应

200 (ServiceAccount): OK

201 (ServiceAccount): 已创建

202 (ServiceAccount): 已接受

401: 未授权

update 替换指定的 ServiceAccount

HTTP 请求

PUT /api/v1/namespaces/{namespace}/serviceaccounts/{name}

参数

  • name (在路径中): string,必需

    ServiceAccount 的名称

  • namespace (在路径中): string,必需

    命名空间

  • body: ServiceAccount,必需

  • dryRun (在查询参数中): string

    dryRun

  • fieldManager (在查询参数中): string

    fieldManager

  • fieldValidation (在查询参数中): string

    fieldValidation

  • pretty (在查询参数中): string

    pretty

响应

200 (ServiceAccount): OK

201 (ServiceAccount): 已创建

401: 未授权

patch 部分更新指定的 ServiceAccount

HTTP 请求

PATCH /api/v1/namespaces/{namespace}/serviceaccounts/{name}

参数

  • name (在路径中): string,必需

    ServiceAccount 的名称

  • namespace (在路径中): string,必需

    命名空间

  • body: Patch,必需

  • dryRun (在查询参数中): string

    dryRun

  • fieldManager (在查询参数中): string

    fieldManager

  • fieldValidation (在查询参数中): string

    fieldValidation

  • force (在查询参数中): 布尔值

    force

  • pretty (在查询参数中): string

    pretty

响应

200 (ServiceAccount): OK

201 (ServiceAccount): 已创建

401: 未授权

delete 删除一个 ServiceAccount

HTTP 请求

DELETE /api/v1/namespaces/{namespace}/serviceaccounts/{name}

参数

响应

200 (ServiceAccount): OK

202 (ServiceAccount): 已接受

401: 未授权

deletecollection 删除 ServiceAccount 集合

HTTP 请求

DELETE /api/v1/namespaces/{namespace}/serviceaccounts

参数

响应

200 (Status): OK

401: 未授权

本页面是自动生成的。

如果你计划报告此页面的问题,请在问题描述中提及此页面是自动生成的。修复可能需要在 Kubernetes 项目中的其他地方进行。

最后修改时间:2025 年 4 月 9 日下午 6:36 PST:更新 v1.32 的 API 参考文档 (a3b579d035)