â»ãã®è¨äºã¯ Red Hat Advent Calendar 2023 ã® 16æ¥ç®ã®è¨äºã§ãã
ããã«ã¡ã¯ãã¬ãããããã§ã¯ã©ã¦ãã¤ã³ãã©ãçæ¥ã«ãã¦ããå®é½å®®(ãã¤ã¼)ã§ãã
æ©éã§ããã¹ãã¬ã¼ã¸ã«é¢ããåé¡ã§ãã
åé¡
ã¢ãªã¹ã¯ãªã³ãã¬ãã¹ã§å±éããã OpenShiftï¼ã¾ã㯠Kubernetesï¼ã¯ã©ã¹ã¿ã®ç®¡çè ã§ãã
ã¯ã©ã¹ã¿ã«ã¯1㤠10TiB ãã®ãã«ããã PV ãããã¾ãããã® PV ã®ããã¯ã¨ã³ãã¯ãããã¯ã¹ãã¬ã¼ã¸ã§ãThin-provisioned ãªè«çããªã¥ã¼ã ã使ã£ã¦ãã¾ãã ã¹ãã¬ã¼ã¸ã®ç®¡çè ã§ããããããã¯ãããã¹ãã¬ã¼ã¸ã®å®¹éããªããªãããã ããããã® PV ãã容éãè¿ãã¦ãããã¨è¨ããã¦ãã¾ãã
ã¯ã©ã¹ã¿ç®¡çè ã®ã¢ãªã¹ã¯ããã®ãã«ããã PV ã使ããã£ãã«ã«ãã®è©±ããã¦ãPV å ã«æºãè¾¼ãã ä¸è¦ãªãã¡ã¤ã«ãæ¶ãã¦ããããã¨ã«ãªãã¾ããã
ãã£ãã«ããã¯ããä»°ãã®éããã¡ã¤ã«ãæ¶ããã3åã®1 ãããã«ãªã£ããã¨å ±åãåãã¾ããã
ã¢ãªã¹ã¯ããã§ä¸ä»¶è½çã¨æãé«ããã¦å¯ã¾ããããããç¿æ¥ããããã¯ãããæ¬å½ã«ã¾ããï¼æ©ã容éãè¿ãã¦ããï¼ãã¨è¨ãããå°æãã¦ãã¾ãã
ãã¦ããªãã§ããããããªããããããã£ãã«ãåã¯ã¤ãã¦ããªããã®ã¨ãã¾ãã
解ç
ç°¡åã§ãããæ£è§£ã¯ããã¡ã¤ã«ãæ¶ãã¦ããã¡ã¤ã«ã·ã¹ãã ã¯åæã«ç¸®ã¾ãªããããã¡ã¤ã«ã·ã¹ãã ã縮ã¾ãªããã°ããªã¥ã¼ã ãµã¤ãºãæ¸ããªããã ã§ãã
ããã¯å¥ã« Kubernetes ã¨ãã«éã£ã話ã§ã¯ããã¾ãããä¸è¬ç㪠Linux ãµã¼ãã§ãåãç¾è±¡ã¯èµ·ããã¾ãã
ããããä¸ã®åé¡ã§ä¸çªãã¡ãªã®ã¯ 10TiB ã® PVC ã許ãã¦ããã¨ããã§ãOpenShift ãã¹ãã¬ã¼ã¸å´ã§ Quota ãããã¦å¶éãã¹ãã§ãã
ã§ããããããã¯ã¹ãã¬ã¼ã¸ã ã¨ãã¡ã¤ã«ã·ã¹ãã ã§ãã¡ã¤ã«ãæ¶ãããèªåã§ç©ºãã容éãã¹ãã¬ã¼ã¸ã«å¸°ã£ã¦ãããªãã¦ãã¨ã¯ç¡ãã®ã§ãã¢ãªã¹ããã£ããå¯ã¦ãå ´åã§ã¯ããã¾ããã
Space Reclamation 㨠PV
ä¸åº¦ä½¿ã£ããã©ç©ºãã容éãã¹ãã¬ã¼ã¸å´ã«è¿ããã¨ããSpace Reclamation ã¨è¨ãã¾ãã
ã·ãã¯ãããã¸ã§ãã³ã°ã§ã¯ã¾ãåºã¦ãã¾ããããã·ã³ãããã¸ã§ãã³ã°ã§ã¯ããªãã¿ã®æ¦å¿µã§ãã
ã·ã³ãããã¸ã§ãã³ã°ã¯ãèªåãå¿
è¦ãªå®¹éã ã使ãã¹ãããªããªã·ã¼ã§ãã®ã§ããå¿
è¦ãªããªã£ã¦åãããã容éã¯è¿ãã¹ããã ããã§ãã
é常㮠Linux 㧠Space Reclamation ããã«ã¯ãfstrim
ã³ãã³ããå®è¡ãã¦ãã¡ã¤ã«ã·ã¹ãã ã®ä½¿ã£ã¦ããªãé åãéæ¾ãã¾ãããã®å¾ã¯ã¹ãã¬ã¼ã¸å´ã§ãããååãã¾ãã
ããã§ã¯ Kubernetes PV ã®å ´åã¯ï¼ãããã Pod ã Worker ãã¼ãã«å
¥ã£ã¦ fstrim
ãå®è¡ããï¼ãããªéç¨ããããªãã§ãããã
PV ã®å ´åã¯ãCSI (Container Storage Interface) Add-on ã使ã£ã¦ Reclaim ãããã¨ãã§ãã¾ãã
ReclaimSpaceJob
ã¨ããã«ã¹ã¿ã ãªã½ã¼ã¹ã使ãã¾ããReclaim ã¯ãããªã«å¸¸æãããã®ã§ã¯ãªãã®ã§ãåçºã§ Job çã«ä½¿ãã¾ãã
ODF 㧠PV ã® Space Reclamation ã試ãã¦ã¿ã
Red Hat OpenShift Data Foundationï¼ODFï¼ã¯ããã«å¯¾å¿ãã¦ããã®ã§ãå®éãã£ã¦ã¿ã¾ãããã
ODF ãã¤ã³ã¹ãã¼ã«ãããã¯ã©ã¹ã¿ã§é©å½ãªã¢ããªãä½ã£ã¦ 50GiB PVC ãã¢ã¿ãããã¾ãã
Pod ãã㯠/dev/rbd0
ã¨ãã¦è¦ãã¾ãããã®æç¹ã§ã¯ã»ã¨ãã©ç©ºã£ã½ã
sh-4.4$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT loop1 7:1 0 512G 0 loop rbd0 252:0 0 50G 0 disk /mnt nvme0n1 259:0 0 100G 0 disk |-nvme0n1p1 259:1 0 1M 0 part |-nvme0n1p2 259:2 0 127M 0 part |-nvme0n1p3 259:3 0 384M 0 part `-nvme0n1p4 259:4 0 99.5G 0 part /dev/termination-log sh-4.4$ df -h /mnt Filesystem Size Used Avail Use% Mounted on /dev/rbd0 49G 24K 49G 1% /mnt
ODF ã®ããã·ã¥ãã¼ãã§è¦ã¦ããã»ã¨ãã©ä½¿ããã¦ããªãåæç¶æ ã§ãã
ãã㧠10GiB ã®ããã¼ãã¡ã¤ã«ãæ¸ãè¾¼ã¿ã¾ãã10GiB å¢ãã¦ãã¾ããï¼å½ããåï¼
sh-4.4$ dd if=/dev/random of=/mnt/10G.dat bs=1M count=10240 10240+0 records in 10240+0 records out 10737418240 bytes (11 GB, 10 GiB) copied, 81.0443 s, 132 MB/s sh-4.4$ sh-4.4$ df -h /mnt Filesystem Size Used Avail Use% Mounted on /dev/rbd0 49G 11G 39G 21% /mnt
ODF ã§ã¯ä¸éã§ã¬ããªã±ã¼ã·ã§ã³ãããã®ã§ãããã·ã¥ãã¼ãã§è¦ã㨠3åã® 30GiB ã»ã©ãå¢ãã¦ãããã¨ããããã¾ãã
ããã§ã¯ Pod ã§ãã¡ã¤ã«ãåé¤ãã¾ãã10GiB æ¸ãã¾ãã
sh-4.4$ rm -f /mnt/10G.dat sh-4.4$ sh-4.4$ df -h /mnt Filesystem Size Used Avail Use% Mounted on /dev/rbd0 49G 24K 49G 1% /mnt
ODF ã§ã¯ãå ¨ç¶æ¸ã£ã¦ã¾ããã
ãã¦ãã㧠ReclaimSpaceJob
ãä½ã£ã¦ Reclaim ãã¦ã¿ã¾ãããã
apiVersion: csiaddons.openshift.io/v1alpha1 kind: ReclaimSpaceJob metadata: name: reclaim-odf-pvc namespace: test spec: target: persistentVolumeClaim: odf-pvc
ãããå®è¡ããã¨ã次ã®ããã«ãªãã¾ãã
ODF ã®ä¸ã§åã Ceph ã®ãããã¯ããã¤ã¹ï¼RBDï¼ã¯ãã·ã³ãããã¸ã§ãã³ã°ã§ä½ããã¾ãã
ãã® ReclaimSpaceJob
ã«ãã£ã¦ãã¢ã㪠Pod ã¨åããã¼ãã§åã CSI driver ã fstrim
ãå®è¡ãã¾ããCeph RBD 㯠sparse ãªã¤ã¡ã¼ã¸ãã¡ã¤ã«ãªã®ã§ãã¼ãé åã¯èªåçã« Ceph ã®ãã¼ã«ã«è¿ããã¾ãã
Space Reclamation ã¯ã¹ã±ã¸ã¥ã¼ã«ããã¨ãã£ã¨æ¥½
ad hoc ã« Reclaim ãããªã ReclaimSpaceJob
ãä½ãã¾ãããå®æçã«å®è¡ããããã¹ã±ã¸ã¥ã¼ã«ãã¦ããã¨ããã§ãã
ReclaimSpaceCronJob
ã¨ããã«ã¹ã¿ã ãªã½ã¼ã¹ã§ã¹ã±ã¸ã¥ã¼ã«ãè¨å®ã§ããã®ã§ããã対象㮠PVC ã« annotation ã追å ãããã¨ã§ä»£ç¨ã§ãã¾ãã
# oc annotate pvc odf-pvc "reclaimspace.csiaddons.openshift.io/schedule=@weekly" -n test persistentvolumeclaim/odf-pvc annotated
ä¸ã® @weekly
ã®é¨å㯠Cron ã¨åãæ¸ãæ¹ã§ãOKã§ããæ¯é±éææ¥ã®æ·±å¤0æã«å®è¡ãããªãã0 0 * * 5
ã¿ãããªæãã§ããã
ããã§ã¢ãªã¹ããããæãé«ããã¦ãã£ããç ãããã¨ã§ãããã
ã¾ã¨ã
ã¯ã©ã¦ãç°å¢ã§ Space Reclamation ããªãã¨ããºããã¨ãããã¨ã¯ã»ã¨ãã©ç¡ãã¨æãã¾ãããåé ã®åé¡ã®ããã«ãªã³ãã¬ãã¹ç°å¢ã ã£ããæå¤ã¨ããããããã¾ããã
ã¹ãã¬ã¼ã¸ã¯ãã£ã¦å½ç¶ä½¿ãã¦å½ç¶ãã¨ãæãã®æ¹ãããããããã¾ããããããããçµæ§ä¸ã®äººã¯è²ã
ã¨å·¥å¤«ã¨è¦å´ããã¦ãããã§ããã
ä»å㯠ODF ã§ç¢ºèªãã¾ããããä»ã®ã¹ãã¬ã¼ã¸ã® CSI ã¯ã©ããªã®ã§ãããããã¿ã¾ããç§ããããã¾ãããè²ã
ã¨è©¦ãã¦ã¿ãã¨ããã®ã§ã¯ãªãããªã¨æãã¾ãã
ã¨ããããã§ãä»åã¯ããã¾ã§ã