部署kubesphere时需要默认 StorageClass

23 篇文章 0 订阅
16 篇文章 0 订阅

1、场景

在部署kubesphere3.3版本时其中有一个项失败;需要默认的sc

TASK [preinstall : KubeSphere | Stopping if default StorageClass was not found] ***
fatal: [localhost]: FAILED! => {
"assertion": ""(default)" in default_storage_class_check.stdout",
"changed": false,
"evaluated_to": false,
"msg": "Default StorageClass was not found !"
}

排查发现自己的sc已经创建但是不是默认的,默认的一般后面都带有 (default) 标识

NAME                  PROVISIONER                                   RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUMEEXPANSION   AGE
local (default)       openebs.io/local                              Delete          WaitForFirstConsumer   false                  15h
managed-nfs-storage   k8s-sigs.io/nfs-subdir-external-provisioner   Delete          Immediate              false                  22d

这里我的刚开始没有带默认标识,后面修改后的

默认 StorageClass 的注解 storageclass.kubernetes.io/is-default-class 设置为 true
注解的其它任意值或者缺省值将被解释为 false。

要标记一个 StorageClass 为非默认的,你需要改变它的值为 false:

2、修改sc为默认标识

 kubectl patch sc local -p '{"metadata": {"annotations": {"storageclass.beta.kubernetes.io/is-default-class": "true"}}}'

其中local为我的sc名称
或者在创建class时添加注解:

  metadata:
    annotations:
      storageclass.beta.kubernetes.io/is-default-class: "true"

3、创建local 的sc

cat >> default-storage-class.yaml <<-EOF
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: local
  annotations:
    cas.openebs.io/config: |
      - name: StorageType
        value: "hostpath"
      - name: BasePath
        value: "/var/openebs/local/"
    kubectl.kubernetes.io/last-applied-configuration: >
      {"apiVersion":"storage.k8s.io/v1","kind":"StorageClass","metadata":{"annotations":{"cas.openebs.io/config":"-
      name: StorageType\n  value: \"hostpath\"\n- name: BasePath\n  value:
      \"/var/openebs/local/\"\n","openebs.io/cas-type":"local","storageclass.beta.kubernetes.io/is-default-class":"true","storageclass.kubesphere.io/supported-access-modes":"[\"ReadWriteOnce\"]"},"name":"local"},"provisioner":"openebs.io/local","reclaimPolicy":"Delete","volumeBindingMode":"WaitForFirstConsumer"}
    openebs.io/cas-type: local
    storageclass.beta.kubernetes.io/is-default-class: 'true'
    storageclass.kubesphere.io/supported-access-modes: '["ReadWriteOnce"]'
provisioner: openebs.io/local
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
EOF
kubectl apply -f default-storage-class.yaml

参考:
https://blog.csdn.net/qq_31977125/article/details/121243097
https://kubernetes.io/zh-cn/docs/tasks/administer-cluster/change-default-storage-class/

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值