Merge pull request #591 from Sherlock113/configmap

Update configmap
This commit is contained in:
KubeSphere CI Bot 2020-11-21 22:48:35 +08:00 committed by GitHub
commit ac13601f49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 50 additions and 23 deletions

View File

@ -1,44 +1,64 @@
---
title: "ConfigMaps"
keywords: 'kubesphere, kubernetes, docker, ConfigMaps'
description: 'Create a KubeSphere ConfigMap'
keywords: 'KubeSphere, Kubernetes, ConfigMaps'
description: 'How to create a ConfigMap in KubeSphere'
linkTitle: "ConfigMaps"
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 command parameters in the container.
- Create a config file in the volume.
- Set the value of environment variables.
- Set command parameters in containers.
- Create a configuration file in volumes.
## 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 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).
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).
## Create a Configmap
## Create a ConfigMap
### Step 1: Open Dashboard
Log in the console as `project-regular`. Go to **Configurations** of a project, choose **ConfigMaps** and click **Create**.
![configmap](/images/docs/project-user-guide/workloads/deployments.png)
![create-configmap](/images/docs/project-user-guide/configurations/configmaps/create-configmap.jpg)
### 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.
![basic-info](/images/docs/project-user-guide/workloads/deployments_form_1.jpg)
{{< 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 >}}
![set-basic-info](/images/docs/project-user-guide/configurations/configmaps/set-basic-info.jpg)
### 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**.
![add-data](/images/docs/project-user-guide/workloads/deployments_form_1.jpg)
![add-data](/images/docs/project-user-guide/configurations/configmaps/add-data.jpg)
When finished, click **Create** to generate the ConfigMap.
2. Input a key-value pair. For example:
![key-value](/images/docs/project-user-guide/configurations/configmaps/key-value.jpg)
{{< 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.
![finish-creating](/images/docs/project-user-guide/configurations/configmaps/finish-creating.jpg)
4. When you finish, click **Create** to generate the ConfigMap.
## 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.
![configmaps](/images/docs/project-user-guide/workloads/deployments_list.png)
![configmap-list](/images/docs/project-user-guide/configurations/configmaps/configmap-list.jpg)
- **Edit**: View and edit the basic information.
- **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.
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.
![configmap-detail](/images/docs/project-user-guide/workloads/deployments_detail.png)
![detail-page](/images/docs/project-user-guide/configurations/configmaps/detail-page.jpg)
3. Click **More** to display what operations about this ConfigMap you can do.
![configmap-dropdown-menu](/images/docs/project-user-guide/workloads/deployments_detail_operation_btn.png)
![configmap-dropdown-menu](/images/docs/project-user-guide/configurations/configmaps/configmap-dropdown-menu.jpg)
- **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.
4. Click the **Eidt Info** to view and edit the basic information.
![edit-configmap](/images/docs/project-user-guide/workloads/deployments_detail_state.png)
![edit-configmap-info](/images/docs/project-user-guide/configurations/configmaps/edit-configmap-info.jpg)
## 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.
![use-configmap](/images/docs/project-user-guide/configurations/configmaps/use-configmap.jpg)

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 KiB