docker run -e APP_COLOR=pink simple-webapp-color
pod-definition.yaml
apiVersion: v1
kind: Pod
metadata:
name: simple-webapp-color
spec:
containers:
- name: simple-webapp-color
image: simple-webapp-color
ports:
- containerPort: 8080
env:
- name: APP_COLOR
value: pink
APP_COLOR: blue
APP_MODE: prod
1st Create ConfigMap
[imperative]
kubectl create configmap
<<config-name>> --from-literal=<key>=<value>
예시
kubectl create configmap \
app-config --from-literal=APP_COLOR=blue \
--from-literal=APP_MODE=prod
Another Way
kubectl create configmap
<<config-name> --from-file=<path-to-file>
예시
kubectl create configmap \
app-config --from-file-=app_config.properties
[Declarative]
kubectl create -f
config-map.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: app-config
data:
APP_COLOR: blue
APP_MODE: prod
kubectl create -f config-map.yaml
[mysql-config]
port: 3306
max_allowed_packet: 128M
mysql-config.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: mysql-config
data:
port: 3306
max_allowed_packet: 128M
[redis-config]
port: 6379
rdb-compression: yes
redis-config.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: redis-config
data:
port: 6379
rdb-compression: yes
View ConfigMaps
kubectl get configmaps
kubectl describe configmaps
2nd Inject into Pods
pod-definition.yaml
apiVersion: v1
kind: Pod
metadata:
name: simple-webapp-color
spec:
containers:
- name: simple-webapp-color
image: simple-webapp-color
ports:
- containerPort: 8080
envFrom
- configMapRef:
name: app-config
'CKA &. CKAD > Application Lifecycle Management' 카테고리의 다른 글
Secret Practice Test (0) | 2021.03.27 |
---|---|
Secret (0) | 2021.03.27 |
ConfigMap Practice Test (0) | 2021.03.27 |
Application Commands & Argument and Practice Test (0) | 2021.03.27 |
Rolling Update and Rollout (0) | 2021.03.27 |