Persistence Volume(PV)를 NFS 방식으로 사용시 Mount Options은 아래와 같이 사용 가능하다.
다만, Storage Class 방식으로 사용하려면 Storage 벤더사에서 CSI(Container Storage Interface)를 지원해야 사용가능 하다.
1. NFS 옵션 조회
사용가능한 옵션을 조회 한다.
[root@bastion ~]# mount -t nfs -o [tab][tab]
_netdev acregmin= context= dirsync hard mounthost= nfsvers= nodev noiversion nostrictatime rdirplus retry= sharecache timeo=
ac actimeo= cto exec intr mountport= noac nodiratime nomand nosuid rdma ro soft udp
acdirmax= async defaults fg iversion mountproto= noacl noexec nordirplus nouser relatime rootcontext= strictatime user
acdirmin= atime defcontext= fsc lookupcache= mountvers= noatime nofail norelatime owner remount rsize= suid users
acl auto dev fscontext= loop namlen=lock noauto nofsc noresvport port= resvport rw sync vers=
acregmax= bg diratime group mand namlen=nolock nocto nointr nosharecache proto= retrans= sec= tcp wsize=
2. PV 생성
PV 내용중 spec.mountOptions을 통해서 정의 한다.
[root@bastion ~]# vi ybkim-test-pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: ybkim-pv
labels:
app: httpd-24
spec:
capacity:
storage: 100Gi
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
mountOptions:
- vers=4.1
- noac
- noatime
nfs:
path: /data/nfs/ybkim/test
server: 200.200.250.1
[root@bastion ~]# oc create -f ybkim-test-pv.yaml
3. PVC 생성
[root@bastion ~]# vi ybkim-test-pvc.yaml
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: ybkim-test-pvc
namespace: ybkim
labels:
app: httpd-24
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 100Gi
volumeName: ybkim-pv
volumeMode: Filesystem
[root@bastion ~]# oc create -f ybkim-test-pvc.yaml
4. Deploymnet 볼륨 마운트
namespace(ybkim)에 볼륨명(volume-test)과 PVC(ybkim-test-pvc)를 정의하고 Pod에서 마운트 될 경로(/mnt)를 지정 한다.
– Deployment 확인
[root@bastion ~]# oc get deployment -n ybkim
NAME READY UP-TO-DATE AVAILABLE AGE
httpd-24 1/1 1 1 62m
– Volume Mount
[root@bastion ~]# oc set volumes deployment/httpd-24 \
--add --name=volume-test \
-t pvc --claim-name=ybkim-test-pvc --mount-path=/mnt \
--overwrite -n ybkim
– Pod에서 NFS 옵션 확인
[root@bastion ~]# oc get pod -n ybkim
NAME READY STATUS RESTARTS AGE
httpd-24-765578d576-w42fc 1/1 Running 0 47s
[root@bastion ~]# oc exec -it httpd-24-765578d576-w42fc \
-- cat /proc/mounts | grep nfs | grep --color -E 'vers|noac|noatime'
200.200.250.1:/data/nfs/ybkim/test /mnt nfs4 rw,sync,noatime,vers=4.1,rsize=1048576,wsize=1048576,namlen=255,acregmin=0,acregmax=0,acdirmin=0,acdirmax=0,hard,noac,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=200.200.250.50,local_lock=none,addr=200.200.250.1 0 0
5. Volume Mount 삭제
Deployment에서 마운트 된 Volume을 삭제할 경우 수행.
[root@bastion ~]# oc set volumes deployment/httpd-24 --remove --name=volume-test -n ybkim
99. RefURL
[1]: Manpage: NFS
[2]: Kubernetes: Persistent Volumes
[3]: OpenShift Docs: Persistent Volume API
[4]: RedHat Knowledge Base: Edit options for persistent volume and storage class mounts in OCP 4
[5]: OpenShift Docs: CSI drivers supported by OpenShift Container Platform
끝.