diff --git a/content/en/docs/project-user-guide/configuration/configmaps.md b/content/en/docs/project-user-guide/configuration/configmaps.md index 38c77aa46..9c409fc4d 100644 --- a/content/en/docs/project-user-guide/configuration/configmaps.md +++ b/content/en/docs/project-user-guide/configuration/configmaps.md @@ -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. + +{{}} + +![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. + + {{}} + +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) \ No newline at end of file diff --git a/static/images/docs/project-user-guide/configurations/configmaps/add-data.jpg b/static/images/docs/project-user-guide/configurations/configmaps/add-data.jpg new file mode 100644 index 000000000..7ce8d27d9 Binary files /dev/null and b/static/images/docs/project-user-guide/configurations/configmaps/add-data.jpg differ diff --git a/static/images/docs/project-user-guide/configurations/configmaps/configmap-dropdown-menu.jpg b/static/images/docs/project-user-guide/configurations/configmaps/configmap-dropdown-menu.jpg new file mode 100644 index 000000000..7524b44c5 Binary files /dev/null and b/static/images/docs/project-user-guide/configurations/configmaps/configmap-dropdown-menu.jpg differ diff --git a/static/images/docs/project-user-guide/configurations/configmaps/configmap-list.jpg b/static/images/docs/project-user-guide/configurations/configmaps/configmap-list.jpg new file mode 100644 index 000000000..86a37abbf Binary files /dev/null and b/static/images/docs/project-user-guide/configurations/configmaps/configmap-list.jpg differ diff --git a/static/images/docs/project-user-guide/configurations/configmaps/create-configmap.jpg b/static/images/docs/project-user-guide/configurations/configmaps/create-configmap.jpg new file mode 100644 index 000000000..94fa12eb7 Binary files /dev/null and b/static/images/docs/project-user-guide/configurations/configmaps/create-configmap.jpg differ diff --git a/static/images/docs/project-user-guide/configurations/configmaps/detail-page.jpg b/static/images/docs/project-user-guide/configurations/configmaps/detail-page.jpg new file mode 100644 index 000000000..799b18dba Binary files /dev/null and b/static/images/docs/project-user-guide/configurations/configmaps/detail-page.jpg differ diff --git a/static/images/docs/project-user-guide/configurations/configmaps/edit-configmap-info.jpg b/static/images/docs/project-user-guide/configurations/configmaps/edit-configmap-info.jpg new file mode 100644 index 000000000..9b1a516e3 Binary files /dev/null and b/static/images/docs/project-user-guide/configurations/configmaps/edit-configmap-info.jpg differ diff --git a/static/images/docs/project-user-guide/configurations/configmaps/finish-creating.jpg b/static/images/docs/project-user-guide/configurations/configmaps/finish-creating.jpg new file mode 100644 index 000000000..6ef148bac Binary files /dev/null and b/static/images/docs/project-user-guide/configurations/configmaps/finish-creating.jpg differ diff --git a/static/images/docs/project-user-guide/configurations/configmaps/key-value.jpg b/static/images/docs/project-user-guide/configurations/configmaps/key-value.jpg new file mode 100644 index 000000000..b318b2059 Binary files /dev/null and b/static/images/docs/project-user-guide/configurations/configmaps/key-value.jpg differ diff --git a/static/images/docs/project-user-guide/configurations/configmaps/set-basic-info.jpg b/static/images/docs/project-user-guide/configurations/configmaps/set-basic-info.jpg new file mode 100644 index 000000000..62c07951c Binary files /dev/null and b/static/images/docs/project-user-guide/configurations/configmaps/set-basic-info.jpg differ diff --git a/static/images/docs/project-user-guide/configurations/configmaps/use-configmap.jpg b/static/images/docs/project-user-guide/configurations/configmaps/use-configmap.jpg new file mode 100644 index 000000000..3704018d2 Binary files /dev/null and b/static/images/docs/project-user-guide/configurations/configmaps/use-configmap.jpg differ