# Config Map

When we would like to add the env variable to `Pod` , we can do it by add the property called env in `definition file` <br>

```yaml
# Pod Template
apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  containers:
  - name: nginx
    image: nginx:1.14.2
    ports:
    - containerPort: 80
    env:
      - name:
        value:   
      - name:
        value:
    # For ConfigMap case (1)
      - name: APP_COLOR
        valueFrom: 
          configMapRef:
            name: app-config
            key: APP_COLOR  
    # For ConfigMap case (2)
    envFrom:
      - configMapRef:
          name:
    # For ConfigMap case (3)
    volumes:
    - name: app-config-volume
      configMap:
        name: app-config               
```

but It's hard to manage in the configuration in `definition file`  so we have `Config map`  for managing the configuration&#x20;

**CheatSheet**

1. Create Configmap (Imperative way):&#x20;

* `kubectl create configmap <config_name> --from-literal=<key>=<value>`
* `kubectl create configmap <config_name> --from-file=<path_to_file>`

2. Create Configmap (Declarative way):&#x20;

```yaml
# Configmap Template
apiVersion: v1
kind: ConfigMap
metadata:
  name: <configmap_name>
data:
  <key>: <value>
```
