Let's you inject configuration data into the application.
ConfigMap in Kubernetes is a flexible and scalable way to manage configuration data for your applications,
allowing you to separate configuration from application code, make dynamic updates to configuration, and easily consume configuration data within your Kubernetes cluster.
apiVersion: v1
kind: ConfigMap
metadata:
name: example-configmap
data:
database.properties: |
database.url=jdbc:mysql://localhost:3306/mydb
database.username=admin
database.password=secretpassword
app.properties: |
app.debug=true
app.max_connections=100
#Create a ConfigMap from Literal:
kubectl create configmap
--from-literal== --from-literal==
#Create a ConfigMap from File:
kubectl create configmap --from-file=
#Create a ConfigMap from Directory:
kubectl create configmap --from-file=
#View ConfigMaps:
kubectl get configmaps
#View Details of a ConfigMap:
kubectl describe configmap
#Edit a ConfigMap:
kubectl edit configmap
#Delete a ConfigMap:
kubectl delete configmap
#Apply Changes to a ConfigMap from File:
kubectl apply -f
#Get ConfigMap Data:
kubectl get configmap -o yaml
#Use ConfigMap in a Pod:
volumes:
- name:
configMap:
name:
#As Environment Variables:
envFrom:
- configMapRef:
name:
#As a file
spec:
containers:
- name: mycontainer
image: myimage
volumeMounts:
- name: config-volume
mountPath: /etc/config
volumes:
- name: config-volume
configMap:
name: example-configmap