Updated on 2024-09-27 GMT+08:00

Managing Configuration Items

Configuration items (ConfigMaps) are user-defined resources that store application configurations. They can be used as files or environment variables in applications.

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

Benefits of configuration items:

  • Manage configurations for different environments and services.
  • Deploy applications in different environments. You can maintain configuration files in multiple versions, which makes it easy to update and roll back applications.
  • Quickly import configurations in the form of files to containers.

This section describes how to create, view, update, and delete configuration items for the CCE cluster bound to a Kubernetes environment.

Prerequisites

  1. A CCE cluster has been bound to the environment. For details, see Binding a CCE Cluster.
  2. The namespace to which the configuration item belongs has been created. For details, see Creating a Namespace.

Creating a Configuration Item

  1. Log in to ServiceStage.
  2. On the Environment Management page, click the target environment.
  3. In the Resources area, choose Clusters from Compute.
  4. Click Configuration Item > Create Configuration Item.

    ServiceStage allows you to create configuration items in Visualization or YAML mode.
    • Method 1: Visualization
      Configure the configuration item by referring to Table 1. Parameters marked with an asterisk (*) are mandatory.
      Table 1 Parameters for creating a configuration item in visualization mode

      Parameter

      Description

      *Configuration Name

      Configuration item name, which must be unique in a namespace.

      Enter 4 to 24 characters. Start with a lowercase letter and end with a lowercase letter or digit. Only use lowercase letters, digits, and hyphens (-).

      *Cluster

      Cluster where the configuration item will be used.

      *Namespace

      Namespace to which the configuration item belongs.

      Description

      Configuration item description. Enter 0 to 255 characters.

      Configuration Data

      Configuration data to be used in applications or used to store configuration data. Key indicates a file name, and Value indicates the content in the file.

      1. Click Add Data.
      2. Enter the key and value.
        • The key contains 1 to 63 characters. Only use digits, letters, dots (.), hyphens (-), and underscores (_).
        • The value contains 0 to 1,048,576 characters.

      Configuration Labels

      Labels that you want to attach to various objects (such as applications, nodes, and services) in the form of key-value pairs. Labels define the identifiable attributes of these objects and are used to manage and select the objects.

      1. Click Add.
      2. Enter the key and value.
        • The key contains 1 to 63 characters. Start and end with a letter or digit. Only use digits, letters, dots (.), hyphens (-), underscores (_), and slashes (/).
        • The value contains 1 to 63 characters. Start and end with a letter or digit. Only use digits, letters, dots (.), hyphens (-), and underscores (_).
      Figure 1 Setting configuration item parameters in Visualization mode
    • Method 2: YAML

      To create a configuration item by uploading a file, ensure that a configuration item resource file in YAML format has been created and the file size is less than 1 MB. For details, see Requirements for the Configuration Item Resource File.

      1. Select a cluster from the Cluster drop-down list.
      2. Use either of the following methods to set the configuration item resource file:
        • Click Upload File, select the configuration item resource file created locally, click Open, and wait until the file is uploaded.
        • Write or modify the ConfigMap resource file in Orchestration content.
      Figure 2 Setting configuration item parameters in YAML mode

  5. Click Create ConfigMap.

    After the configuration item is created, it is displayed in the configuration item list.

Follow-Up Operations

After a configuration item is created, you can search for, view, update, and delete the configuration item by referring to Table 2.

  • Deleted items cannot be restored. Exercise caution when performing this operation.
  • The configuration item list contains system configuration items, which can only be viewed and cannot be modified or deleted.
Table 2 Configuration item management operations

Operation

Description

Searching for a configuration item

  1. Select the namespace to which the configuration item belongs from the namespace drop-down list.
  2. Enter a configuration item name in the search box.

Viewing a configuration item

Click Show YAML in the Operation column of the target configuration item to view the content of the YAML file of the configuration item.

Modifying a configuration item

  1. Click Update in the Operation column of the target configuration item.
  2. Modify the information according to Table 1.
  3. Click Update Configuration Item.

Deleting a configuration item

  1. Click Delete in the Operation column of the target configuration item.
  2. In the displayed dialog box, click OK.

Deleting configuration items in batches

  1. Select the configuration items to be deleted.
  2. Click Delete Configuration Item.
  3. In the displayed dialog box, click OK.

Requirements for the Configuration Item Resource File

A configuration item resource file should be in YAML format, and the file size cannot exceed 1 MB.

Example:

apiVersion: v1
data: {}
kind: ConfigMap
metadata:
  annotations:
    description: ''
  labels: {}
  name: configmap-ww8qkl
  namespace: cse