Create ConfigMaps¶
ConfigMaps store non-confidential data in the form of key-value pairs to achieve the effect of mutual decoupling of configuration data and application code. ConfigMaps can be used as environment variables for containers, command-line parameters, or configuration files in storage volumes.
Note
-
The data saved in ConfigMaps cannot exceed 1 MiB. If you need to store larger volumes of data, it is recommended to mount a storage volume or use an independent database or file service.
-
ConfigMaps do not provide confidentiality or encryption. If you want to store encrypted data, it is recommended to use secret, or other third-party tools to ensure the privacy of data.
You can create ConfigMaps with two methods:
- Graphical form creation
- YAML creation
Prerequisites¶
-
Integrated the Kubernetes cluster or created the Kubernetes cluster, and you can access the UI interface of the cluster.
-
Created a namespace, user, and authorized the user as NS Editor. For details, refer to Namespace Authorization.
Graphical form creation¶
-
Click the name of a cluster on the Clusters page to enter Cluster Details .
-
In the left navigation bar, click ConfigMap and Secret -> ConfigMap , and click the Create ConfigMap button in the upper right corner.
-
Fill in the configuration information on the Create ConfigMap page, and click OK .
!!! note
Click __Upload File__ to import an existing file locally to quickly create ConfigMaps.
-
After the creation is complete, click More on the right side of the ConfigMap to edit YAML, update, export, delete and other operations.
YAML creation¶
-
Click the name of a cluster on the Clusters page to enter Cluster Details .
-
In the left navigation bar, click ConfigMap and Secret -> ConfigMap , and click the YAML Create button in the upper right corner.
-
Fill in or paste the configuration file prepared in advance, and then click OK in the lower right corner of the pop-up box.
!!! note
- Click __Import__ to import an existing file locally to quickly create ConfigMaps. - After filling in the data, click __Download__ to save the configuration file locally.
-
After the creation is complete, click More on the right side of the ConfigMap to edit YAML, update, export, delete and other operations.
ConfigMap YAML example¶
```yaml
kind: ConfigMap
apiVersion: v1
metadata:
name: kube-root-ca.crt
namespace: default
annotations:
data:
version: '1.0'
```