Injecting configurations from files

In its purest, and probably the most common form, a ConfigMap takes a single file. For example, we can create one from the cm/prometheus-conf.yml file:

kubectl create cm my-config \
    --from-file=cm/prometheus-conf.yml

We created a ConfigMap (cm) called my-config. The data of the map is the content of the cm/prometheus-conf.yml file.

Let's describe it, and see what we'll get.

kubectl describe cm my-config  

The output is as follows:

Name:         my-config 
Namespace:    default 
Labels:       <none> 
Annotations:  <none> 
 
Data 
==== 
prometheus-conf.yml: 
---- 
global: 
  scrape_interval:     15s 
 
scrape_configs: 
  - job_name: Prometheus 
    metrics_path: /prometheus/metrics 
    static_configs: 
      - targets: 
        - localhost:9090 
 
Events:  <none> 

The important ...

Get The DevOps 2.3 Toolkit now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.