企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] # 1. 先查看前提条件 **1. 查看想要安装的 KubeSphere 对应的 Kubernetes 版本** (1)访问 KubeSphere 官网:https://kubesphere.io/zh/ 。 ![](https://img.kancloud.cn/ab/3e/ab3ea10f268ebf8890c30aee99895e2b_2317x479.png) 我这里选择安装 KubeSphere v3.3 版本。 <br/> ![](https://img.kancloud.cn/b5/23/b52396296727e73e8032b2aad7b021de_2137x611.png) ![](https://img.kancloud.cn/64/29/64291579c914951534a11369af8bb90f_1665x700.png) 看一下前提条件。 <br/> **2. 确保 Kubernetes 版本可兼容** ```shell # kubectl version Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.14", ..., Platform:"linux/amd64"} Server Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.14", ..., Platform:"linux/amd64"} ``` >[info]请注意`Server Version`这一行。如果`GitVersion`显示 Kubernetes 版本不兼容,则需要先升级到兼容的 Kubernetes。 **3. 检查集群中的可用资源是否满足最低要求** ```shell # free -g total used free shared buff/cache available Mem: 3 0 0 0 2 2 Swap: 0 0 0 ``` <br/> **4. 检查集群中是否有默认 StorageClass** >[info]准备默认 StorageClass 是安装 KubeSphere 的前提条件。 ```shell # kubectl get sc No resources found【说明没有默认的 StorageClass】 ``` 如果没有安装 StorageClass 继续往下看。 <br/> # 2. 去掉 master 节点的 Taint **1. 查看当前集群所有节点** ```shell # kubectl get node -o wide NAME STATUS ROLES AGE VERSION INTERNAL-IP ... k8s-master1 Ready control-plane,master 20h v1.21.14 192.168.1.17 ... k8s-node1 Ready <none> 20h v1.21.14 192.168.1.22 ... k8s-node2 Ready <none> 20h v1.21.14 192.168.1.23 ... ``` <br/> **2. 确认 master 节点是否有 Taint** ```shell # kubectl describe node k8s-master1 | grep Taint Taints: node-role.kubernetes.io/master:NoSchedule【说明存在 Taint】 ``` <br/> **3. 去掉 master 节点的 Taint** ```shell (1)去掉 Taint # kubectl taint nodes k8s-master1 node-role.kubernetes.io/master:NoSchedule- node/k8s-master1 untainted (2)再次查看已经没有 Taint 了 # kubectl describe node k8s-master1 | grep Taint ``` <br/> # 3. 安装 OpenEBS **1. 创建 OpenEBS 的 namespace,OpenEBS 相关资源将创建在这个 namespace 下** ```shell (1)创建命名空间 openebs # kubectl create ns openebs (2)查看创建的 openebs # kubectl get ns NAME STATUS AGE ... openebs Active 62s【已创建 openebs】 ``` <br/> **2. 安装 OpenEBS** 参考文档:https://github.com/openebs/charts **** ```shell (1)安装 OpenEBS # kubectl apply -f https://openebs.github.io/charts/openebs-operator.yaml (2)查看安装的 OpenEBS,等待它们的状态全部变为 Running。可能需要 10min 以上。 # kubectl get pods --all-namespaces NAMESPACE NAME READY STATUS RESTARTS AGE ... openebs openebs-localpv-provisioner-64478448d5-89zxv 0/1 ContainerCreating 0 5m8s openebs openebs-ndm-7759v 1/1 Running 0 5m8s openebs openebs-ndm-cluster-exporter-5bbbcd59d4-rvkr2 0/1 ContainerCreating 0 5m8s openebs openebs-ndm-node-exporter-5d74d 0/1 ContainerCreating 0 5m8s openebs openebs-ndm-node-exporter-6n9r6 0/1 ContainerCreating 0 5m8s openebs openebs-ndm-node-exporter-9qsg2 0/1 ContainerCreating 0 5m8s openebs openebs-ndm-operator-5b4b976495-9kfxm 0/1 ContainerCreating 0 5m8s openebs openebs-ndm-r8tf7 1/1 Running 0 5m8s openebs openebs-ndm-xmcjq 1/1 Running 0 5m8s (3)当所有的 OpenEBS 的状态全部为 Running,查看创建的 StorageClass # kubectl get sc NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE openebs-device openebs.io/local Delete WaitForFirstConsumer false 15m openebs-hostpath openebs.io/local Delete WaitForFirstConsumer false 15m ``` <br/> **3. 将`openebs-hostpath`设置为默认的 StorageClass** ```shell (1)将 openebs-hostpath 设置为默认的 StorageClass # kubectl patch storageclass openebs-hostpath -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}' storageclass.storage.k8s.io/openebs-hostpath patched (2)可以看到 openebs-hostpath 已被设置为默认 # kubectl get sc NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE openebs-device openebs.io/local Delete WaitForFirstConsumer false 20m openebs-hostpath (default) openebs.io/local Delete WaitForFirstConsumer false 20m ``` <br/> **4. 恢复 master 节点的 Taint** >[info]如果上面你去掉了 master 节点的 Tanit,则请在这里恢复。避免业务相关的工作负载调度到 master 节点,抢占 master 节点资源。 ```shell (1)恢复 master 节点的 Taint # kubectl taint nodes k8s-master1 node-role.kubernetes.io=master:NoSchedule node/k8s-master1 tainted (2)查看是否已恢复 # kubectl describe node k8s-master1 | grep Taint Taints: node-role.kubernetes.io=master:NoSchedule【说明已恢复】 ``` <br/> **5. 至此,已有了默认的 StorageClass** <br/> **** 参考文档:https://v2-1.docs.kubesphere.io/docs/zh-CN/appendix/install-openebs/