本文作者:丁辉
基于KubeKey部署Kubernetes
节点名称 | IP | Kubernetes角色 |
---|---|---|
k8s-master-1,KubeKey管理 | 192.168.1.10 | control-plane,etcd,worker |
k8s-master-2 | 192.168.1.20 | control-plane,etcd,worker |
k8s-master-3 | 192.168.1.30 | control-plane,etcd,worker |
基础准备
所有节点执行
创建用户
1
useradd -m -s /bin/bash kubekey
配置用户密码
根据自己的密码修改 “123456”
1
echo "kubekey:123456" | chpasswd
配置 kubekey 免密使用 sudo 权限
1
2
3
4cat <<EOF | sudo tee /etc/sudoers.d/kubekey
# User rules for kubekey
kubekey ALL=(ALL) NOPASSWD: ALL
EOF更改主机名
192.168.1.10
1
hostnamectl set-hostname k8s-master-1 && bash
192.168.1.20
1
hostnamectl set-hostname k8s-master-2 && bash
192.168.1.30
1
hostnamectl set-hostname k8s-master-3 && bash
编辑 /etc/hosts 文件
1
vi /etc/hosts
添加如下内容
1
2
3192.168.1.10 k8s-master-1
192.168.1.20 k8s-master-2
192.168.1.30 k8s-master-3安装依赖
Centos
1
yum install conntrack-tools socat -y
Ubuntu
1
apt install conntrack socat -y
KubeKey管理节点执行
切换用户
1
su - kubekey
创建密钥
1
sudo ssh-keygen -t rsa -N "" -f /root/.ssh/id_rsa -q
配置免密登录
1
2
3sudo ssh-copy-id kubekey@192.168.1.10
sudo ssh-copy-id kubekey@192.168.1.20
sudo ssh-copy-id kubekey@192.168.1.30
开始安装 KubeKey
KubeKey管理节点执行
下载最新版 KubeKey
配置国内加速
1
export KKZONE=cn
1
curl -sfL https://get-kk.kubesphere.io | sh -
指定版本
1
curl -sfL https://get-kk.kubesphere.io | VERSION=v3.0.13 sh -
为
kk
添加可执行权限1
2sudo chmod +x kk
sudo mv kk /usr/local/bin/生成配置文件
1
kk create config -f kubesphere.yaml
安装 Kubesphere 指定参数
1
--with-kubesphere v3.4.1
修改如下内容
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49apiVersion: kubekey.kubesphere.io/v1alpha2
kind: Cluster
metadata:
name: sample
spec:
hosts:
- {name: k8s-master-1, address: 192.168.100.10, internalAddress: 192.168.100.10, user: kubekey, password: "123456"}
- {name: k8s-master-2, address: 192.168.100.20, internalAddress: 192.168.100.20, user: kubekey, password: "123456"}
- {name: k8s-master-3, address: 192.168.100.30, internalAddress: 192.168.100.30, user: kubekey, password: "123456"}
roleGroups:
etcd:
- k8s-master-1
- k8s-master-2
- k8s-master-3
control-plane:
- k8s-master-1
- k8s-master-2
- k8s-master-3
worker:
- k8s-master-1
- k8s-master-2
- k8s-master-3
controlPlaneEndpoint:
# 启用内置的 HAProxy 负载均衡器
internalLoadbalancer: haproxy
domain: lb.kubesphere.local
address: ""
port: 6443
kubernetes:
# 指定 Kubernetes 版本, 可使用 kk version --show-supported-k8s 命令查询当前 KubeKey 支持的版本
version: v1.23.10
clusterName: cluster.local
autoRenewCerts: true
# 指定容器运行时
containerManager: docker
etcd:
type: kubekey
network:
plugin: calico
kubePodsCIDR: 10.233.64.0/18
kubeServiceCIDR: 10.233.0.0/18
multusCNI:
enabled: false
registry:
privateRegistry: ""
namespaceOverride: ""
registryMirrors: []
insecureRegistries: []
addons: []
开始安装 Kubernetes
1 | kk create cluster -f kubesphere.yaml -y |
扩容节点
1 | kk add nodes -f kubesphere.yaml -y |
卸载集群
1 | kk delete cluster -f kubesphere.yaml |
I'm so cute. Please give me money.
- 本文链接: https://blog.offends.cn/Kubernetes/部署文档/KubeSphere/基于KubeKey部署高可用Kubernetes集群.html
- 版权声明: 本博客所有文章除特别声明外,均默认采用 CC BY-NC-SA 4.0 许可协议。