机器配置情况
host | ipaddress | 备注 | 配置 |
---|---|---|---|
master1 | 172.16.40.60 | 管理节点 | 8C16G |
master2 | 172.16.40.61 | 管理节点 | 8C16G |
master3 | 172.16.40.62 | 管理节点 | 8C16G |
node1 | 172.16.40.63 | 工作节点 | 16C32G |
node2 | 172.16.40.64 | 工作节点 | 16C32G |
node3 | 172.16.40.65 | 工作节点 | 16C32G |
node4 | 172.16.40.66 | 工作节点 | 16C32G |
初始化虚拟机
所有机器都要执行以下命令,没有管理平台克隆虚拟机就得一个一个机器执行没得办法。
设置时间
开启时间同步。yum install -y chrony systemctl enable chronyd systemctl start chronyd timedatectl set-ntp true
- 设置时区。
timedatectl set-timezone Asia/Shanghai
- 检查 ntp-server 是否可用。
chronyc activity -v
设置防火墙
执行以下命令停止并禁用 firewalld 服务:
systemctl status firewalld
systemctl disable firewalld
systemctl stop firewalld
iptables -F
更新系统包和依赖项
执行以下命令更新系统包并安装依赖项:
yum update
yum install conntrack-tools
yum install epel-release
yum install socat
yum install openssl openssl-devel
yum install ipvsadm
yum isntall vim unzip htop
下载 KubeKey
KubeKey 是新一代 Kubernetes 和 KubeSphere 安装器,可帮助您以简单、快速、灵活的方式安装 Kubernetes 和 KubeSphere。
export KKZONE=cn
curl -sfL https://get-kk.kubesphere.io | VERSION=v3.0.10 sh -
tar -zxvf kubekey-v3.0.10-linux-amd64.tar.gz
chmod +x kk
创建多节点集群
./kk create config --with-kubernetes v1.24.14 此处安装的是k8S 如果只需要安装k8s和kubesphere, 可以执行命令 ./kk create config --with-kubernetes v1.24.14 --with-kubesphere v3.4.0
系统将创建默认的 config-sample.yaml
文件。您可以根据您的环境修改此文件。
vim config-sample.yaml
apiVersion: kubekey.kubesphere.io/v1alpha2
kind: Cluster
metadata:
name: sample
spec:
hosts:
- {name: master1, address: 172.16.40.61, internalAddress: 172.16.40.61, user: root, password: "ABCD@1234"}
- {name: master2, address: 172.16.40.66, internalAddress: 172.16.40.66, user: root, password: "ABCD@1234"}
- {name: master3, address: 172.16.40.62, internalAddress: 172.16.40.62, user: root, password: "ABCD@1234"}
- {name: node1, address: 172.16.40.65, internalAddress: 172.16.40.65, user: root, password: "ABCD@1234"}
- {name: node2, address: 172.16.40.64, internalAddress: 172.16.40.64, user: root, password: "ABCD@1234"}
- {name: node3, address: 172.16.40.60, internalAddress: 172.16.40.67, user: root, password: "ABCD@1234"}
- {name: node4, address: 172.16.40.63, internalAddress: 172.16.40.63, user: root, password: "ABCD@1234"}
roleGroups:
etcd:
- master1
- master2
- master3
control-plane:
- master1
- master2
- master3
worker:
- node1
- node2
- node3
- node4
controlPlaneEndpoint:
## Internal loadbalancer for apiservers
internalLoadbalancer: haproxy
这里有个haproxy的注释需要去掉,默认使用它进行负载均衡。
domain: lb.kubesphere.local
address: ""
port: 6443
.......
执行以下命令使用自定义的配置文件创建集群:
./kk create cluster -f config-sample.yaml