--- api_metadata: apiVersion: "v1" import: "k8s.io/api/core/v1" kind: "Secret" content_type: "api_reference" description: "Secret 包含某些类别的秘密数据。" title: "Secret" weight: 2 --- `apiVersion: v1` `import "k8s.io/api/core/v1"` ## Secret {#Secret} Secret 包含某些类别的秘密数据。 data 字段值的总字节必须小于 MaxSecretSize 字节。
- **apiVersion**: v1 - **kind**: Secret - **metadata** (}}">ObjectMeta) 标准的对象元数据。 更多信息: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata - **data** (map[string][]byte) data 包含秘密数据。 每个键必须由字母、数字、“-”、“_” 或 “.” 组成。 秘密数据的序列化格式是 base64 编码的字符串,表示此处的任意(可能是非字符串)数据值。 请参阅 https://tools.ietf.org/html/rfc4648#section-4 - **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} SecretList 是 Secret 的列表。
- **apiVersion**: v1 - **kind**: SecretList - **metadata** (}}">ListMeta) 标准的列表元数据。 更多信息: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - **items** ([]}}">Secret),必需 items 是 Secret 对象的列表。 更多信息: https://kubernetes.io/zh-cn/docs/concepts/configuration/secret ## 操作 {#Operations}
### `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 #### 参数 - **namespace** (**路径参数**): string,必需 }}">namespace - **allowWatchBookmarks** (**查询参数**): boolean }}">allowWatchBookmarks - **continue** (**查询参数**): string }}">continue - **fieldSelector** (**查询参数**): string }}">fieldSelector - **labelSelector** (**查询参数**): string }}">labelSelector - **limit** (**查询参数**): integer }}">limit - **pretty** (**查询参数**): string }}">pretty - **resourceVersion** (**查询参数**): string }}">resourceVersion - **resourceVersionMatch** (**查询参数**): string }}">resourceVersionMatch - **sendInitialEvents** (**查询参数**): boolean }}">sendInitialEvents - **timeoutSeconds** (**查询参数**): integer }}">timeoutSeconds - **watch** (**查询参数**): boolean }}">watch #### 响应 200 (}}">SecretList): OK 401: Unauthorized ### `list` 列出或观测类别为 Secret 的对象 #### HTTP 请求 GET /api/v1/secrets #### 参数 - **allowWatchBookmarks** (**查询参数**): boolean }}">allowWatchBookmarks - **continue** (**查询参数**): string }}">continue - **fieldSelector** (**查询参数**): string }}">fieldSelector - **labelSelector** (**查询参数**): string }}">labelSelector - **limit** (**查询参数**): integer }}">limit - **pretty** (**查询参数**): string }}">pretty - **resourceVersion** (**查询参数**): string }}">resourceVersion - **resourceVersionMatch** (**查询参数**): string }}">resourceVersionMatch - **sendInitialEvents** (**查询参数**): boolean }}">sendInitialEvents - **timeoutSeconds** (**查询参数**): integer }}">timeoutSeconds - **watch** (**查询参数**): boolean }}">watch #### 响应 200 (}}">SecretList): OK 401: Unauthorized ### `create` 创建 Secret #### HTTP 请求 POST /api/v1/namespaces/{namespace}/secrets #### 参数 - **namespace** (**路径参数**): string,必需 }}">namespace - **body**: }}">Secret,必需 - **dryRun** (**查询参数**): string }}">dryRun - **fieldManager** (**查询参数**): string }}">fieldManager - **fieldValidation** (**查询参数**): string }}">fieldValidation - **pretty** (**查询参数**): string }}">pretty #### 响应 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} #### 参数 - **name** (**路径参数**): string,必需 Secret 的名称 - **namespace** (**路径参数**): string,必需 }}">namespace - **body**: }}">DeleteOptions - **dryRun** (**查询参数**): string }}">dryRun - **gracePeriodSeconds** (**查询参数**): integer }}">gracePeriodSeconds - **pretty** (**查询参数**): string }}">pretty - **propagationPolicy** (**查询参数**): string }}">propagationPolicy #### 响应 200 (}}">Status): OK 202 (}}">Status): Accepted 401: Unauthorized ### `deletecollection` 删除 Secret 的集合 #### HTTP 请求 DELETE /api/v1/namespaces/{namespace}/secrets #### 参数 - **namespace** (**路径参数**): string,必需 }}">namespace - **body**: }}">DeleteOptions - **continue** (**查询参数**): string }}">continue - **dryRun** (**查询参数**): string }}">dryRun - **fieldSelector** (**查询参数**): string }}">fieldSelector - **gracePeriodSeconds** (**查询参数**): integer }}">gracePeriodSeconds - **labelSelector** (**查询参数**): string }}">labelSelector - **limit** (**查询参数**): integer }}">limit - **pretty** (**查询参数**): string }}">pretty - **propagationPolicy** (**查询参数**): string }}">propagationPolicy - **resourceVersion** (**查询参数**): string }}">resourceVersion - **resourceVersionMatch** (**查询参数**): string }}">resourceVersionMatch - **sendInitialEvents** (**查询参数**): boolean }}">sendInitialEvents - **timeoutSeconds** (**查询参数**): integer }}">timeoutSeconds #### 响应 200 (}}">Status): OK 401: Unauthorized