简介

这里已经创建好ack集群,创建集群步骤跳过下面直接开始安装

查看Storage Class

您可以在阿里云容器服务 Kubernetes 集群中使用阿里云云盘存储卷。目前,阿里云 CSI 插件支持通过 PV/PVC 方式挂载云盘,包括静态存储卷和动态存储卷。

默认阿里云 ACK 已经为用户创建了不同规格的 StorageClass,可直接使用,但存在最小容量规格限制,详情参考云盘存储卷使用说明

1
2
3
4
5
6
7
# kubectl get sc 
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
alicloud-disk-available diskplugin.csi.alibabacloud.com Delete Immediate true 8m39s
alicloud-disk-efficiency diskplugin.csi.alibabacloud.com Delete Immediate true 8m39s
alicloud-disk-essd diskplugin.csi.alibabacloud.com Delete Immediate true 8m39s
alicloud-disk-ssd diskplugin.csi.alibabacloud.com Delete Immediate true 8m39s
alicloud-disk-topology diskplugin.csi.alibabacloud.com Delete WaitForFirstConsumer true 8m39s

容器服务Kubernetes版(ACK)集群默认提供了以下几种StorageClass:

  • alicloud-disk-efficiency:高效云盘。
  • alicloud-disk-ssd:SSD云盘。
  • alicloud-disk-essd:ESSD云盘。
  • alicloud-disk-available:提供高可用选项,优先创建SSD云盘;如果SSD云盘售尽,则创建高效云盘。
  • alicloud-disk-topology: 使用延迟绑定的方式创建云盘。

指定默认StorageClass

本次使用alicloud-disk-efficiency,注意申请高效云盘时申请的PV大小不得小于20G。

1
2
# kubectl patch sc alicloud-disk-efficiency -p '{"metadata": {"annotations": {"storageclass.beta.kubernetes.io/is-default-class": "true"}}}'
storageclass.storage.k8s.io/alicloud-disk-efficiency patched

确认配置更改成功

1
2
3
4
5
6
7
[root@iZbp12zirv9d1jdumu566mZ ~]# kubectl get sc 
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
alicloud-disk-available diskplugin.csi.alibabacloud.com Delete Immediate true 9m48s
alicloud-disk-efficiency (default) diskplugin.csi.alibabacloud.com Delete Immediate true 9m48s
alicloud-disk-essd diskplugin.csi.alibabacloud.com Delete Immediate true 9m48s
alicloud-disk-ssd diskplugin.csi.alibabacloud.com Delete Immediate true 9m48s
alicloud-disk-topology diskplugin.csi.alibabacloud.com Delete WaitForFirstConsumer true 9m48s

下载Kubesphere部署资源清单到本地

1
2
wget https://github.com/kubesphere/ks-installer/releases/download/v3.1.0/kubesphere-installer.yaml
wget https://github.com/kubesphere/ks-installer/releases/download/v3.1.0/cluster-configuration.yaml

由于阿里云 ACK 高效磁盘最小申请大小为20G,所以挂载的PV申请的容量大小不能小于该值,参考以下配置修改cluster-configuration.yaml。

1
2
3
4
5
6
7
# cat cluster-configuration.yaml | grep VolumeSize
minioVolumeSize: 20Gi # Minio PVC size.
openldapVolumeSize: 2Gi # openldap PVC size.
elasticsearchMasterVolumeSize: 4Gi # Volume size of Elasticsearch master nodes.
elasticsearchDataVolumeSize: 20Gi # Volume size of Elasticsearch data nodes.
jenkinsVolumeSize: 8Gi # Jenkins volume size.
prometheusVolumeSize: 20Gi # Prometheus PVC size

编辑 cluster-configuration.yaml 文件,调整 openldapVolumeSize、elasticsearchMasterVolumeSize、jenkinsVolumeSize 3 个卷大小为 20G。

执行下面命令部署Kubesphere

1
2
kubectl apply -f kubesphere-installer.yaml
kubectl apply -f cluster-configuration.yaml

查看部署的过程日志

1
# kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f

安装完成后会看到如下信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#####################################################
### Welcome to KubeSphere! ###
#####################################################
Account: admin
Password: P@88w0rd
NOTES:
1. After logging into the console, please check the
monitoring status of service components in
the "Cluster Management". If any service is not
ready, please wait patiently until all components
are ready.
2. Please modify the default password after login.
#####################################################
https://kubesphere.io 2020-xx-xx xx:xx:xx

访问节点IP:30880即可访问到Kubesphere控制台,默认账号密码为admin P@88w0rd

遇到的问题一

Kubesphere-controlmanager一直打印以下日志,大致原因就是找不到阿里云的diskcsi,由于阿里云默认已经安装了csi插件,只是Kubesphere去找的插件路径不正确,我们修改下kubesphere-controlmanager的插件挂载路径即可解决

1
W0629 09:57:10.067823 1 clientconn.go:1208] grpc: addrConn.createTransport failed to connect to {/var/lib/kubelet/plugins/diskplugin.csi.alibabacloud.com/csi.sock <nil> 0 <nil>}. Err :connection error: desc = "transport: Error while dialing dial unix /var/lib/kubelet/plugins/diskplugin.csi.alibabacloud.com/csi.sock: connect: no such file or directory". Reconnecting...W0629 09:57:10.362171 1 clientconn.go:1208] grpc: addrConn.createTransport failed to connect to {/var/lib/kubelet/plugins/diskplugin.csi.alibabacloud.com/csi.sock <nil> 0 <nil>}. Err :connection error: desc = "transport: Error while dialing dial unix /var/lib/kubelet/plugins/diskplugin.csi.alibabacloud.com/csi.sock: connect: no such file or directory". Reconnecting...

登录Kubesphere应用负载工作负载选择Kubesphere-system名称空间点击ks-controller-manager更多操作编辑配置模板存储卷

修改kubelet-plugin的hostpath路径为/var/lib/kubelet/csi-plugins/

随后等待pod重新启动成功后再查看Kubesphere-controlmanager就没有错误日志了