ConfigMaps
A Kubernetes ConfigMap is used to store configuration data in the form of key-value pairs. The ConfigMap resource provides a way to inject configuration data into Pods. The data stored in a ConfigMap object can be referenced in a volume of type ConfigMap
and then consumed by containerized applications running in a Pod. ConfigMaps are often used in the following cases:
- Set the value of environment variables.
- Set command parameters in containers.
- Create a configuration file in volumes.
This tutorial demonstrates how to create a ConfigMap in KubeSphere.
Prerequisites
You need to create a workspace, a project and a user (project-regular
). The user must be invited to the project with the role of operator
. For more information, see Create Workspaces, Projects, Users and Roles.
Create a ConfigMap
Log in to the console as
project-regular
. Go to Configuration of a project, select ConfigMaps and click Create.In the displayed dialog box, specify a name for the ConfigMap (for example,
demo-configmap
) and click Next to continue.Tip
You can see the ConfigMap manifest file in YAML format by enabling Edit YAML in the upper-right corner. KubeSphere allows you to edit the manifest file directly to create a ConfigMap. Alternatively, you can follow the steps below to create a ConfigMap via the dashboard.On the Data Settings tab, configure values by clicking Add Data.
Enter a key-value pair. For example:
Note
key-value pairs displays under the field
data
in the manifest.On the KubeSphere dashboard, you can only add key-value pairs for a ConfigMap currently. In future releases, you will be able to add a path to a directory containing configuration files to create ConfigMaps directly on the dashboard.
Click √ in the lower-right corner to save it and click Add Data again if you want to add more key-value pairs.
Click Create to generate the ConfigMap.
View ConfigMap Details
After a ConfigMap is created, it is displayed on the ConfigMaps page. You can click on the right and select the operation below from the drop-down list.
- Edit Information: View and edit the basic information.
- Edit YAML: View, upload, download, or update the YAML file.
- Edit Settings: Modify the key-value pair of the ConfigMap.
- Delete: Delete the ConfigMap.
Click the name of the ConfigMap to go to its details page. Under the tab Data, you can see all the key-value pairs you have added for the ConfigMap.
Click More to display what operations about this ConfigMap you can do.
- Edit YAML: View, upload, download, or update the YAML file.
- Edit Settings: Modify the key-value pair of the ConfigMap.
- Delete: Delete the ConfigMap, and return to the list page.
Click Edit Information to view and edit the basic information.
Use a ConfigMap
When you create workloads, Services, Jobs or CronJobs, you may need to add environment variables for containers. On the Add Container page, check Environment Variables and click From secret to use a ConfigMap from the list.
Feedback
Was this page Helpful?
Receive the latest news, articles and updates from KubeSphere
Thanks for the feedback. If you have a specific question about how to use KubeSphere, ask it on Slack. Open an issue in the GitHub repo if you want to report a problem or suggest an improvement.