业务需要将默认的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: