您正在查看 Kubernetes 版本的文档: v1.24

Kubernetes v1.24 版本的文档已不再维护。您现在看到的版本来自于一份静态的快照。如需查阅最新文档,请点击 最新版本。

Secret

Secret 包含某些类别的秘密数据。

apiVersion: v1

import "k8s.io/api/core/v1"

Secret

Secret 包含某些类别的秘密数据。 data 字段值的总字节必须小于 MaxSecretSize 字节。


  • apiVersion: v1

  • kind: Secret

  • immutable (boolean)

    如果 immutable 设为 true,则确保不会更新 Secret 中存储的数据(只能修改对象元数据)。 如果未设为 true,则可以随时修改此字段。 默认为 nil。

  • stringData (map[string]string)

    stringData 允许指定字符串格式的非二进制秘密数据。 为了方便起见,它作为只写输入字段提供。 写入时将所有键和值合并到 data 字段,且覆盖任何现有的值。 从 API 读取时绝不会输出 stringData 字段。

  • type (string)

    用于满足程序化方式处理秘密数据。 更多信息: https://kubernetes.io/zh-cn/docs/concepts/configuration/secret/#secret-types

SecretList

SecretList 是 Secret 的列表。


  • apiVersion: v1

  • kind: SecretList

操作


get 读取指定的 Secret

HTTP 请求

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

参数

  • name (路径参数): string,必需

    Secret 的名称

  • namespace (路径参数): string,必需

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (Secret): OK

401: Unauthorized

list 列出或观测类别为 Secret 的对象

HTTP 请求

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

参数

响应

200 (SecretList): OK

401: Unauthorized

list 列出或观测类别为 Secret 的对象

HTTP 请求

GET /api/v1/secrets

参数

响应

200 (SecretList): OK

401: Unauthorized

create 创建 Secret

HTTP 请求

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

参数

响应

200 (Secret): OK

201 (Secret): Created

202 (Secret): Accepted

401: Unauthorized

update 替换指定的 Secret

HTTP 请求

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

参数

  • name (路径参数): string,必需

    Secret 的名称

  • namespace (路径参数): string,必需

    namespace

  • body: Secret,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • pretty (查询参数): string

    pretty

响应

200 (Secret): OK

201 (Secret): Created

401: Unauthorized

patch 部分更新指定的 Secret

HTTP 请求

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

参数

  • name (路径参数): string,必需

    Secret 的名称

  • namespace (路径参数): string,必需

    namespace

  • body: Patch,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (Secret): OK

201 (Secret): Created

401: Unauthorized

delete 删除 Secret

HTTP 请求

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

参数

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 Secret 的集合

HTTP 请求

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

参数

响应

200 (Status): OK

401: Unauthorized