k8s基于KubeSphere 安装(All-in-One )

发布于:2022-11-09 ⋅ 阅读:(1256) ⋅ 点赞:(1)

一.安装前了解

1.KubeSphere3.3.0 要求

如需在 Kubernetes 上安装 KubeSphere 3.3.0,您的 Kubernetes 版本必须为:v1.19.x,v1.20.x,v1.21.x,v1.22.x 或 v1.23.x(实验性支持)

 yum list kubeadm --showduplicates | sort -r

2.容器运行环境

您的集群必须有一个可用的容器运行时。如果您使用 KubeKey 搭建集群,KubeKey 会默认安装最新版本的 Docker。或者,您也可以在创建集群前手动安装 Docker 或其他容器运行时

支持的容器运行时

版本

Docker

19.3.8 +

containerd

最新版

CRI-O(试验版,未经充分测试)

最新版

iSula(试验版,未经充分测试)

最新版

注意:docker环境可以提前一定的版本安装,本文中是自己先安装的

3.依赖项要求

KubeKey 可以将 Kubernetes 和 KubeSphere 一同安装。针对不同的 Kubernetes 版本,需要安装的依赖项可能有所不同。您可以参考以下列表,查看是否需要提前在节点上安装相关的依赖项。

依赖项

Kubernetes 版本 ≥ 1.18

Kubernetes 版本 < 1.18

socat

必须

可选但建议

conntrack

必须

可选但建议

ebtables

可选但建议

可选但建议

ipset

可选但建议

可选但建议

二,linux基础环境准备

# 关闭防火墙

systemctl stop firewalld

systemctl disable firewalld

# 关闭selinux

sed -i 's/enforcing/disabled/' /etc/selinux/config # 永久

setenforce 0 # 临时

# 关闭swap

swapoff -a # 临时

sed -ri 's/.*swap.*/#&/' /etc/fstab # 永久

# 根据规划设置主机名

hostnamectl set-hostname <hostname>

# 在master添加hosts

cat >> /etc/hosts << EOF

x.x.x.x k8s-master

x.x.x.x k8s-node1

x.x.x.x k8s-node2

x.x.x.x k8s-node3

EOF

# 将桥接的IPv4流量传递到iptables的链

cat > /etc/sysctl.d/k8s.conf << EOF

net.bridge.bridge-nf-call-ip6tables = 1

net.bridge.bridge-nf-call-iptables = 1

EOF

sysctl --system # 生效

# 时间同步

yum install ntpdate -y

ntpdate time.windows.com

#集群节点间配置无密登录

三.安装docker环境

yum install -y wget

wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo

yum install -y docker-ce-20.10.7 docker-ce-cli-20.10.7 containerd.io-1.4.6

systemctl enable docker && systemctl start docker

docker --version

#配置镜像加速器

sudo mkdir -p /etc/docker

sudo tee /etc/docker/daemon.json <<-'EOF'

{

"registry-mirrors": ["https://afi5x6i2.mirror.aliyuncs.com"]

}

EOF

sudo systemctl daemon-reload

sudo systemctl restart docker

四.安装KubeSphere 

1.准备KubeKey

export KKZONE=cn

curl -sfL https://get-kk.kubesphere.io | VERSION=v2.2.2 sh -

chmod +x kk

2.使用KubeKey引导安装集群

yum install -y conntrack

./kk create cluster --with-kubernetes v1.22.10 --with-kubesphere v3.3.0

 

一般来说,对于 All-in-One 安装,您无需更改任何配置。

如果您在这一步的命令中不添加标志 --with-kubesphere,则不会部署 KubeSphere,KubeKey 将只安装 Kubernetes。如果您添加标志 --with-kubesphere 时不指定 KubeSphere 版本,则会安装最新版本的 KubeSphere。

验证安装结果

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

 

本文含有隐藏内容,请 开通VIP 后查看