使用kubesphere搭建k8s集群

问题背景

在搭建k8s集群的时候踩了好多坑,真的蓝瘦,大多原因都是各种不兼容导致的,比如

Please wait for the installation to complete: >>>
03:26:40 UTC failed: [master]
error: Pipeline[CreateClusterPipeline] execute failed: Module[CheckResultModule] exec failed:
failed: [master] execute task timeout, Timeout=7200000000000
connect is refused

最后发现不兼容主要是centos安装的版本所包含的依赖和kubesphere不兼容,因此想要安装成功,虚拟机也需要重新选择合适的版本,可以根据的我的版本进行安装,已经通过三次了

kubesphere搭建k8s集群

1 下载centos7.9的镜像:阿里镜像库

2 在VMware虚拟机上安装三台这个下载的centos镜像,更改静态IP

cd /etc/sysconfig/network-scripts
vim ifcfg-ens33
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.207.138
GATEWAY=192.168.207.2
NETMASK=255.255.255.0
DNS1=114.114.114.114


重启网络设置

systemctl restart network

3 每台虚拟机更新yum的软件包,时间设置等

yum -y update
yum makecache fast
yum install -y ntpdate
ntpdate time.windows.com
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
date

4 关闭防火墙

systemctl stop firewalld
systemctl disable firewalld

5 添加三台服务器的域名设置

vim /etc/hosts
192.168.207.138 k8s-node1
192.168.207.139 k8s-node2
192.168.207.140 k8s-node3

6 设置三台服务器的免密,敲(三个回车),就会生成两个文件id_rsa(私钥)、id_rsa.pub(公钥)

ssh-keygen -t rsa
ssh-copy-id k8s-node1
ssh-copy-id k8s-node2

如果取消免密,直接删除ssh文件夹的所有文件

cd ~/.ssh

7 安装kubesphere必要依赖

yum install -y socat conntrack ebtables ipset

8 在一个文件夹中下载k8s安装脚本

export KKZONE=cn
curl -sfL https://get-kk.kubesphere.io | VERSION=v2.2.1 sh -
chmod +x kk

9 集群配置,创建配置文件,config-sample.yaml

./kk create config

10 编辑config-sample.yaml

vim config-sample.yaml

11 启动脚本和配置文件

./kk create cluster --with-kubernetes v1.23.7 --with-kubesphere v3.3.0 -f config-sample.yaml -y

12 耐心等待安装完成,会把所有工作节点添加到k8s-node1

13 查看日志

kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-installer -o jsonpath='{.items[0].metadata.name}') -f

14 查看节点状态

kubectl get nodes

15 登录kubesphere:http://192.168.207.138:30880

16 更改密码





作为程序员第 217 篇文章,每次写一句歌词记录一下,看看人生有几首歌的时间,wahahaha …

Lyric: 脑海里 你的笑容太彻底

猜你喜欢

转载自blog.csdn.net/cucgyfjklx/article/details/125963381