다중 컨테이너 포드 (multi-container pods)
pod 내의 컨테이너는 수명주기가 같고, 같은 네트워크에 존재하기 때문에 서로를 localhost 로 참조 할수 있으며,
같은 볼륨에 접근할수 있다.
pod 정의 파일의 spec 섹션에서 containers 섹션이 배열인 이유가 바로, 멀티컨테이너 pod 를 사용할 수 있게끔 하기 위해서이다.
- 아래 YAML 파일은 kode kloud 예제이다.
https://seulseul.tistory.com/22
--
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:
# directory location on host
path: /var/log/webapp
# this field is optional
type: DirectoryOrCreate
- 멀티컨테이너 일때 로그
# 컨테이너 지정후 로그 파일 조회
kubectl -n elastic-stack exec -it app -- cat /log/app.log
# 컨테이너 접속
kubectl exec -it app -- sh
bookmark
https://matthewpalmer.net/kubernetes-app-developer/articles/multi-container-pod-design-patterns.html
https://www.mirantis.com/blog/multi-container-pods-and-container-communication-in-kubernetes/
https://voidmainvoid.tistory.com/145?category=668790
'CKA (Certified Kubernetes Administrator) > CKA TIP' 카테고리의 다른 글
CKA (Certified Kubernetes Administrator) 공부 방법 및 시험 정보 (0) | 2023.01.24 |
---|---|
CKA - Storage (0) | 2022.01.26 |
kubectl Cheat Sheet (0) | 2022.01.25 |
kubernetes create vs apply & run (0) | 2022.01.24 |