클라우드 엔지니어 꿈나무
Kubernetes(K8S) Volume - Centos7 본문
hostpath 설정
1. 파일 및 디렉토리 mount + nginx 설치
vi hostpod.yml : nignx 설치와 pod 내 test 디렉토리 및 babo.txt 파일 생성
pod명 : hostvol-nginx
vi hostpod.yml
apiVersion: v1
apiVersion: v1
kind: Pod
metadata:
name: hostvol-nginx
labels:
env: prod
spec:
containers:
- name: n1
image: nginx
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
volumeMounts:
- mountPath: /test
name: kang-vol
- mountPath: /test/babo.txt
name: kang-file
volumes:
- name: kang-vol
hostPath:
path: /data
type: DirectoryOrCreate
- name: kang-file
hostPath:
path: /data/babo.txt
type: FileOrCreate
nodeName: node1
node 1로 지정을 하였으니 node 1에 /data 디렉토리와 babo.txt 생성 후 진행
kubectl apply -f hostpod.yml
kubectl exec hostbol-nginx -- lx /test
확인하면 하기와 같이 babo.txt가 생긴 것을 볼 수 있다.
vi emptydp.ym
apiVersion: apps/v1
kind: Deployment
metadata:
name: vol-dep
labels:
env: prod
spec:
replicas: 1
selector:
matchLabels:
vol: empty
template:
metadata:
name: temp-vol
labels:
vol: empty
spec:
containers:
- name: a1
image: alpine
imagePullPolicy: Never
command: ["tail", "-f", "/home/"]
volumeMounts:
- mountPath: /test1
name: kang-vol
- name: n1
image: nginx
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
volumeMounts:
- mountPath: /test2
name: kang-vol
volumes:
- name: kang-vol
emptyDir: {}
'kubernetes' 카테고리의 다른 글
Kubernetes Storage : Persistent Volume & Claim - Centos7 (0) | 2023.09.17 |
---|---|
Kubernetes(K8S) LoadBalance (metallb) - Centos7 (0) | 2023.09.17 |
Kubernetes(K8S) Labels - Centos7 (0) | 2023.09.17 |
Kubernetes(K8S) 설치 - Centos7 (0) | 2023.09.16 |
Kubernetes(K8S) Storage: Empty Dir - Centos7 (0) | 2023.09.14 |