Un config maps es un archivo de configuración que contiene una especie de variables que se utilizarán en la configuración de una implementación.
apiVersion: V1
kind: ConfigMap
metadata:
name: test-configmap #name the configmap
data:
#Conexion db
DB_HOST: 127.0.0.1
DB_PORT: '3306'
DB_NAME: 'test_load'
DB_USER: 'user'
DB_PASS: '1234'
Configmaps no se recomienda para la configuración de datos sensibles.
- name: DB_HOST
valueFrom:
configMapKeyRef:
name: test-configmap
key: DB_HOST
apiVersion: v1
kind: Deployment
metadata:
name: test-load-api
spec:
selector:
matchLabels:
app: test-load-api
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
app: test-load-api
spec:
containers:
- name: test-load-api
image: dockerdevops/test_load:0.1.0
env:
- name: DB_HOST
valueFrom:
configMapKeyRef:
name: test-configmap #name of the configmap with the variables
key: DB_HOST
- name: DB_PORT
valueFrom:
configMapKeyRef:
name: test-configmap #name of the configmap with the variables
key: DB_PORT
- name: DB_NAME
valueFrom:
configMapKeyRef:
name: test-configmap #name of the configmap with the variables
key: DB_NAME
- name: DB_USER
valueFrom:
configMapKeyRef:
name: test-configmap #name of the configmap with the variables
key: DB_USER
- name: DB_PASS
valueFrom:
configMapKeyRef:
name: test-configmap #name of the configmap with the variables
key: DB_PASS