This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.6.4. 更改默认存储类
如果使用 AWS,请使用以下流程更改默认存储类。这个过程假设您定义了两个存储类,gp2 和 standard,您想要将默认存储类从 gp2 改为 standard。
列出存储类:
oc get storageclass
$ oc get storageclass NAME TYPE gp2 (default) kubernetes.io/aws-ebs1 standard kubernetes.io/aws-ebsCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
(默认)表示默认存储类。
将默认存储类的
storageclass.kubernetes.io/is-default-class注解的值更改为false:oc patch storageclass gp2 -p '{"metadata": {"annotations": {"storageclass.kubernetes.io/is-default-class": "false"}}}'$ oc patch storageclass gp2 -p '{"metadata": {"annotations": {"storageclass.kubernetes.io/is-default-class": "false"}}}'Copy to Clipboard Copied! Toggle word wrap Toggle overflow 通过添加或修改注解
storageclass.kubernetes.io/is-default-class=true 来使另一个存储类作为默认设置。oc patch storageclass standard -p '{"metadata": {"annotations": {"storageclass.kubernetes.io/is-default-class": "true"}}}'$ oc patch storageclass standard -p '{"metadata": {"annotations": {"storageclass.kubernetes.io/is-default-class": "true"}}}'Copy to Clipboard Copied! Toggle word wrap Toggle overflow 确认更改:
oc get storageclass
$ oc get storageclass NAME TYPE gp2 kubernetes.io/aws-ebs standard (default) kubernetes.io/aws-ebsCopy to Clipboard Copied! Toggle word wrap Toggle overflow