#安装服务器基本依赖以及做基本配置
yum install  socat conntrack ebtables ipset -y
yum install vim lsof net-tools zip unzip tree wget curl bash-completion pciutils gcc make lrzsz tcpdump bind-utils -y
sed -ri 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config 
setenforce 0
echo "检查是否关闭selinux:";getenforce && grep 'SELINUX=disabled' /etc/selinux/config
systemctl stop firewalld.service && systemctl disable firewalld.service
echo "检查是否关闭防火墙:";systemctl status firewalld.service | grep -E 'Active|disabled'
sed -ri 's/.*swap.*/#&/' /etc/fstab
swapoff -a
echo "检查swap是否关闭:";grep -i 'swap' /etc/fstab;free -h | grep -i 'swap'
#可提前手动安装docker,不安装的话kubekey默认会自动安装与k8s匹配的最新版本docker
#docker 手动安装参考:https://blog.csdn.net/MssGuo/article/details/122694156

#下载安装kubekey v3.0.7
export KKZONE=cn
curl -sfL https://get-kk.kubesphere.io | VERSION=v3.0.7 sh -
chmod +x kk
#上面下载不了可直接下载包解压亦可
wget https://kubernetes.pek3b.qingstor.com/kubekey/releases/download/v3.0.7/kubekey-v3.0.7-linux-amd64.tar.gz
tar xf kubekey-v3.0.7-linux-amd64.tar.gz && chmod a+x kk

#安装kubernetes和kubesphere
#查看当前kubekey支持安装哪些k8s版本
./kk version --show-supported-k8s
#kk命令创建集群语法格式
./kk create cluster [--with-kubernetes version] [--with-kubesphere version]
#同时创建k8s集群和安装kubesphere,因为没有创建配置文件,默认就是当前节点单节点安装k8s集群
./kk create cluster --with-kubernetes v1.22.17 --with-kubesphere v3.3.0

#等待k8s集群安装完成,查看全部的pod是否启动就绪
kubectl get pod --all-namespaces
#查看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
#配置kubectl命令自动补全功能
yum -y install bash-completion
echo 'source <(kubectl completion bash)' >>~/.bashrc
kubectl completion bash >/etc/bash_completion.d/kubectl
#登录kubesphere,根据安装页面的输出信息登录kubesphere即可
Console: http://192.168.x.x:30880
Account: admin
Password: P@88w0rd

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐