Creating a ConfigMap

Function

This API is used to create a ConfigMap.

URI

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

Table 1 describes the parameters of this API.

Table 1 Description

Parameter

Mandatory

Description

namespace

Yes

Object name and auth scope, such as for teams and projects.

pretty

No

If 'true', then the output is pretty printed.

Request

Request parameters:

For the description about request parameters, see Table 2.

Table 2 Request parameters

Parameter

Mandatory

Type

Description

apiVersion

Yes

String

APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values.

kind

Yes

String

Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated.

metadata

Yes

metadata object

Standard list metadata.

data

Yes

Object

Data contains the configuration data. Each key must consist of alphanumeric characters, '-', '_' or '.'.

Example request:

{
    "apiVersion": "v1",
    "data": {
        "property_1": "test"
    },
    "kind": "ConfigMap",
    "metadata": {
        "name": "test-12130306"
    }
}

Response

Response parameters:

For the description about response parameters, see Table 2.

Example response:

{
    "kind": "ConfigMap",
    "apiVersion": "v1",
    "metadata": {
        "name": "test-12130306",
        "namespace": "ns-12130306-s",
        "selfLink": "/api/v1/namespaces/ns-12130306-s/configmaps/test-12130306",
        "uid": "efd6d9e0-dfb3-11e7-9c19-fa163e2d897b",
        "resourceVersion": "419081",
        "creationTimestamp": "2017-12-13T03:15:57Z",
        "enable": true
    },
    "data": {
        "property_1": "test"
    }
}

Status Code

Table 3 describes the status code of this API.

Table 3 Status code

Status Code

Description

201

The request has been fulfilled, resulting in the creation of a new resource.

For the description about error status codes, see Status Code.