--- api_metadata: apiVersion: "v1" import: "k8s.io/api/core/v1" kind: "ConfigMap" content_type: "api_reference" description: "ConfigMap 包含供 Pod 使用的配置数据。" title: "ConfigMap" weight: 1 --- `apiVersion: v1` `import "k8s.io/api/core/v1"` ## ConfigMap {#ConfigMap} ConfigMap 包含供 Pod 使用的配置数据。
- **apiVersion**: v1 - **kind**: ConfigMap - **metadata** (}}">ObjectMeta) 标准的对象元数据。 更多信息: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata - **binaryData** (map[string][]byte) binaryData 包含二进制数据。 每个键必须由字母、数字、“-”、“\_” 或 “.” 组成。 binaryData 可以包含不在 UTF-8 范围中的字节序列。 binaryData 中存储的键不得与 data 字段中的键重叠,这在验证过程中是强制要求。 使用此字段需要 apiserver 和 kubelet 的版本高于 1.10。 - **data** (map[string]string) data 包含配置数据。 每个键必须由字母、数字、“-”、“\_” 或 “.” 组成。 如果值包含非 UTF-8 字节序列,则必须使用 binaryData 字段。 data 中存储的键不得与 binaryData 字段中的键重叠,这在验证过程中是强制要求。 - **immutable** (boolean) 如果 immutable 设为 true, 则确保不会更新 ConfigMap 中存储的数据(只能修改对象元数据)。 如果未设为 true,则可以随时修改此字段。 默认为 nil。 ## ConfigMapList {#ConfigMapList} ConfigMapList 是包含 ConfigMap 对象列表的资源。
- **apiVersion**: v1 - **kind**: ConfigMapList - **metadata** (}}">ListMeta) 更多信息: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata - **items** ([]}}">ConfigMap),必需 items 是 ConfigMap 的列表。 ## 操作 {#Operations}
### `get` 读取指定的 ConfigMap #### HTTP 请求 GET /api/v1/namespaces/{namespace}/configmaps/{name} #### 参数 - **name** (**路径参数**): string,必需 ConfigMap 的名称 - **namespace** (**路径参数**): string,必需 }}">namespace - **pretty** (**查询参数**): string }}">pretty #### 响应 200 (}}">ConfigMap): OK 401: Unauthorized ### `list` 列出或观测类别为 ConfigMap 的对象 #### HTTP 请求 GET /api/v1/namespaces/{namespace}/configmaps #### 参数 - **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 (}}">ConfigMapList): OK 401: Unauthorized ### `list` 列出或观测类别为 ConfigMap 的对象 #### HTTP 请求 GET /api/v1/configmaps #### 参数 - **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 (}}">ConfigMapList): OK 401: Unauthorized ### `create` 创建 ConfigMap #### HTTP 请求 POST /api/v1/namespaces/{namespace}/configmaps #### 参数 - **namespace** (**路径参数**): string,必需 }}">namespace - **body**: }}">ConfigMap,必需 - **dryRun** (**查询参数**): string }}">dryRun - **fieldManager** (**查询参数**): string }}">fieldManager - **fieldValidation** (**查询参数**): string }}">fieldValidation - **pretty** (**查询参数**): string }}">pretty #### 响应 200 (}}">ConfigMap): OK 201 (}}">ConfigMap): Created 202 (}}">ConfigMap): Accepted 401: Unauthorized ### `update` 替换指定的 ConfigMap #### HTTP 请求 PUT /api/v1/namespaces/{namespace}/configmaps/{name} #### 参数 - **name** (**路径参数**): string,必需 ConfigMap 的名称 - **namespace** (**路径参数**): string,必需 }}">namespace - **body**: }}">ConfigMap,必需 - **dryRun** (**查询参数**): string }}">dryRun - **fieldManager** (**查询参数**): string }}">fieldManager - **fieldValidation** (**查询参数**): string }}">fieldValidation - **pretty** (**查询参数**): string }}">pretty #### 响应 200 (}}">ConfigMap): OK 201 (}}">ConfigMap): Created 401: Unauthorized ### `patch` 部分更新指定的 ConfigMap #### HTTP 请求 PATCH /api/v1/namespaces/{namespace}/configmaps/{name} #### 参数 - **name** (**路径参数**): string,必需 ConfigMap 的名称 - **namespace** (**路径参数**): string,必需 }}">namespace - **body**: }}">Patch,必需 - **dryRun** (**查询参数**): string }}">dryRun - **fieldManager** (**查询参数**): string }}">fieldManager - **fieldValidation** (**查询参数**): string }}">fieldValidation - **force** (**查询参数**): boolean }}">force - **pretty** (**查询参数**): string }}">pretty #### 响应 200 (}}">ConfigMap): OK 201 (}}">ConfigMap): Created 401: Unauthorized ### `delete` 删除 ConfigMap #### HTTP 请求 DELETE /api/v1/namespaces/{namespace}/configmaps/{name} #### 参数 - **name** (**路径参数**): string,必需 ConfigMap 的名称 - **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` 删除 ConfigMap 的集合 #### HTTP 请求 DELETE /api/v1/namespaces/{namespace}/configmaps #### 参数 - **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