官方文档:多节点安装 (kubesphere.io)
前提条件
我这里准备了三个 CentOS 节点,IP 分别为:
- master:192.168.10.10
- node1:192.168.10.11
- node2:192.168.10.12
建议使用干净的操作系统(即不安装任何其他软件)。否则,可能会产生冲突。这里我连 Docker 都没有装,KubeKey 会自动帮我们装!
依赖项要求
KubeKey 可以一同安装 Kubernetes 和 KubeSphere。根据要安装的 Kubernetes 版本,需要安装的依赖项可能会不同。您可以参考下表,查看是否需要提前在节点上安装相关依赖项。
依赖项 | Kubernetes 版本 ≥ 1.18 | Kubernetes 版本 < 1.18 |
| 必须 | 可选,但建议安装 |
| 必须 | 可选,但建议安装 |
| 可选,但建议安装 | 可选,但建议安装 |
| 可选,但建议安装 | 可选,但建议安装 |
这里需要在这三台机器上分别执行:
yum install -y socat conntrack ebtables ipset
下载 KubeKey
执行一下命令:
export KKZONE=cn
curl -sfL https://get-kk.kubesphere.io | VERSION=v3.0.13 sh -
这里要多试几次,不断的尝试,因为网络的问题…
下载好之后就会在当前的目录下多出两个文件:kubekey-v3.0.13-linux-amd64.tar.gz
、kk
。
这个 kk 就是我们要执行的工具,先给它赋予执行权限:
chmod +x kk
创建集群
创建一个配置文件:
./kk create config
之后当前目录下会多出一个文件:config-sample.yaml
修改这个文件,主要是修改他的节点信息,将准备的其他两个节点也都配置好。
之后执行一下命令开始创建:
./kk create -y cluster -f config-sample.yaml
整个安装过程可能需要 10 到 20 分钟,具体取决于您的计算机和网络环境。
如果失败了,还是多试几次~
通过观察日志可以看到,KubeKey 正在为我们自动的下载和安装:kubeadm、kubelet、kubectl、helm、kubecni、crictl、etcd、docker、calicoctl、kubesphere…
整个过程真的很慢,而且网络总是出问题,我这里都试了最少 10 次…
我这边在下载 kubesphere 的 Dcoker 镜像的时候不断的再重试,网络又在抽风,都开始下载镜像了,说明我们这三个节点的 Docker 肯定是安装好了,所以我们把安装程序停掉,配置一下 Docker 的国内镜像。
在这三台机器上分别执行一下命令,配置一下镜像加速器:
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://c2yf9ia3.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
之后回到主节点上面,再次重试…
验证安装
安装完成后,您会看到如下内容:
#####################################################
### Welcome to KubeSphere! ###
#####################################################
Console: http://192.168.10.10:30880
Account: admin
Password: P@88w0rd
NOTES:
1. After you log 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 up and running.
2. Please change the default password after login.
#####################################################
https://kubesphere.io 20xx-xx-xx xx:xx:xx
#####################################################
现在,您可以通过 <NodeIP:30880
使用默认帐户和密码 (admin/P@88w0rd
) 访问 KubeSphere 的 Web 控制台。