on
hostpath 컨테이너와 노드간 데이터 공유
hostpath 컨테이너와 노드간 데이터 공유
728x90
# hostpath 컨테이너와 노드간 데이터 공유
# work1과 work2에서 진행
sudo mkdir /var/htdocs sudo -i echo "work1" > /var/htdocs/index.html cat /var/htdocs/index.html
- 동일한 방식으로 work2에도 데이터를 저장
gedit count-httpd.yaml
apiVersion: v1 kind: Pod metadata: name: hostpath-http spec: containers: - image: httpd name: web-server volumeMounts: - name: html mountPath: /usr/local/apache2/htdocs readOnly: true ports: - containerPort: 80 protocol: TCP volumes: - name: html hostPath: path: /var/htdocs type: Directory
kubectl create -f count-httpd.yaml kubectl get pod -w
# 서비스 응답확인
kubectl port-forward hostpath-http 8888:80
127.0.0.1:8888
work2 라는 메세지를 확인 할 수 있다.
- 그렇다면 헌재 서비스중인 것은 work2의 pod가 된다는 것을 알 수 있다.
# pod 서비스 확인하기
kubectl get pod -o wide
- hostpath-http 가 work2에 떠 있는 모습을 볼 수 있다.
# GCP에서 실습하기 - 서비스 확인하기
kubectl get pod -n kube-system
- kube-system은 시스템을 관리하기 위한 pod가 모여있다.
여기서 fluentbit-gke-knwz5 는 데이터 로깅되는 리소스를 가지고 오고 있다.
kubectl get pod fluentbit-gke-knwz5 -n kube-system -o yaml
- 위의 명령어로 조회하면 fluentbit-gke-knwz5의 정보를 볼 수 있다.
volumes: 의 내용을 보면 hostpath가 존재한다.
728x90
from http://may9noy.tistory.com/250 by ccl(A) rewrite - 2021-09-11 17:00:37