kubekey安装kubesphere

本文版本: kubernetes 1.21.5 kubeshpere 3.2.0

主机规划

最低2核4G
建议使用 Linux Kernel 版本: 4.15 or later
我的搭建环境为3台主机
192.168.56.101 node1
192.168.56.101 node2
192.168.56.101 node3

timedatectl set-timezone Asia/Shanghai ##设置时区
hostnamectl set-hostname node1 
........

关闭防火墙或者开放必要的[防火墙端口]

systemctl disable firewalld
systemctl stop firewalld
systemctl status firewalld
image

查看并关闭swap分区

swapoff -a
vi /etc/fstab 
#swap一行注释
free -h 
image.png

关闭selinux

vim /etc/selinux/config
image.png
setenforce 0

重启后会变成
image.png

安装依赖组件

yum install -y ebtables socat ipset conntrack 

配置网桥

cat <<EOF >  /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system

kk也会配置,自己配一下保险

安装docker

yum -y update systemd #如果linux版本老,最好先升级一下
yum install -y yum-utils
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
yum -y install docker-ce docker-ce-cli
systemctl start docker && systemctl enable docker

虽然kk也会安装docker,自己提前装保险一些,先保证docker的运行环境没有问题
可以通过修改daemon配置文件/etc/docker/daemon.json来使用加速器

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://xxxxxxx.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

下载kubekey

注意自己的芯片架构
https://github.com/kubesphere/kubekey
https://github.com/kubesphere/kubekey/releases

https://github.com/kubesphere/kubekey/releases/download/v1.2.1/kubekey-v1.2.1-linux-amd64.tar.gz
https://github.com/kubesphere/kubekey/releases/download/v2.0.0-rc.2/kubekey-v2.0.0-rc.2-linux-amd64.tar.gz

开始安装

使用kubekey安装kubernetes和kubesphere

创建一个配置文件

[root@localhost opt]# ./kk create config --with-kubernetes v1.21.5  --with-kubesphere v3.2.0 -f ./config-kubesphere.yaml
如果没有lb,最好不要填写lb地址

image.png

删除/etc/cni/net.d

[root@localhost opt]# ./kk create cluster -f ./config-kubesphere.yaml

如果下载缓慢,先export KKZONE=cn
改了KKZONE,下载地址有证书过期的组件下不了,可以用wget --no-check-certificate下载后再运行kk,例:

[root@localhost opt]# wget --no-check-certificate -P /opt/kubekey/kube/v1.21.5/amd64/ https://kubernetes-release.pek3b.qingstor.com/release/v1.21.5/bin/linux/amd64/kubeadm

其他检查

如果yum锁住,删掉/var/run/yum.pid就行了

[root@localhost opt]# journalctl -xefu kubelet ##查看kubelet日志
[root@localhost opt]# docker info|grep Driver  ##查看docker驱动
[root@localhost opt]# systemctl show --property=Environment kubelet |cat  ##查看kubelet驱动
##修改docker驱动,与k8s保持一致就行了
[root@localhost opt]# cat << EOF > /etc/docker/daemon.json
{
  "exec-opts": ["native.cgroupdriver=systemd"] ##或者cgroupfs
}
EOF
[root@localhost opt]# systemctl daemon-reload && systemctl restart docker
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
禁止转载,如需转载请通过简信或评论联系作者。

推荐阅读更多精彩内容