컨테이너 2개를 가진 멀티컨테이너파드를 만드세요
만약 파드가 crashloopbackoff 상태라면 sleep 1000 명령을 레몬 컨테이너에 추가하세요
Name: yellow
Container 1 Name: lemon
Container 1 Image: busybox
Container 2 Name: gold
Container 2 Image: redis
kubectl run yellow --image=busybox --dry-run=client -o yaml > ./yellow.yaml
생성된 yaml
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: yellow
name: yellow
spec:
containers:
- image: busybox
name: yellow
resources: {}
dnsPolicy: ClusterFirst
restartPolicy: Always
status: {}
lemon 컨테이너에 sleep 1000 커맨드 추가 및 gold 컨테이너 추가
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: yellow
name: yellow
spec:
containers:
- image: busybox
name: lemon
command:
- "sleep"
- "1000"
- image: redis
name: gold
resources: {}
dnsPolicy: ClusterFirst
restartPolicy: Always
status: {}
파드에 로그 볼륨을 마운트한 새로운 컨테이너를 만드세요
Name: app
Container Name: sidecar
Container Image: kodekloud/filebeat-configured
Volume Mount: log-volume
Mount Path: /var/log/event-simulator/
Existing Container Name: app
Existing Container Image: kodekloud/event-simulator
apiVersion: v1
kind: Pod
metadata:
name: app
namespace: elastic-stack
labels:
name: app
spec:
containers:
- name: app
image: kodekloud/event-simulator
volumeMounts:
- mountPath: /log
name: log-volume
- name: sidecar
image: kodekloud/filebeat-configured
volumeMounts:
- mountPath: /var/log/event-simulator/
name: log-volume
volumes:
- name: log-volume
hostPath:
path: /var/log/webapp
type: DirectoryOrCreate
sidecar 컨테이너 추가 후 replace
app 파드의 /log/app.log 파일을 cat 하세요
kubectl -n elastic-stack exec -it app -- cat /log/app.log
'DevOps' 카테고리의 다른 글
Kubernetes - drain, cordon, uncordon (0) | 2024.11.03 |
---|---|
CKA 예제 리마인더 - 18. OS Upgrades (0) | 2024.11.03 |
CKA 예제 리마인더 - 16. Secrets (1) | 2024.11.02 |
Kubernetes - Secret, ConfigMap (0) | 2024.11.02 |
CKA 예제 리마인더 - 14. Commands and Arguments (0) | 2024.10.31 |