一、环境配置
二、前期环境预置
1.更改hostname
[root@localhost ~]# hostnamectl set-hostname k8s-master
2.添加hosts文件
[root@localhost ~]# cat >> /etc/hosts << EOF
> 192.168.149.174 k8s-master
> EOF
3.关闭防火墙
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
4.关闭Selinux
vi /etc/sysconfig/selinux
SELINUX=disabled
5.替换阿里源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
#备份
#下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache
yum update(可选)
6.安装常用软件
[root@localhost ~]# yum -y install epel-release.noarch conntrack ipvsadm ipset jq sysstat curl iptables libseccomp vim lrzsz bash-completion git
7.关闭swap分区
[root@localhost ~]# swapoff -a
[root@localhost ~]# sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
8.部署docker 19.03
8.1卸载docker
[root@k8s-master ~]# yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
8.2安装依赖包
[root@localhost ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
8.3添加docker源 (三台都要改)
[root@localhost ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
8.4查看docker版本
[root@localhost ~]# yum list docker-ce --showduplicates | sort -r
8.5安装docker指定版本
[root@localhost ~]# yum -y install docker-ce-19.03.9 docker-ce-cli-19.03.9
8.6启动docker,设置开机自起
[root@localhost ~]# systemctl start docker
[root@localhost ~]# systemctl enable docker
8.7配置镜像加速器
[root@localhost ~]# mkdir -p /etc/docker/
[root@localhost ~]# tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://uafxazog.mirror.aliyuncs.com"],
"exec-opts": ["native.cgroupdriver=systemd"]
}
EOF
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl restart docker
三、KubeSphere3.1(nightly版)部署
1.从源代码生成二进制文件
[root@localhost ~]git clone https://github.com/kubesphere/kubekey.git
[root@localhost ~] cd kubekey
[root@localhost ~]./build.sh
注意:
在部署之前,必须先安装Docker。
如果您无法访问https://proxy.golang.org/,请执行build.sh -p。
2.安装KubeSphere3.1
2.1进入kk所在文件夹
[root@localhost ~]cd /root/kubekey/output
2.2执行安装命令
[root@localhost ~]export KKZONE=cn
[root@localhost ~]./kk create cluster --with-kubesphere nightly-20210328
高能预警
1.此处一定一定要注意这是 nightly版本(每日构建版)后缀的日期必须要填写正确即前一天的日期
2.当前,kk仍然不支持将KubeSphere升级到每晚版本
3.验证安装结果
kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f
4.如果最后返回Welcome to KubeSphere,则表示已安装成功。
**************************************************
#####################################################
### Welcome to KubeSphere! ###
#####################################################
Console: 192.168.149.174:30880
Account: admin
Password: P@88w0rd
NOTES:
1. After logging into the console, please check the
monitoring status of service components in
the "Cluster Management". If any service is not
ready, please wait patiently until all components
are ready.
2. Please modify the default password after login.
#####################################################
https://kubesphere.io 2021-03-29 09:50:20
#####################################################
5.查看部署结果
FAQ
1.ks-installer部署时一直提示拉取不到镜像怎么办?
答:请确认每日构建的日期版本是否正确,如果确实提示没有镜像请用edit修改当前pod的image信息,将后缀(:nightly-20210328)去掉,就会拉取到镜像
2.pull镜像时提示下载失败怎么办?
答:请运行export KKZONE=cn
3.如果要添加节点、开启热插组件怎么办?
答:请参考官网教程
开启热插 https://kubesphere.io/zh/docs/quick-start/enable-pluggable-components/
添加新节点 https://kubesphere.io/zh/docs/installing-on-linux/cluster-operation/add-new-nodes/
4.平台信息为什么显示的还是3.0.0
答:非正式版还是显示3.0.0,等正式版发布后会更正