Red Hatã§ã½ãªã¥ã¼ã·ã§ã³ã¢ã¼ããã¯ãããã¦ããç°ä¸å¸æ©(@tnk4on)ã§ãã ãã®é£è¼ã¯vSphereç°å¢ä¸ã«OpenShift Container Platformï¼ä»¥ä¸ãOpenShiftï¼ããã³OpenShift Virtualizationã®ç°å¢ãæ§ç¯ããæ¹æ³ã解説ããã·ãªã¼ãºã§ãã
æ¬è¨äºã¯å ã ãé£è¼ãã¼ãããã¯ãããOpenShift Virtualizationãã®ç¬¬3åã¨ãã¦æ稿ããå 容ã®NFSãããã¸ã§ãã¼ã®æ§ç¯é¨åã®ã¿ãããã¯ã¢ããããå 容ã§ãã ãã®NFSãããã¸ã§ãã¼ã¯ããªã¥ã¼ã ã®ã¹ãããã·ã§ããã«å¯¾å¿ãã¦ããããOpenShift Virtuzalizationã¨ãã¦å©ç¨ããã«ã¯æ©è½ä¸è¶³ãªç¹ãããã¾ããã ãã®ãããæ¬é£è¼ç¬¬3åã®å 容ã¯NFS CSI driver for Kubernetesï¼ä»¥ä¸ãNFS CSIãã©ã¤ãã¼ï¼ã使ã£ãå 容ã«å¤æ´ãã¦ããã¾ãã æ¬è¨äºã¯ããã¾ã§åèæ å ±ã¨ãã¦æ®ãã¦ãããã¨ãç®çã¨ãã¾ãã
æ¬é£è¼ã®ä¸è¦§ã¯ä¸è¨ã®éãã§ãã
- 第1åï¼OpenShiftã®ã¤ã³ã¹ãã¼ã«
- 第2åï¼OpenShiftã¤ã³ã¹ãã¼ã«å¾ã®ä½æ¥
- 第3åï¼å ±æã¹ãã¬ã¼ã¸ã®ä½æï¼NFS CSIãã©ã¤ãã¼ã®æ§ç¯ï¼
- 第4åï¼OpenShift Virtualizationã®ã¤ã³ã¹ãã¼ã«ã¨å®è¡
- 第5åï¼vSphereä»®æ³ãã·ã³ã®ç§»è¡
- ãçªå¤ç·¨ãï¼å ±æã¹ãã¬ã¼ã¸ã®ä½æï¼NFSãããã¸ã§ãã¼ã®æ§ç¯ï¼ï¼âæ¬è¨äºï¼
-ç®æ¬¡-
- åææ¡ä»¶
- 1. NFSãããã¸ã§ãã¼ã®è¨å®
- ã¾ã¨ã
åææ¡ä»¶
- é£è¼ç¬¬1åã第2åããã³ã第3åã®ã2. è¸ã¿å°ãµã¼ãã¼ä¸ã®NFSãµã¼ãã¼è¨å®ãä½æ¥ãå®äºãã¦ãããã¨ã¨ãã¾ã
- NFSãããã¸ã§ãã¼æ§ç¯å¾ã®ãã¤ã¡ã¼ã¸ã¬ã¸ã¹ããªã®è¨å®ãã¯ç¬¬3åãåç §ãã ãã
- å ¨ä½ã®æ§æãåãã©ã¡ã¼ã¿ã¼ãªã©ã¯é£è¼ç¬¬1åãåç §ãã¦ãã ãã
- ä½æ¥ç¨ç«¯æ«ã®ããã³ããã¯
%
ã¨ãã¾ã - è¸ã¿å°ãµã¼ãã¼ã®ããã³ããã¯
$
ã¨ãã¾ã - è¸ã¿å°ãµã¼ãã¼ã®ä½æ¥ã¯æ示çã«è¨è¼ãããå ´åãé¤ãã¦ãä½æ¥ãã£ã¬ã¯ããª
${HOME}/work
ã§ä½æ¥ãããã¨ã¨ãã¾ã
1. NFSãããã¸ã§ãã¼ã®è¨å®
è¸ã¿å°ãµã¼ãã¼ä¸ã«æ§ç¯ããNFSãµã¼ãã¼ãå©ç¨ãã¦PVã®åçãããã¸ã§ãã³ã°ãè¡ããããOpenShiftã«NFSãããã¸ã§ãã¼ãã¤ã³ã¹ãã¼ã«ãã¾ãã
1-1 NFSãããã¸ã§ãã¼ã«ã¤ãã¦
OpenShiftã§PVã®åçãããã¸ã§ãã³ã°ãè¡ãããã«ã¯ã¹ãã¬ã¼ã¸ã¨ããã«å¯¾å¿ããCSIãã©ã¤ãã¼ãå¿ è¦ã§ãã ä»åæ§ç¯ããã¹ãã¬ã¼ã¸ã¯RHELã§ç«ã¦ãæ±ç¨çãªNFSãµã¼ãã¼ãªã®ã§å°ç¨ã®CSIãã©ã¤ãã¼ãããã¾ããã ããã§ä»åã¯ãæ±ç¨çãªNFSãµã¼ãã¼ãããã¯ã¨ã³ãã«ä½¿ç¨ãPVã®åçãããã¸ã§ãã³ã°ãè¡ããã¨ãã§ãããNFS Subdir External Provisionerï¼ä»¥ä¸ãNFSãããã¸ã§ãã¼ï¼ããå©ç¨ãã¾ãã
ãã®NFSãããã¸ã§ãã¼ã¯Kuberentes SIGsã§ãã¹ãããã¦ãããªãã¸ããªã®1ã¤ã§ããOSSã§éçºããã¦ããApache-2.0 licenseã«å¾ãç¡åã§å©ç¨ã§ãã¾ãã
ãªãããã®NFSãããã¸ã§ãã¼ã¯æ±ç¨çãªNFSãµã¼ãã¼ãããã¯ã¨ã³ãã«å©ç¨ã§ããåé¢ãé«åº¦ãªæ©è½ã«ã¯å¯¾å¿ãã¦ãã¾ããï¼ã¹ãã¬ã¼ã¸ã®æ©è½ã使ã£ãVolume CLoneãªã©ï¼ã
Support for "CSI Volume Cloning" · Issue #182 · kubernetes-sigs/nfs-subdir-external-provisioner
å®ç¨¼åç°å¢ã§ã¯ã¹ãããã·ã§ãããããªã¥ã¼ã ã¯ãã¼ãã³ã°ã«å¯¾å¿ããCSIãã©ã¤ããæä¾ãã¦ããã¹ãã¬ã¼ã¸ãã³ãã¼ãªã©ã®è£½åããå©ç¨ãã ããã
1-2 NFSãããã¸ã§ãã¼ã®åä½
NFSãããã¸ã§ãã¼ã®åä½ã®æµãã¯ä¸è¨ã®éãã§ã
1-3 NFSãããã¸ã§ãã¼ã®ã¤ã³ã¹ãã¼ã«
NFSãããã¸ã§ãã¼ãã¤ã³ã¹ãã¼ã«ããæµãã¯ä¸è¨ã®ã¨ããã§ãã
- NFSãããã¸ã§ãã¼ç¨ã®ããã¸ã§ã¯ããä½æ
- ãµã¼ãã¹ã¢ã«ã¦ã³ãã®ä½æ
- Helmã®ã¤ã³ã¹ãã¼ã«
- NFSãããã¸ã§ãã¼ã®ã¤ã³ã¹ãã¼ã«
ç¾æç¹ã§ã¯ã³ãã³ãã®è©³ç´°ãæ·±ãç解ããå¿ è¦ã¯ããã¾ãããã¾ãã¯ãã¾ããªãçã«ã³ãã³ããã³ãããã¦å®è¡ãã¦ãã ããã
ï¼ï¼ï¼NFSãããã¸ã§ãã¼ç¨ã®ããã¸ã§ã¯ããä½æ
oc new-project
ã³ãã³ãã§NFSãããã¸ã§ãã¼ç¨ã®ããã¸ã§ã¯ããä½æãã¾ãã
ããã¸ã§ã¯ãåã¯nfs-subdir-external-provisioner
ã¨ãã¾ãã
$ oc new-project nfs-subdir-external-provisioner
ï¼2ï¼ãµã¼ãã¹ã¢ã«ã¦ã³ãã®ä½æ
NFSãããã¸ã§ãã¼ã®ã¤ã³ã¹ãã¼ã«ã®åã«ãµã¼ãã¹ã¢ã«ã¦ã³ããä½æãã¾ãã ãµã¼ãã¹ã¢ã«ã¦ã³ãã¯ãKubernetesãOpenShiftã§ã·ã¹ãã ã³ã³ãã¼ãã³ããã¢ããªã±ã¼ã·ã§ã³ãAPIãµã¼ãã¼ã¨å®å ¨ã«éä¿¡ããããã«ä½¿ç¨ãããç¹æ®ãªã¢ã«ã¦ã³ãã§ãã
æåã§ä½æããnfs-subdir-external-provisioner
ãµã¼ãã¹ã¢ã«ã¦ã³ãã«æ¨©éãã©ãã«ãã¢ããã¼ã·ã§ã³ã追å ãã¾ãã
$ oc create sa nfs-subdir-external-provisioner $ oc adm policy add-scc-to-user hostmount-anyuid system:serviceaccount:nfs-subdir-external-provisioner:nfs-subdir-external-provisioner $ oc label sa nfs-subdir-external-provisioner app.kubernetes.io/managed-by=Helm $ oc annotate sa nfs-subdir-external-provisioner meta.helm.sh/release-name=nfs-subdir-external-provisioner meta.helm.sh/release-namespace=nfs-subdir-external-provisioner
oc adm policy add-scc-to-user
ï¼ãµã¼ãã¹ã¢ã«ã¦ã³ãã«hostmount-anyuid
ã¨ããSCCã追å ãã¾ãoc label sa
ï¼ãã®ãµã¼ãã¹ã¢ã«ã¦ã³ããHelmã«ãã£ã¦ç®¡çããã¦ãããã¨ã示ãã©ãã«ã追å ããoc annotate sa
ï¼ãµã¼ãã¹ã¢ã«ã¦ã³ãã«Helmãªãªã¼ã¹ã«é¢ããã¡ã¿ãã¼ã¿ãã¢ããã¼ã·ã§ã³ã¨ãã¦è¿½å ãã
ããã§NFSãããã¸ã§ãã¼ãã¤ã³ã¹ãã¼ã«ããæºåãæ´ãã¾ããã
ï¼3ï¼Helmã®ã¤ã³ã¹ãã¼ã«
NFSãããã¸ã§ãã¼ã®ã¤ã³ã¹ãã¼ã«ã§Helm*1ã使ç¨ãã¾ãã Helmã¯ããã±ã¼ã¸ããã¼ã¸ã£ã¼ã®1ã¤ã§ãã¢ããªã±ã¼ã·ã§ã³ãããã±ã¼ã¸ï¼Helmã§ã¯ãã£ã¼ãã¨ããï¼ã¨ãã¦Kuberenetesä¸ã«ç°¡åã«ãããã¤ã§ããä»çµã¿ã§ãã ä»åã®æ§æã§ã¯è¸ã¿å°ãµã¼ãã¼ã«Helmãã¤ã³ã¹ãã¼ã«ãã¾ããHelmã®ã¤ã³ã¹ãã¼ã«ããã¥ã¡ã³ãã¯ä¸è¨ã§ãï¼æ¬è¨äºã§ã¯Red Hatãæä¾ãã¦ããHelmã®ãã¤ããªãå©ç¨ãã¾ãï¼ã
6.2. Helm ã®ã¤ã³ã¹ãã¼ã« | Red Hat Product Documentation
x86_64ã®ç°å¢ã«Helmãã¤ã³ã¹ãã¼ã«ããã³ãã³ãä¾ã¯ä¸è¨ã®ã¨ããã§ãã
$ sudo curl -L https://mirror.openshift.com/pub/openshift-v4/clients/helm/latest/helm-linux-amd64 -o /usr/local/bin/helm $ sudo chmod +x /usr/local/bin/helm
Helmã®ã¤ã³ã¹ãã¼ã«å¾ãhelm
ã³ãã³ããå®è¡ãã¦åä½ç¢ºèªãè¡ãã¾ãã
$ helm version WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /home/user/work/auth/kubeconfig WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /home/user/work/auth/kubeconfig version.BuildInfo{Version:"v3.14.4+37.el9", GitCommit:"7163c12e65c8c0a40334c0a4b514b991ea37aa21", GitTreeState:"clean", GoVersion:"go1.21.9 (Red Hat 1.21.9-2.el9_4)"}
KUBECONFIG
ç°å¢å¤æ°ãã»ããããã¦ãã¦ããã¤kubeconfig
ãã¡ã¤ã«ã®ãã¼ããã·ã§ã³ãææè
以å¤ããèªã¿è¾¼ã¿å¯è½ã«ãªã£ã¦ããã¨ã³ãã³ãã®åºåã«è¦åãåºã¾ãã
æ°ã«ãªãæ¹ã¯chmod
ã³ãã³ãã§ãã¼ããã·ã§ã³ãå¤æ´ãã¦ãã ããã
$ chmod 600 auth/kubeconfig
ï¼4ï¼NFSãããã¸ã§ãã¼ã®ã¤ã³ã¹ãã¼ã«
NFSãããã¸ã§ãã¼ã¯OpenShiftã«ã¤ã³ã¹ãã¼ã«ãã¾ããåãã«ãã£ã¼ããªãã¸ããªã追å ãããã®å¾ã«ã¤ã³ã¹ãã¼ã«ãè¡ãã¾ãã
helm repo add
ã³ãã³ãã§NFSãããã¸ã§ãã¼ã®ãã£ã¼ããªãã¸ããªã追å ãã¾ãã
$ helm repo add nfs-subdir-external-provisioner https://kubernetes-sigs.github.io/nfs-subdir-external-provisioner/
~/.config/helm
ãã£ã¬ã¯ããªãä½æãããåç §ãããªãã¸ããªã®æ å ±ãä¿åããã¾ã
helm install
ã³ãã³ãã§NFSãããã¸ã§ãã¼ãã¤ã³ã¹ãã¼ã«ãã¾ãã
--set
ãªãã·ã§ã³ã使ã£ã¦åºæã®æ
å ±ã追å ã§æå®ãã¾ãã
$ helm install nfs-subdir-external-provisioner nfs-subdir-external-provisioner/nfs-subdir-external-provisioner \ --set nfs.server=192.168.1.206 \ --set nfs.path=/mnt/nfs \ --set storageClass.accessMode=ReadWriteMany
nfs.server
ï¼NFSãµã¼ãã¼ã®IPã¢ãã¬ã¹/ãã¹ãåãæå®nfs.path
ï¼NFSã¨ã¯ã¹ãã¼ããè¡ã£ããã¹ãæå®storageClass.accessMode
ï¼RWXã使ç¨ããããReadWriteMany
ãæå®
helm install
ã³ãã³ããå®è¡ããã¨ä¸è¨ã®ãããªå¿çãåºåããã¾ã
... NAME: nfs-subdir-external-provisioner LAST DEPLOYED: Mon Jul 8 05:15:36 2024 NAMESPACE: nfs-subdir-external-provisioner STATUS: deployed REVISION: 1 TEST SUITE: None
NFSãããã¸ã§ãã¼ãæ£å¸¸ã«ã¤ã³ã¹ãã¼ã«ã§ãããã©ããã¯æ¬¡ã®æé ã§ç¢ºèªãã¾ãã
ï¼5ï¼NFSãããã¸ã§ãã¼ã®ã¤ã³ã¹ãã¼ã«ã®ç¢ºèª
OpenShiftã®Webã³ã³ã½ã¼ã«ããã管çè åã表示ãã®ãã«ãã¦ã³ãé¸æããéçºè ããé¸æãã¾ãã ããã«ããéçºè åã表示ï¼Developerãã¼ã¹ãã¯ãã£ãï¼ã«åãæ¿ãããã¨ãã§ãã¾ãã
å·¦ã®ã¡ãã¥ã¼ããããããã¸ã¼ããé¸æãã¾ããããã¸ã§ã¯ãã®ãã«ãã¦ã³ã¡ãã¥ã¼ãããnfs-subdir-external-provisioner
ããé¸æãã¾ãã
ç»é¢å
ã«ãDãã®ã¢ã¤ã³ã³ãã¤ããnfs-subdir-external-provisioner
ã¨ãããªãã¸ã§ã¯ãï¼Deploymentï¼ã表示ããã¾ãã
ãã®Deploymentã¯NFSãããã¸ã§ãã¼ã®ã¢ããªã±ã¼ã·ã§ã³Podã®å±éã¨ç®¡çãè¡ããªã½ã¼ã¹ã§ãã
å·¦ã®ã¡ãã¥ã¼ããHelmãé¸æããã¨ãç¾å¨é¸æãã¦ããããã¸ã§ã¯ãã«ç»é²æ¸ã¿ã®Helmãªãªã¼ã¹*2ã®æ å ±ã表示ããã¾ãã
ãHRãã¢ã¤ã³ã³ãä»ããHelmãªãªã¼ã¹åï¼ããã§ã¯nfs-subdir-external-provisioner
ï¼ã®ãªã³ã¯ãé¸æãã¾ãã
Helmã§ã¤ã³ã¹ãã¼ã«ããããªã½ã¼ã¹ã®ååãã¿ã¤ããä¸è¦§ã§è¡¨ç¤ºããã¾ããå ã»ã©ç¢ºèªããDeploymentã®ã¹ãã¼ã¿ã¹æ¬ã«ã¯Podã1ã¤èµ·åãã¦ãããã¨ã確èªã§ãã¾ãã ãã®PodãNFSãããã¸ã§ãã¼ãå®è¡ããå®ä½ï¼ã®ã³ã³ããï¼ã¨ãªãã¾ãã
1-4 ããã©ã«ãã¹ãã¬ã¼ã¸ã¯ã©ã¹ã®è¨å®
ã¹ãã¬ã¼ã¸ã¯ã©ã¹ã¨ã¯PVã®åçãããã¸ã§ãã³ã°ãå®ç¾©ããããã«ä½¿ç¨ããã¾ããã¦ã¼ã¶ã¼ã¯å¿ è¦ãªã¹ãã¬ã¼ã¸ã¯ã©ã¹ãæå®ãã¦æ°¸ç¶ããªã¥ã¼ã è¦æ±ï¼PVCï¼ãä½æãã¾ãã
ã¹ãã¬ã¼ã¸ã¯ã©ã¹ã®è©³ç´°ã«ã¤ãã¦ã¯ä¸è¨ã®ããã¥ã¡ã³ããåç §ãã¦ãã ããã
5.6. ããã©ã«ãã¹ãã¬ã¼ã¸ã¯ã©ã¹ã®ç®¡ç | Red Hat Product Documentation
ããã©ã«ãã¹ãã¬ã¼ã¸ã¯ã©ã¹ã¨ã¯2ã¤ä»¥ä¸ã®ã¹ãã¬ã¼ã¸ã¯ã©ã¹ãåå¨ããå ´åã«æ¨æºçã«ä½¿ç¨ãããã¹ãã¬ã¼ã¸ã¯ã©ã¹ã®ãã¨ã§ãã ä»åã®æ§æã§ã¯ã¹ãã¬ã¼ã¸ã¯ã©ã¹ã¯1ã¤ããä½æããã¦ãã¾ããããæ示çã«è¨å®ããã¦ãããã¨ã§ä»ã®ã¹ãã¬ã¼ã¸ã¯ã©ã¹ãããåªå çã«å©ç¨ããããã«ãã¦ããã¾ãã
ããã©ã«ãã¹ãã¬ã¼ã¸ã¯ã©ã¹ãè¨å®ããã«ã¯ä¸è¨ã®ã³ãã³ããå®è¡ãã¾ãã
ä»åã¯ã¹ãã¬ã¼ã¸ã¯ã©ã¹åï¼nfs-client
ã«å¯¾ãã¦é常ã®ã³ã³ããã¢ããªã±ã¼ã·ã§ã³ã¨ä»®æ³ãã·ã³ã®ä¸¡æ¹ã«ããã©ã«ãè¨å®ãè¡ãã¾ãã
$ oc patch storageclass nfs-client -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}' $ oc patch storageclass nfs-client -p '{"metadata": {"annotations":{"storageclass.kubevirt.io/is-default-virt-class":"true"}}}'
è¨å®ãåæ ããã¦ãããä¸è¨ã®ã³ãã³ããå®è¡ãã¦ç¢ºèªãè¡ãã¾ãã
oc get
ã³ãã³ãã§å¼æ°ã«storageclass
ãæå®ããããã«-o yaml
ãªãã·ã§ã³ã追å ãã¦ãã¹ãã¬ã¼ã¸ã¯ã©ã¹ã®è¨å®å
容ãYAMLå½¢å¼ã§åºåãè¡ãã¾ãã
$ oc get storageclass -o yaml
åºåçµæå
ã®annotations:
ã«å
ã»ã©è¨å®ããå¤ãåæ ããã¦ããã確èªã§ãã¾ããä¸è¨ã®åºåçµæãå±éãã¦å
容ã確èªãã ããã
åºåçµæãéã
$ oc get storageclass -o yaml apiVersion: v1 items: - allowVolumeExpansion: true apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: annotations: meta.helm.sh/release-name: nfs-subdir-external-provisioner meta.helm.sh/release-namespace: nfs-subdir-external-provisioner storageclass.kubernetes.io/is-default-class: "true" storageclass.kubevirt.io/is-default-virt-class: "true" creationTimestamp: "2024-06-28T07:10:00Z" labels: app: nfs-subdir-external-provisioner app.kubernetes.io/managed-by: Helm chart: nfs-subdir-external-provisioner-4.0.18 heritage: Helm release: nfs-subdir-external-provisioner name: nfs-client resourceVersion: "128018" uid: fd859079-dcb4-4b15-b1f2-747189033af2 parameters: archiveOnDelete: "true" provisioner: cluster.local/nfs-subdir-external-provisioner reclaimPolicy: Delete volumeBindingMode: Immediate kind: List metadata: resourceVersion: ""
1-5 åçãããã¸ã§ãã³ã°ã®åä½ãã¹ã
NFSãããã¸ã§ãã¼ã®è¨å®ãã§ããã®ã§å®éã«ãµã³ãã«ã®Podãå®è¡ãã¦åçãããã¸ã§ãã³ã°ã®åä½ãã¹ããè¡ãã¾ãã
ï¼1ï¼ãµã³ãã«ãã¡ã¤ã«ã®ãã¦ã³ãã¼ã
NFSãããã¸ã§ãã¼ã®ãªãã¸ããªã§å ¬éããã¦ãããµã³ãã«ã®ãã¡ã¤ã«ããã¦ã³ãã¼ããã¾ãã PVCã¨Podãããããå®è¡ããYAMLãã¡ã¤ã«ããã¦ã³ãã¼ããã¾ãã
$ wget https://raw.githubusercontent.com/kubernetes-sigs/nfs-subdir-external-provisioner/master/deploy/test-claim.yaml $ wget https://raw.githubusercontent.com/kubernetes-sigs/nfs-subdir-external-provisioner/master/deploy/test-pod.yaml $ ls -d test-claim.yaml test-pod.yaml test-claim.yaml test-pod.yaml
ï¼2ï¼PVCã®ä½æ
oc create
ã³ãã³ãã§YAMLãã¡ã¤ã«ãããªã½ã¼ã¹ãä½æãã¾ãã-f
ãªãã·ã§ã³ã§èªã¿è¾¼ãYAMLãã¡ã¤ã«ãæå®ãã¾ãã
ä»åã¯åã®ä½æ¥ããã®æµãã®ã¾ã¾ããã¸ã§ã¯ãã¯å¤æ´ããã«è¡ãã¾ãã
$ oc create -f test-claim.yaml persistentvolumeclaim/test-claim created
Webã³ã³ã½ã¼ã«ã®ç®¡çè åã表示ã®ã¡ãã¥ã¼ãããã¹ãã¬ã¼ã¸ï¼PersistentVolumeClaimsããé¸æããã¨ãä½æãããPVCã¨ãã¤ã³ããããPVãä¸è¦§ã§è¡¨ç¤ºããã¾ãã
ãã®ãµã³ãã«ã§ã¯ä¸è¨ã®æ å ±ã確èªã§ãã¾ãã
- PVCï¼test-claim
- PVï¼pvc-51702f11-4b99-451f-b2a1-109ab9e35557
- PVã®å®¹éï¼1 MiB
- 使ç¨ããã¹ãã¬ã¼ã¸ã¯ã©ã¹ï¼nfs-client
è¸ã¿å°ãµã¼ãã¼ä¸ã®NFSã¨ã¯ã¹ãã¼ããã£ã¬ã¯ããªã確èªããã¨ãPVç¨ã®ãã£ã¬ã¯ããªãèªåã§ä½æããã¦ãããã¨ãåããã¾ãã
$ tree /mnt/nfs/ /mnt/nfs/ âââ nfs-subdir-external-provisioner-test-claim-pvc-51702f11-4b99-451f-b2a1-109ab9e35557 1 directory, 0 files
NFSãµã¼ãã¼ä¸ã«ä½æããããã£ã¬ã¯ããªã®å½åè¦åã¯PVCã®ããã¸ã§ã¯ãåï¼Namespaceåï¼
-PVCå
-PVå
ã«ãªãã¾ãã
ï¼3ï¼Podã®ä½æ
ä½æãããPVã使ç¨ãããµã³ãã«ã®Podãèµ·åãã¾ããPVCã®ä½æã¨åæ§ã«oc create
ã³ãã³ãã使ç¨ãã¾ãã
$ oc create -f test-pod.yaml pod/test-pod created
Webã³ã³ã½ã¼ã«ã®ç®¡çè
åã表示ã®ã¡ãã¥ã¼ãããWorkloadsï¼Podsããé¸æããã¨ãå®è¡ä¸ã®Podãä¸è¦§ã§è¡¨ç¤ºããã¾ãã
ãµã³ãã«ã®Podï¼test-pod
ï¼ã®ã¹ãã¼ã¿ã¹ãCompleted
ã«ãªã£ã¦ããããã®Podã®å®è¡ãæ£å¸¸ã«å®äºãããã¨ãåããã¾ãã
Podåã®test-pod
ã®ãªã³ã¯ãé¸æããã¨Podã®è©³ç´°ç»é¢ã表示ããã¾ãã
test-pod
ã³ã³ãããbusybox:stable
ã³ã³ããã¤ã¡ã¼ã¸ããä½æããã¦ãããç¶æ
ãTerminated
ã«ãªã£ã¦ããããã§ã«å®è¡ãçµäºãã¦ãããã¨ã確èªã§ãã¾ãã
çµäºã³ã¼ãã0
ã«ãªã£ã¦ããããã®ã³ã³ããã®å®è¡ãæ£å¸¸ã«çµäºãããã¨ã示ããã¦ãã¾ãã
ã¾ãããã®ã³ã³ããã§ã¯PVã¯nfs-pvc
ã¨ããååã§ããªã¥ã¼ã ã¨ãã¦æ±ããã¦ãããã³ã³ããå
ã®/mnt
ãã£ã¬ã¯ããªã«ãã¦ã³ãããã¦ãã¾ãã
ãã®ãµã³ãã«ã§ã¯ã³ã³ããã®å®è¡ã³ãã³ãã¨ãã¦touch /mnt/SUCCESS
ãå®è¡ããã¦æåããã°exit 0
ã§çµäºããããã«ããã°ã©ã ããã¦ãã¾ã*3ã
ãã®ããããµã³ãã«ã®Podèµ·åå¾ã«NFSãµã¼ãã¼ä¸ã®ãã£ã¬ã¯ããªã確èªããã¨ãã³ã³ããã®ä¸ã§ä½æãããSUCCESS
ãã¡ã¤ã«ãçæããã¦ãããã¨ã確èªã§ãã¾ãã
$ tree /mnt/nfs/ /mnt/nfs/ âââ nfs-subdir-external-provisioner-test-claim-pvc-51702f11-4b99-451f-b2a1-109ab9e35557 âââ SUCCESS 1 directory, 1 file
ï¼4ï¼ãµã³ãã«ã®Podã¨PVã®åé¤
ä½æãããµã³ãã«ã®Podã¨PVãåé¤ããå ´åã¯ä¸è¨ã®ã³ãã³ããå®è¡ãã¾ãã
oc delete
ã³ãã³ãã§OpenShiftä¸ã®ãªã½ã¼ã¹ãåé¤ãã¾ãã
-f
ãªãã·ã§ã³ã§YAMLãã¡ã¤ã«ãæå®ã対象ã®ãªã½ã¼ã¹ã®ã¿ãåé¤ã§ãã¾ãã-f
ãªãã·ã§ã³ã¯è¤æ°æå®å¯è½ã§ãä»åã¯Podã¨PVãåæã«åé¤ãã¾ãã
$ oc delete -f test-claim.yaml -f test-pod.yaml
PVåé¤å¾ã®NFSãµã¼ãã¼ä¸ã®å®ä½ãã£ã¬ã¯ããªã¯ä¸è¨ã®ããã«ãªãã¾ãã
$ tree /mnt/nfs/ /mnt/nfs/ âââ archived-nfs-subdir-external-provisioner-test-claim-pvc-51702f11-4b99-451f-b2a1-109ab9e35557 âââ SUCCESS 1 directory, 1 file
NFSãããã¸ã§ãã¼ã®ããã©ã«ãåä½ã§ã¯ãPVåé¤æã®NFSãµã¼ãã¼ä¸ã®å®ä½ãã£ã¬ã¯ããªã¯archived-
ã追å ãããååã«ãªãã¼ã ããã¦ä¿æããã¾ãã
ããã¯ã¹ãã¬ã¼ã¸ã¯ã©ã¹ã®è¨å®ãåºåãããã¨ã§ç¢ºèªã§ãã¾ãã
OpenShiftä¸ã®ãªã½ã¼ã¹ããç¹å®ã®ã»ã¯ã·ã§ã³ã®ãã©ã¡ã¼ã¿ã¼ãåå¾ããå ´åã¯ãoc get
ã³ãã³ãã®åºåã-o json
ãªãã·ã§ã³ã«ããJSONå½¢å¼ã§åºåãããã¤ãã§ç¹ãã§jq
ã³ãã³ãã§ãã¼ã¹ãã¾ãã
ä¸è¨ã®ã³ãã³ãã§ã¹ãã¬ã¼ã¸ã¯ã©ã¹ã®parameters
ã»ã¯ã·ã§ã³ã®å¤ã®ã¿ãåãåºããã¨ãã§ãã¾ãã
$ oc get storageclasses -o json | jq '.items[].parameters' { "archiveOnDelete": "true" }
parameters
ã»ã¯ã·ã§ã³ã«archiveOnDelete:true
ã§è¨å®ããã¦ãããããPVãåé¤ããå ´åã§ãå®ä½ãã£ã¬ã¯ããªãã¢ã¼ã«ã¤ãããã¦ä¿æããã¾ãã
ãã®è¨å®ãarchiveOnDelete:false
ã«å¤æ´ãããã¨ã§ãPVã®åé¤ã¨åæã«å®ä½ãã£ã¬ã¯ããªãåé¤ã§ãã¾ãã
ãªããNFSãããã¸ã§ãã¼ã®ã¤ã³ã¹ãã¼ã«å¾ã«ã¹ãã¬ã¼ã¸ã¯ã©ã¹ã®ãã©ã¡ã¼ã¿ã¼ã¯å¤æ´ã§ãã¾ããã
次ã®é
ç®ãåç
§ãã¦NFSãããã¸ã§ãã¼ãåé¤ããå度ã¤ã³ã¹ãã¼ã«ããæã«--set storageClass.archiveOnDelete=false
ãªãã·ã§ã³ã追å ãã¦ã³ãã³ããå®è¡ãã¦ãã ããã
ï¼5ï¼NFSãããã¸ã§ãã¼ã®åé¤
NFSãããã¸ã§ãã¼ã®åé¤ãè¡ãå ´åã¯helm delete
ã³ãã³ããå®è¡ãã¾ãã
helm delete
ã³ãã³ãã«å¼æ°ã¨ãã¦nfs-subdir-external-provisioner
ãæå®ãã¦å®è¡ãã¾ãã
$ helm delete nfs-subdir-external-provisioner release "nfs-subdir-external-provisioner" uninstalled
åããã¦OpenShiftã®ããã¸ã§ã¯ããåé¤ããå ´åã¯ä¸è¨ã®ã³ãã³ããå®è¡ãã¾ãã
oc delete project
ã³ãã³ãã«å¼æ°ã§ããã¸ã§ã¯ãåï¼nfs-subdir-external-provisioner
ãæå®ãã¦å®è¡ãã¾ãã
$ oc delete project nfs-subdir-external-provisioner project.project.openshift.io "nfs-subdir-external-provisioner" deleted
ããã¸ã§ã¯ããåé¤ããå ´åãNFSãããã¸ã§ãã¼ãåã¤ã³ã¹ãã¼ã«ããå ´åã¯ãµã¼ãã¹ã¢ã«ã¦ã³ãã®ä½æããè¡ãå¿ è¦ãããã¾ãã
ã¾ã¨ã
æ±ç¨çãªNFSãµã¼ãã¼ãããã¯ã¨ã³ãã¨ãã¦ãPVã®åçãããã¸ã§ãã³ã°ãè¡ãæ¹æ³ã¨ãã¦NFSãããã¸ã§ãã¼ã®æ§ç¯æ¹æ³ããç´¹ä»ãã¾ããã PVã®åçãããã¸ã§ãã³ã°ãè¡ãã ãã§ããã°NFSãããã¸ã§ãã¼ã§ååã§ãããOpenShift Virtualizationã§ä»®æ³ãã·ã³ã®ã¹ãããã·ã§ããæ©è½ã«ã¯å¯¾å¿ãã¦ãã¾ããã ãã®ãããåºæ¬çã«ã¯NFSãããã¸ã§ãã¼ã¨åæ§ã«æ§æãã¦ãHelmã§ã¤ã³ã¹ãã¼ã«ãè¡ããã¨ãã§ãããNFS CSIãã©ã¤ãã¼ãã®å©ç¨ãæ¨å¥¨ãã¾ãã 詳細ã¯ç¬¬3åï¼å ±æã¹ãã¬ã¼ã¸ã®ä½æï¼NFS CSIãã©ã¤ãã¼ã®æ§ç¯ï¼ãåç §ãã ããã