# Part 1: Using ConfigMaps

This is Part 1 of a multi-part, self-paced quick start exercise.

Note  
This exercise requires MicroK8s and uses `alias kubectl='microk8s kubectl'`. If you do not have these already installed and running, see " [Prerequisites](https://docs.rafay.co/learn/quickstart/kubernetes/prerequisites/)".

---

## What Will You Do  
In part 1, you will:

- Use a ConfigMap to store a key-value pair.

**Estimated Time**  
Estimated time for this exercise is 5 minutes. Watch a video of the exercise below.

Kubernetes 201-ConfigMaps - YouTube

---

## Using ConfigMaps  
A ConfigMap is an API object used to store non-confidential data in key-value pairs. Pods can consume ConfigMaps as environment variables, command-line arguments, or as configuration files in a volume.

### ConfigMap YAML file
Create a configmap using a YAML file, which is a configuration file. You could create a YAML file from the command line, but for this exercise, you can just use a text editor. Or you can download the configmap YAML file from this public [Git repository](https://github.com/RafaySystems/getstarted/tree/master/kubernetes).

1. Open the Terminal.
2. Navigate to the Downloads folder.

```
   cd ./Downloads
   ```

3. Use the following command to create an empty YAML file in your Downloads folder.

```
   touch configmap.yaml
   ```

4. Use the nano text editor in the Terminal.

```
   nano configmap.yaml
   ```

5. Copy and paste the configuration below into the text editor.
6. Press **Cmd + X**, then type **Y** and press **Return** to save the configmap.yaml file.

7. Open the command prompt.
8. Navigate to the Downloads folder.

```
   cd ./Downloads
   ```

9. Use the following command to create an empty YAML file in your Downloads folder.

```
   copy NUL configmap.yaml
   ```

10. Open the configmap.yaml file with a text editor. For example, use Notepad++ to edit the YAML file.
11. Copy and paste the configuration below into the text editor.
12. Save the configmap.yaml file.

13. Open the Terminal.
14. Navigate to the Downloads folder.

```
   cd ./Downloads
   ```

15. Use the following command to create an empty YAML file in your Downloads folder.

```
   touch configmap.yaml
   ```

16. Use the nano text editor in the Terminal.

```
   nano configmap.yaml
   ```

17. Copy and paste the configuration below into the text editor.
18. Press **Ctrl + X**, then type **Y** and press **Enter** to save the configmap.yaml file.

---

### Add a ConfigMap  
1. In the Terminal or Command Prompt, add the configmap to your environment using a YAML file.

```
   kubectl create -f configmap.yaml
   ```

2. List the configmaps.

```
   kubectl get configmaps
   ```

---

## configmap.yaml  
```yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: mysql-config
  labels:
    app: mysql
data:
  MYSQL_DB: mysqldb
```

Back to top
