반응형
[문제]
Application With Persistent Volume Claim
* Create a new PersistentVolumeClaim:
Name: app-volume
StorageClass: az-c
Capacity: 10Mi
* Create a new Pod which mounts the PersistentVolumeClaim as a volume:
Name: web-server-pod
Image: nginx
Mount path: /usr/share/nginx/html
* Configure the new Pod to have ReadWriteMany access on the volume.
[풀이]
아래 docs 링크의 PersistentVolumeClaim 예제 참고
https://kubernetes.io/docs/concepts/storage/persistent-volumes/
문제에 맞게 pvc 구성
# cat app-volume-pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: app-volume
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 10Mi
storageClassName: az-c
# kubectl apply -f app-volume-pvc.yaml
# 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 2d15h
pv1 5Gi RWO,ROX Recycle Available gp2 57d
# kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
app-volume Bound app-config 1Gi RWX az-c 6s
※ 10Mi로 설정하였지만 pv는 모두 1Gi로 설정되어있기 때문에 1Gi로 나옴
web-server-pod 생성 후 볼륨을 마운트 하기 위해서
아래 docs 링크의 PersistentVolumeClaim의 Claims As Volumes 예제 참고
문제 요구 조건에 맞게 구성 진행
# cat web-server-app.yaml
apiVersion: v1
kind: Pod
metadata:
name: web-server-pod
spec:
containers:
- name: nginx
image: nginx
volumeMounts:
- mountPath: "/usr/share/nginx/html"
name: mypd
volumes:
- name: mypd
persistentVolumeClaim:
claimName: app-volume
# kubectl apply -f web-server-app.yaml
# kubectl get pod
# kubectl describe pod web-server-pod
...
Mounts:
/usr/share/nginx/html from mypd (rw)
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-rsctq (ro)
...
Volumes:
mypd:
Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
ClaimName: app-volume
ReadOnly: false
Mount 및 Volumes 설정 확인하면 요구 조건에 맞게 구성된걸 확인할 수 있음
[참고]
- 유투브 따배씨
반응형
'자격증 > CKA' 카테고리의 다른 글
[CKA] Kubernetes Upgrade (0) | 2023.04.22 |
---|---|
[CKA] Check Resource Information (0) | 2023.04.22 |
[CKA] Persistent Volume 생성 (0) | 2023.04.19 |
[CKA] Ingress 구성 (0) | 2023.04.02 |
[CKA] Secret 운영 (0) | 2023.04.01 |