|
|
@ -1,44 +1,64 @@
|
||||||
---
|
---
|
||||||
title: "ConfigMaps"
|
title: "ConfigMaps"
|
||||||
keywords: 'kubesphere, kubernetes, docker, ConfigMaps'
|
keywords: 'KubeSphere, Kubernetes, ConfigMaps'
|
||||||
description: 'Create a KubeSphere ConfigMap'
|
description: 'How to create a ConfigMap in KubeSphere'
|
||||||
|
|
||||||
linkTitle: "ConfigMaps"
|
linkTitle: "ConfigMaps"
|
||||||
weight: 2110
|
weight: 2110
|
||||||
---
|
---
|
||||||
|
|
||||||
A Kubernets [ConfigMap](https://kubernetes.io/docs/concepts/configuration/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:
|
A Kubernetes [ConfigMap](https://kubernetes.io/docs/concepts/configuration/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 the environment variable.
|
- Set the value of environment variables.
|
||||||
- Set command parameters in the container.
|
- Set command parameters in containers.
|
||||||
- Create a config file in the volume.
|
- Create a configuration file in volumes.
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
- You need to create a workspace, a project and an account (`project-regular`). Please refer to [Create Workspace, Project, Account and Role](../../../quick-start/create-workspace-and-project) if they are not ready yet.
|
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 Workspace, Project, Account and Role](../../../quick-start/create-workspace-and-project).
|
||||||
- You need to sign in with the `project-admin` account and invite `project-regular` to the corresponding project. Please refer to [the steps to invite a member](../../../quick-start/create-workspace-and-project#task-3-create-a-project).
|
|
||||||
|
|
||||||
## Create a Configmap
|
## Create a ConfigMap
|
||||||
|
|
||||||
### Step 1: Open Dashboard
|
### Step 1: Open Dashboard
|
||||||
|
|
||||||
Log in the console as `project-regular`. Go to **Configurations** of a project, choose **ConfigMaps** and click **Create**.
|
Log in the console as `project-regular`. Go to **Configurations** of a project, choose **ConfigMaps** and click **Create**.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### Step 2: Input Basic Information
|
### Step 2: Input Basic Information
|
||||||
|
|
||||||
Specify a name for the ConfigMap (e.g. `demo-cm`) and click **Next** to continue.
|
Specify a name for the ConfigMap (e.g. `demo-configmap`) and click **Next** to continue.
|
||||||
|
|
||||||

|
{{< notice 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.
|
||||||
|
|
||||||
|
{{</ notice >}}
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
### Step 3: Input Configuration Values
|
### Step 3: Input Configuration Values
|
||||||
|
|
||||||
Under the tab **ConfigMap Settings**, configure values by clicking **Add Data** and input a key-value pair. Click **√** in the bottom right corner and continue adding data if needed.
|
1. Under the tab **ConfigMap Settings**, configure values by clicking **Add Data**.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
When finished, click **Create** to generate the ConfigMap.
|
2. Input a key-value pair. For example:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
{{< notice 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.
|
||||||
|
|
||||||
|
{{</ notice >}}
|
||||||
|
|
||||||
|
3. Click **√** in the bottom right corner to save it and click **Add Data** again if you want to add more key-value pairs.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
4. When you finish, click **Create** to generate the ConfigMap.
|
||||||
|
|
||||||
## Check ConfigMap Details
|
## Check ConfigMap Details
|
||||||
|
|
||||||
|
|
@ -46,25 +66,32 @@ When finished, click **Create** to generate the ConfigMap.
|
||||||
|
|
||||||
1. After a ConfigMap is created, it displays in the list as below. You can click the three dots on the right and select the operation from the menu to modify it.
|
1. After a ConfigMap is created, it displays in the list as below. You can click the three dots on the right and select the operation from the menu to modify it.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
- **Edit**: View and edit the basic information.
|
- **Edit**: View and edit the basic information.
|
||||||
- **Edit YAML**: View, upload, download, or update the YAML file.
|
- **Edit YAML**: View, upload, download, or update the YAML file.
|
||||||
- **Modify Config**: Modify the key-value pairs of the ConfigMap.
|
- **Modify Config**: Modify the key-value pair of the ConfigMap.
|
||||||
- **Delete**: Delete the ConfigMap.
|
- **Delete**: Delete the ConfigMap.
|
||||||
|
|
||||||
2. Click the name of the ConfigMap and you can go to its detail page.
|
2. Click the name of the ConfigMap and you can go to its detail page. Under the tab **Detail**, you can see all the key-value pairs you have added for the ConfigMap.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
3. Click **More** to display what operations about this ConfigMap you can do.
|
3. Click **More** to display what operations about this ConfigMap you can do.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
- **Edit YAML**: View, upload, download, or update the YAML file.
|
- **Edit YAML**: View, upload, download, or update the YAML file.
|
||||||
- **Modify Config**: Modify the key-value pairs of the ConfigMap.
|
- **Modify Config**: Modify the key-value pair of the ConfigMap.
|
||||||
- **Delete**: Delete the ConfigMap, and return to the list page.
|
- **Delete**: Delete the ConfigMap, and return to the list page.
|
||||||
|
|
||||||
4. Click the **Eidt Info** to view and edit the basic information.
|
4. Click the **Eidt Info** to view and edit the basic information.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
|
## Use a ConfigMap
|
||||||
|
|
||||||
|
When you create workloads, [Services](../../../project-user-guide/application-workloads/services/), [Jobs](../../../project-user-guide/application-workloads/jobs/) or [CronJobs](../../../project-user-guide/application-workloads/cronjob/), 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.
|
||||||
|
|
||||||
|

|
||||||
|
After Width: | Height: | Size: 170 KiB |
|
After Width: | Height: | Size: 108 KiB |
|
After Width: | Height: | Size: 219 KiB |
|
After Width: | Height: | Size: 225 KiB |
|
After Width: | Height: | Size: 131 KiB |
|
After Width: | Height: | Size: 168 KiB |
|
After Width: | Height: | Size: 181 KiB |
|
After Width: | Height: | Size: 184 KiB |
|
After Width: | Height: | Size: 227 KiB |
|
After Width: | Height: | Size: 186 KiB |