NFS Subdir External ProvisionerからNFS CSI Driverに移行する
目標
NFS CSI Driverを使えるようにする
コンテキスト
去年立てたK8sはとりあえず建てた感じだから、普通にPV/PVCをするときにNFS直参照していた。
サークルのK8sなので、他の人も使うことになる。
そうすると、使用者全員にNFS鯖の権限を割り当てるとかいうクソだるいことが起こる。
自動Provisioningのために使っていたNFS Subdir External Provisionerはレガシー寄りらしいので、CSI Driverに移行していこうという話。
今の状況を確認してみる。
kubectl get pv,pvc -A -o wide | grep nfs
...なんか想像以上にあって既に腰が引けるのだが...
とりあえずインストールするかー...
このmicrok8sの公式を使ってもいいものの...更新が1年前だからな...
素直にhelmでインストールする。
helm repo add csi-driver-nfs https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/master/charts
helm install csi-driver-nfs csi-driver-nfs/csi-driver-nfs --namespace kube-system
storageClassを作るためのvalues.yamlがある模様。
早速使ってみる。
storageClass:
create: false
name: nfs-csi
annotations:
storageclass.kubernetes.io/is-default-class: "true"
parameters:
server: nfs.local
share: /nfs2 # ← ここを /nfs2 に変更
subDir: "" # ← 特定のサブディレクトリを使いたい場合はここに指定
mountPermissions: "0"
# CSIシークレットは削除不要、DeleteVolume用
csi.storage.k8s.io/provisioner-secret-name: "mount-options"
csi.storage.k8s.io/provisioner-secret-namespace: "default"
reclaimPolicy: Retain
volumeBindingMode: Immediate
mountOptions:
- nfsvers=4.1
なんか動かないなぁ...ということに...
特に、SecurityContextのfsGroupが動かない...
どうやらマウントに失敗しているのかな?../kubelet/pods/<podid>/mountがないらしい。
当方、microk8sを使っているのだが、公式ガイドによるとkubeletのディレクトリとnfsのオプションに変更がいる模様。
+ kubeletDir: /var/snap/microk8s/common/var/lib/kubelet
storageClass:
create: true
name: nfs-csi
annotations:
storageclass.kubernetes.io/is-default-class: "true"
parameters:
server: nfs.unipro.infra
share: /nfs2
subDir: ""
mountPermissions: "0"
# csi.storage.k8s.io/provisioner-secret is only needed for providing mountOptions in DeleteVolume
# csi.storage.k8s.io/provisioner-secret-name: "mount-options"
# csi.storage.k8s.io/provisioner-secret-namespace: "default"
reclaimPolicy: Retain
volumeBindingMode: Immediate
mountOptions:
- hard
+ - nfsvers=4.1
⚠️ Important Notice: Upcoming changes to the Bitnami Catalog
Beginning August 28th, 2025, Bitnami will evolve its public catalog to offer a curated set of hardened, security-focused images under the new Bitnami Secure Images initiative. As part of this transition:Bitnami will begin deprecating support for non-hardened, Debian-based software images in its free tier and will gradually remove tags from the public catalog. As a result, community users will have access to a reduced number of hardened images. These images are published only under the “latest” tag and are intended for development purposes
All existing container images have been migrated from the public catalog (docker.io/bitnami) to the “Bitnami Legacy” repository (docker.io/bitnamilegacy), where they will no longer receive updates.
For production workloads and long-term support, users are encouraged to adopt Bitnami Secure Images, which include hardened containers, smaller attack surfaces, CVE transparency (via VEX/KEV), SBOMs, and enterprise support.
These changes aim to improve the security posture of all Bitnami users by promoting best practices for software supply chain integrity and up-to-date deployments. For more details, visit the Bitnami Secure Images announcement.
やってんなこれ...
詰みじゃね
bitnamilegacyというユーザー名でまだ一応あるらしい...
やるしかないだろ
とりあえず、これにてNFS自体の移行は完了。
続きはこっちで