背景

原来使用 kubesphere 一键安装脚本部署,测试使用期间 Kubesphere 出问题,虽然没有影响 k8s 集群,但 Kubesphere 系统已不可用;

[问题] 不影响 k8s 集群的状态下,如何重装 kubesphere ?

要解决上述问题,最好能独立部署 k8s, 然后再独立部署 Kubesphere;

解决方案

  1. kubeasz 实现 k8s 部署,通过 ks-installer 项目部署 KubeSphere;
  2. 测试 kubesphere 的部署和重装

版本信息:

kubeasz: 2.0.2
kubesphere: 2.1.0
k8s: v1.15.0

安装步骤

  1. 基础架构
主机角色IP地址
master0110.10.14.108
master0210.10.14.109
master0310.10.14.110
node0110.10.14.102
node0210.10.14.133
node0310.21.18.206
node0410.21.18.206
  1. 免密登录
    master01 中控机对其他主机免密登录,方便 ansible 执行

  2. 准备 kubeasz 环境

# 下载工具脚本easzup,举例使用kubeasz版本2.0.2
export release=2.0.2
curl -C- -fLO --retry 3 https://github.com/easzlab/kubeasz/releases/download/${release}/easzup
chmod +x ./easzup
# 使用工具脚本下载
./easzup -D

修改配置文件:

# 
cp /etc/ansible/example/hosts.multi-node /etc/ansible/hosts
# 修改 hosts 清单如下
CONTAINER_RUNTIME="containerd"

# Network plugins supported: calico, flannel, kube-router, cilium, kube-ovn
CLUSTER_NETWORK="calico"

# K8S Service CIDR, not overlap with node(host) networking
SERVICE_CIDR="10.68.0.0/16"

[all:vars]
# --------- Main Variables ---------------
# Cluster container-runtime supported: docker, containerd
CONTAINER_RUNTIME="containerd"

# Network plugins supported: calico, flannel, kube-router, cilium, kube-ovn
CLUSTER_NETWORK="calico"

# K8S Service CIDR, not overlap with node(host) networking
SERVICE_CIDR="10.68.0.0/16"

# Cluster CIDR (Pod CIDR), not overlap with node(host) networking
CLUSTER_CIDR="10.233.0.0/16"
  1. kubeasz 部署 k8s 集群
ansible-playbook 90.setup.yml

# 此处会遇见问题
# 如果主机使用 Kubesphere 一键安装脚本部署过集群,再使用 kubeasz 部署 k8s 时,docker 安装时会有包依赖冲突;需要自行解决;
  1. helm 之伤
    kubeasz 默认配置中没有部署 helm,可通过执行如下命令安装:
ansible-playbook roles/helm/helm.yml

通过这种方式部署的 helm,再部署 Kubesphere 时会有问题;
异常详情见: https://kubesphere.com.cn/forum/d/711-ks-installer-helm

所以,helm 的部署手动完成,参考:https://devopscube.com/install-configure-helm-kubernetes/

  1. 安装 nfs-client

参考如下链接,我这边部署过程中,使用 helm 部署 nfs-client 时没有测试通过;
可以按照仓库文档,手动部署 class.yaml, rbac.yaml, deployment.yaml 即可
https://github.com/kubernetes-incubator/external-storage/tree/master/nfs-client

  1. 按照 ks_installer 的部署方式安装
    参考如下配置:
    https://github.com/kubesphere/ks-installer/blob/master/README_zh.md
    部署过程在需要注意,由于 kubeasz 部署的 etcd 未配置证书;所以只需要创建空的 secret;
kubectl -n kubesphere-monitoring-system create secret generic kube-etcd-client-certs
  1. 其他配置按照 kubesphere 的官方文档操作即可;

测试 Kubesphere 卸载重装

  1. 卸载 Kubesphere
    kubectl delete -f https://raw.githubusercontent.com/kubesphere/ks-installer/master/kubesphere-minimal.yaml

  2. 卸载后
    卸载后,集群仅将 kubesphere-system 命名空间清空,其他组件继续保留;

  3. 重装后,Kubesphere 中的原配置消失;

改善建议

KubeSphere 作为 k8s 集群的管理软件,就像 linux 系统的桌面系统一样。设计思路可仿抄linux桌面;

  1. KubeSphere 的卸载安装,不影响 k8s 集群
  2. KubeSphere 卸载后,所有配置需要另存,重装后可恢复应用
  3. KubeSphere 的各组件需要继续解耦,可独立装卸最佳;
    11 天 后