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 an account (project-regular
). The account must be invited to the project with the role of operator
. For more information, see Create Workspaces, Projects, Accounts and Roles.
Create a ConfigMap
-
Log in to the console as
project-regular
. Go to Configurations of a project, choose ConfigMaps and click Create. -
In the dialog that appears, 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 Mode in the top-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 ConfigMap 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 bottom-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 displays on the ConfigMaps page. You can click on the right and select the operation below from the drop-down list.
- Edit: View and edit the basic information.
- Edit YAML: View, upload, download, or update the YAML file.
- Modify Config: Modify the key-value pair of the ConfigMap.
- Delete: Delete the ConfigMap.
-
Click the name of the ConfigMap to go to its detail page. Under the tab Detail, 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.
- Modify Config: 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 Container Image page, check Environment Variables and click Use ConfigMap or Secret to use a ConfigMap from the list.
Feedback
Was this page Helpful?
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.