利用sealos安装k8s集群

1. 环境准备
准备三台干净(未安装过k8s环境)的虚拟机

# 所有的主机都要配置主机名和域名映射 
# 设置主机名 
hostnamectl set-hostname k8s-master01 

# vim /etc/hosts 
192.168.59.201 k8s-master01 
192.168.59.202 k8s-worker01 
192.168.59.203 k8s-worker02 
192.168.59.204 k8s-worker03

2.安装sealos
官方文档:https://sealos.io/zh-Hans/docs/self-hosting/lifecycle-management/quick-start/deploy-kubernetes
下载地址:https://github.com/labring/sealos/releases

# 安装环境:centos7 
# 下载sealos 
wget https://github.com/labring/sealos/releases/download/v4.3.7/sealos_4.3.7_linux_amd64.rpm 
#安装sealos 
yum install sealos_4.3.7_linux_amd64.rpm 

3. 安装kubernetes集群
官方文档:https://sealos.io/zh-Hans/docs/self-hosting/lifecycle-management/quick-start/deploy-kubernetes
安装方式一

# 安装kubernetes集群 
sealos run labring/kubernetes:v1.27.5 labring/helm:v3.12.3 labring/calico:3.26.1 \ 
--masters 192.168.59.201 \ 
--nodes 192.168.59.202,192.168.59.203,192.168.59.204 -p [your-ssh-passwd] 

# 国内仓库 
sealos run registry.cn-shanghai.aliyuncs.com/labring/kubernetes:v1.27.5 registry.cn-shanghai.aliyuncs.com/labring/helm:v3.12.3 registry.cn-shanghai.aliyuncs.com/labring/calico:3.26.1 \ 
--masters 192.168.59.201 \ 
--nodes 192.168.59.202,192.168.59.203,192.168.59.204 -p [your-ssh-passwd]

image.png
注意:labring/helm 应当在 labring/calico 之前。
参数说明:

参数名 参数值示例 参数说明
–masters 192.168.0.2 kubernetes master 节点地址列表
–nodes 192.168.0.3 kubernetes node 节点地址列表
–ssh-passwd [your-ssh-passwd] ssh 登录密码
kubernetes labring/kubernetes:v1.25.0 kubernetes 镜像

在干净的服务器上直接执行上面命令,不要做任何多余操作即可启动一个高可用的 kubernetes 集群。
安装成功后输出如下内容:
image.png
验证k8s是否安装成功
image.png
image.png

安装方式二

# 生成配置文件 
sealos gen labring/kubernetes:v1.27.5 labring/helm:v3.12.3 labring/calico:3.26.1 \ labring/cert-manager:v1.12.3 labring/openebs:v3.7.0 \ 
--masters 192.168.65.130 \ 
--nodes 192.168.65.140,192.168.65.141,192.168.65.142 -p root > Clusterfile 

# 执行配置文件 
sealos apply -f Clusterfile

安装其他组件

sealos run labring/openebs:v3.7.0 
sealos run labring/cert-manager:v1.12.3 
sealos run labring/minio-operator:v4.5.5 labring/ingress-nginx:v1.8.1 \ 
labring/mysql-operator:8.0.27-18.1 labring/redis-operator:v1.2.4 

增加节点
增加 node 节点:
$ sealos add --nodes 192.168.59.205,192.168.59.206

增加 master 节点:
$ sealos add --masters 192.168.59.207,192.168.59.208

image.png

删除节点
删除 node 节点:
$ sealos delete --nodes 192.168.59.205,192.168.59.206

删除 master 节点:
$ sealos delete --masters 192.168.59.207,192.168.59.208
image.png

清理集群
$ sealos reset

上一篇:DataEase大屏iframe嵌入自建网站(React)


下一篇:2024 年(第 12 届)“泰迪杯”数据挖掘挑战赛——A 题:生产线的故障自动识别与人员配置具体思路以及源代码分析