shlogg · Early preview
Cheedge Lee @cheedge

Configuring ConfigMaps In Kubernetes For Env Vars And File Mounting

ConfigMaps in Kubernetes allow you to decouple configuration from code. They can be used as environment variables or mounted as files within a container, making it easy to manage application configurations.

1. ConfigMap type


property-like key


apiVersion: v1
kind: ConfigMap
metadata:
  name: app-config
data:
  api-url: "https://api.example.com"
  log-level: "debug"

    
    

    
    





file-like key


apiVersion: v1
kind: ConfigMap
metadata:
  name: app-config
data:
  config.yaml: |
    apiVersion: v1
    data:
      app-name: "MyApp"
      app-version: "1.0"

    
    

    
    




  
  
  2. ConfigMap consume type

Args

Inside a container command and args
samilar with the env var comsuming method

Env var

Use it as environment variables for a container
normally used property-like k...