- Create a pod called time-check in the dvl1987 namespace. This pod should run a container called time-check that uses the busybox image.
- Create a config map called time-config with the data TIME_FREQ=10 in the same namespace.
- The time-check container should run the command: while true; do date; sleep $TIME_FREQ;done and write the result to the location /opt/time/time-check.log.
- The path /opt/time on the pod should mount a volume that lasts the lifetime of this pod.
apiVersion: v1
kind: Pod
metadata:
name: time-check
namespace: dvl1987
spec:
containers:
- name: time-check
image: busybox
command:
- "/bin/sh"
- "-c"
- "while true; do date; sleep $TIME_FREQ;done > /opt/time/time-check.log"
env:
- name: TIME_FREQ
valueFrom:
configMapKeyRef:
name: time-config
key: TIME_FREQ
volumeMounts:
- mountPath: /opt/time
name: test-volume
volumes:
- name: test-volume
emptyDir: {}
- configmap 의 data를 container의 volume으로 mount할 때 spec.templates.spec.volumes[]에서 key와 path를 설정하면 해당 path 명으로 key의 value값이 들어간 파일이 생성됨.
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis
labels:
app: redis
spec:
replicas: 1
selector:
matchLabels:
app: redis
template:
metadata:
labels:
app: redis
spec:
containers:
- name: redis
image: redis:alpine
ports:
- containerPort: 6379
resources:
requests:
cpu: "200m"
volumeMounts:
- mountPath: /redis-master-data
name: data
- name: redis-config
mountPath: /redis-master
volumes:
- name: data
emptyDir: {}
- name: config-vol
configMap:
name: redis-config
items:
- key: redis-config
path: redis-config
'CKAD' 카테고리의 다른 글
Admission Controller (0) | 2022.04.26 |
---|---|
Practice Test (0) | 2022.04.26 |
6. State Persistence (0) | 2022.04.21 |
4. Pod Design (0) | 2022.04.19 |
2. Configuration (0) | 2022.04.18 |