业务需要将默认的K8S存储服务修改NFS
,这里记录一下操作记录。
列出当前StorageClass
:
kubectl get sc
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
local-path (default) rancher.io/local-path Delete WaitForFirstConsumer false 17d
nfs cluster.local/nfs-nfs-subdir-external-provisioner Delete Immediate true 6d14h
首先,将默认的名称为local-path
修改为false
:
kubectl patch storageclass local-path -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}'
然后,将nfs
设置为默认:
kubectl patch storageclass nfs -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
操作完成之后,校验一下,可以看到已经成功将nfs
设置为默认的StorageClass
选项。
kubectl get sc
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
local-path rancher.io/local-path Delete WaitForFirstConsumer false 17d
nfs (default) cluster.local/nfs-nfs-subdir-external-provisioner Delete Immediate true 6d14h
Ref:https://kubernetes.io/docs/tasks/administer-cluster/change-default-storage-class/