[K8S] 컨테이너에 command 실행 적용하기 (while문, tail 명령어, sleep 명령어 등)
-
huaya
(후아빠) - 이 글의 작성자
- Offline
- Junior
덜보기
더보기
- Posts: 110
- Thank you received: 11
17 Dec 2022 11:20 - 17 Dec 2022 14:14 #31983
작성자: huaya
huaya 님의 글: [K8S] 컨테이너에 command 실행 적용하기 (while문, tail 명령어, sleep 명령어 등)
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: {}
Time to create page: 0.052 seconds