操作系统信息
虚拟机,Centos7.9,4C/8G
Kubernetes版本信息
v1.21.5。单节点、多节点、其他K8s集群都复现。
容器运行时
docker
KubeSphere版本信息
v3.2.1
KubeKey版本信息
v2.1.0-alpha.2
问题是什么
一、问题描述
使用下面命令安装K8s同时安装Kubesphere,则能安装成功(正常访问kuhesphere后台)
./kk create cluster --with-kubernetes v1.21.5 --with-kubesphere v3.2.1
但是
先安装集群
./kk create cluster --with-kubernetes v1.21.5
# 或者
./kk create cluster -f config-sample.yaml
再安装Kubesphere(安装方法参考
https://kubesphere.com.cn/docs/quick-start/minimal-kubesphere-on-k8s/)
wget https://github.com/kubesphere/ks-installer/releases/download/v3.2.1/kubesphere-installer.yaml
wget https://github.com/kubesphere/ks-installer/releases/download/v3.2.1/cluster-configuration.yaml
kubectl apply -f kubesphere-installer.yaml
kubectl apply -f cluster-configuration.yaml
则会出现下面的错误,就直接退出了。
# 报错
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 !"
}
PLAY RECAP *********************************************************************
localhost : ok=4 changed=2 unreachable=0 failed=1 skipped=4 rescued=0 ignored=0
二 解决方案
根据错误提示:Default StorageClass was not found。缺少 StorageClass。从KubeSphere安装成功的集群里,拿到默认的StorageClass配置,保存成yaml文件后,添加到集群里。再次重试安装KubeSphere,即执行下面的命令
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
重新安装KubeSphere
kubectl delete -f cluster-configuration.yaml
kubectl delete -f kubesphere-installer.yaml
kubectl apply -f kubesphere-installer.yaml
kubectl apply -f cluster-configuration.yaml