• Cloud Container Engine

cce
  1. Help Center
  2. Cloud Container Engine
  3. User Guide 2.0
  4. Configuration Center
  5. Creating a Configuration Item

Creating a Configuration Item

A configuration item is a type of resource that stores configuration information required by an application. Its content is user-defined. After creating configuration items, you can use them as files or environment variables in a containerized application.

Configuration items allow you to decouple configuration files from container images to enhance the portability of containerized applications.

Benefits of configuration items:

  • Manage configurations of different environments and services.
  • Deploy applications in different environments. Multiple versions are supported for configuration files so that you can update and roll back applications easily.
  • Quickly import your configurations files to containers.

Prerequisites

Cluster and node resources have been created. For more information, see Creating a VM Cluster.

Procedure

  1. Log in to the CCE console. In the navigation pane, choose Configuration Center > ConfigMaps, and click Create ConfigMap.
  2. Configuration items can be created manually or by uploading a configuration file.

    • To create a configuration item manually, set the parameters for creating a configuration item listed in Table 1. The parameters marked with an asterisk (*) are mandatory.
      Table 1 Parameters for creating a configuration item

      Parameter

      Description

      * Name

      Name of a configuration item, which must be unique in a namespace.

      * Cluster

      Cluster that will use the configuration item you create.

      * Namespace

      Namespace to which the configuration item belongs. If you do not specify this parameter, the value default is used by default.

      Description

      Description of the configuration item.

      Configuration Data

      The application configuration data can be used in a container or used to store the configuration data. Key indicates a file name.  Value indicates the content in the file.
      1. Click Add Data.
      2. Set Key and Value.

      Configuration Labels

      Labels are attached to objects such as applications, nodes, and services in key-value pairs.

      Labels define the identifiable attributes of these objects and are used to manage and select the objects.

      1. Click Add Label.
      2. Set Key and Value.
    • To create configuration items by uploading a file, perform the following steps:
      NOTE:

      When creating configuration items by uploading a file, ensure that the resource description file has been created. CCE supports files in JSON or yaml format. For more information, see Configuration Item Requirements for ConfigMap.

      1. Choose a cluster from the Cluster drop-down list.
      2. Choose the namespace to which the configuration item belongs from the Namespace drop-down list. If you do not specify this parameter, the value default is used by default.
      3. Click Upload, select the created ConfigMap resource file, and click Open.

  3. After the configuration is complete, click Create Now.

    The new configuration item is displayed in the configuration item list.

Configuration Item Requirements for ConfigMap

A ConfigMap resource file can be in JSON or YAML format, and the file size cannot exceed 2 MB.

  • JSON format

    The file name is configmap.json and the following shows a configuration example.

    {
      "kind": "ConfigMap",
      "apiVersion": "v1",
      "metadata": {
        "name": "paas-broker-app-017",
        "namespace": "test",
       "enable": true
      },
      "data": {
        "context": "{\"applicationComponent\":{\"properties\":{\"custom_spec\":{}},\"node_name\":\"paas-broker-app\",\"stack_id\":\"0177eae1-89d3-cb8a-1f94-c0feb7e91d7b\"},\"softwareComponents\":[{\"properties\":{\"custom_spec\":{}},\"node_name\":\"paas-broker\",\"stack_id\":\"0177eae1-89d3-cb8a-1f94-c0feb7e91d7b\"}]}"
     }
    }
  • YAML format
    The file name is configmap.yaml and the following shows a configuration example.
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: test-configmap
    data:
      data-1: value-1
      data-2: value-2

Creating a Configuration Item Using kubectl

  1. Follow the instructions in Connecting to a Kubernetes Cluster Using kubectl to configure the kubectl command to connect an ECS server to the cluster.
  2. Create and edit the cce-configmap.yaml file.

    vi cce-configmap.yaml

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: cce-configmap
    data:
      SPECIAL_LEVEL: Hello
      SPECIAL_TYPE: CCE

  3. Run the following commands to create a configuration item.

    kubectl create -f cce-configmap.yaml

    kubectl get cm

    NAME               DATA        AGE            
    cce-configmap      3           3h
    cce-configmap1     3           7m

Related Operations

After creating a configuration item, you can update or delete it as described in Table 2.
Table 2 Related operations

Operation

Description

Updating a configuration item

  1. Select a desired configuration item and click Modify.
  2. Modify the configuration parameters. For more information about the parameters, see Table 1.
  3. Click Modify.

Deleting a configuration item

Select the configuration you want to delete and click Delete.

Follow the prompts to delete the configuration item.