728x90
[주의] 개인 공부를 위해 쓴 글이기 때문에 주관적인 내용은 물론, 쓰여진 정보가 틀린 것일 수도 있습니다!
피드백 부탁드립니다. (- -)(_ _) 꾸벅
[ PV 실습 ]
Question : Create Persistent Volume
TASK :
Create a persistent volume whith name app-config of capacity 1Gi and access mode ReadWriteMany. StorageClass: az-c The Type of volume is hostPath and its location is /root/cka_pvc_test.
$ vi pv_cka.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: app-config
spec:
storageClassName: az-c
capacity:
storage: 1Gi
accessModes:
- ReadWriteMany
hostPath:
path: "/root/cka_pvc_test"
$ kubectl apply -f pv_cka.yaml
persistentvolume/app-config created\
$ kubectl get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
app-config 1Gi RWX Retain Available az-c
[ PVC 실습 ]
Question : Application with PersistentVolumeClaim
TASK 1 :
Create a new PersistentVolumeClaim
- Name : app-volume
- StorageClass : az-c
- Capacity : 10Mi
TASK 2 :
Create a new Pod which mounts the PersistentVolumeClaim as a volume
- Name : web-server-pod
- Image : nginx
- Mount path : /usr/share/nginx/html
TASK 3 :
Configure the new Pod to have ReadWriteMany access on the volume.
Task 1
$ vi pvc_cka.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: app-volume
spec:
storageClassName: az-c
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Mi
$ kubectl apply -f pvc_cka.yaml
# 같은 Storage Class Name을 가진 PV가 PVC에 할당된다
yoon@master:~$ kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
app-volume Bound app-config 1Gi RWX az-c 4s
yoon@master:~$ kubectl get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
app-config 1Gi RWX Retain Bound default/app-volume az-c 18m
Task 2
$ vi web_server_pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: web-server-pod
spec:
volumes:
- name: web-volume
persistentVolumeClaim:
claimName: app-volume
containers:
- name: web-server-pod
image: nginx
ports:
- containerPort: 80
name: "http"
volumeMounts:
- mountPath: "/usr/share/nginx/html"
name: web-volume
$ kubectl apply -f web_server_pod.yaml
Task 3
$ kubectl edit pv app-config
...
spec:
accessModes:
- ReadWriteMany
...
728x90
'클라우드 > 쿠버네티스' 카테고리의 다른 글
[Kubernetes] 16. 쿠버네티스 Ingress 인그레스 (0) | 2023.04.23 |
---|---|
[Kubernetes] 15. 쿠버네티스 Configmap과 Secret (컨피그맵, 시크릿) (0) | 2023.04.04 |
[Kubernetes] 14. 쿠버네티스 Node에 Pod 할당하기 (nodeSelector, Affinity, nodeName) (3) | 2023.03.09 |
[Kubernetes] 13. 쿠버네티스 사이드카 패턴(Sidecar pattern) 및 실습 (3) | 2023.03.05 |
CKA 정리 및 북마크 (0) | 2023.01.16 |