[K8S] 컨테이너에 command 실행 적용하기 (while문, tail 명령어, sleep 명령어 등)
조회 3,179 · 댓글 0
spec.containers 아래에 command를 추가한다.
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: multi-container
name: multi-container
spec:
containers:
- image: busybox:1.31.1
name: c1
command: ["sh", "-c", "while true; do date >> /vol/date.log; sleep 1; done"]
volumeMounts:
- name: vol
mountPath: /vol
- image: busybox:1.31.1
name: c2
command: ["sh", "-c", "tail -f /vol/date.log"]
volumeMounts:
- name: vol
mountPath: /vol
dnsPolicy: ClusterFirst
restartPolicy: Always
volumes:
- name: vol
emptyDir: {}
status: {}
apiVersion: v1
kind: Pod
metadata:
labels:
run: sleep-pod
name: sleep-pod
namespace: default
spec:
containers:
- image: nginx:1.21.3-alpine
name: nginx
- image: busybox:1.31
name: bb
command: ["sh", "-c", "sleep 1d"]
resources: {}
dnsPolicy: ClusterFirst
restartPolicy: Always
status: {}로그인 후 답글을 남길 수 있습니다.