一键部署k8s(国内源)
#!/bin/bash
# centos 7 阿里云yum源
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all && yum makecache
# 设置中国时间
rm -rf /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# 使用国内原安装
export KKZONE=cn
# 安装必须依赖
yum install -y socat conntrack
# 下载可选依赖
yum install -y ebtables ipset ipvsadm openssl chrony nfs-utils
# 下载 kubekey
curl -sfL https://get-kk.kubesphere.io | VERSION=v2.3.0 sh -
chmod +x kk
# 安装 Kubernetes 和 KubeSphere,
# 若不指定 with-kubernetes 参数,则默认安装支持的最新版本kubernetes
# 若不指定 with-kubesphere 参数,则不安装 kubesphere
# 若需要安装 local PV provisioner ,则需要指定参数: --with-local-storage
# ./kk create cluster --with-kubernetes v1.22.12 --with-kubesphere v3.3.1 --with-local-storage
# ./kk create cluster --with-kubesphere v3.3.1
# 安装 Kubernetes
#./kk create cluster --yes --with-local-storage
########################################################################################
./kk create cluster --with-kubernetes v1.22.12 --with-kubesphere v3.3.1
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
# 输出信息会显示 Web 控制台的 IP 地址和端口号,默认的 NodePort 是 30880。现在,您可以使用默认的帐户和密码 (admin/P@88w0rd) 通过 <NodeIP>:30880 访问控制台
########################################################################################
# 卸载 kubernetes 集群
# ./kk delete cluster
该脚本主要用于在CentOS7系统上使用阿里云YUM源快速部署Kubernetes和KubeSphere。首先更新YUM源,设置中国时区,安装必需和可选依赖,然后下载并执行kubekey来安装Kubernetesv1.22.12和KubeSpherev3.3.1。最后,提供了一个用于查看KubeSphere安装日志的命令,并说明了如何通过NodeIP:30880访问Web控制台。此外,也提供了卸载Kubernetes集群的命令。
2241

被折叠的 条评论
为什么被折叠?



