一、关闭防火墙
systemctl disable firewalld
systemctl stop firewalld
systemctl status firewalld
第二步:关闭swap分区
swapoff -a
echo "vm.swappiness=0" >> /etc/sysctl.conf
sysctl -p /etc/sysctl.conf
第三步:配置epel源
rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
第四步:更新yum
yum -y update
第五步:安装依赖组件
yum install -y ebtables socat ipset conntrack
第六步:在安装前请先检查hostname,如果不符合规则会报以下错误
error: Pipeline[CreateClusterPipeline] execute failed: Module[InitKubernetesModule] exec failed:
failed: [VM-20-8-centos] [AddWorkerLabel] exec failed after 5 retires: add worker label failed: Failed to exec command: sudo -E /bin/bash -c "/usr/local/bin/kubectl label --overwrite node VM-20-8-centos node-role.kubernetes.io/worker="
Error from server (NotFound): nodes "VM-20-8-centos" not found: Process exited with status 1
这时候就需要修改hostname,因为我们是单机安装就设置为master吧,执行以下命令
hostnamectl --static set-hostname master
设置完成后使用hostnamectl status命令进行核验
第7步:下载 KubeKey
先执行以下命令以确保您从正确的区域下载 KubeKey。
export KKZONE=cn
执行以下命令下载 KubeKey。
curl -sfL https://get-kk.kubesphere.io | VERSION=v2.2.2 sh -
为 kk 添加可执行权限:
chmod +x kk
第8步:开始安装
在本快速入门教程中,您只需执行一个命令即可进行安装,其模板如下所示:
./kk create cluster [--with-kubernetes version] [--with-kubesphere version]
若要同时安装 Kubernetes 和 KubeSphere,可参考以下示例命令:
./kk create cluster --with-kubernetes v1.22.10 --with-kubesphere v3.3.0
第9步:验证安装结果
输入以下命令以检查安装结果。
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
成功输出
#####################################################
### Welcome to KubeSphere! ###
#####################################################
Console: http://192.168.0.2:30880
Account: admin
Password: P@88w0rd
NOTES:
1. After you log into the console, please check the
monitoring status of service components in
"Cluster Management". If any service is not
ready, please wait patiently until all components
are up and running.
2. Please change the default password after login.
#####################################################
https://kubesphere.io 20xx-xx-xx xx:xx:xx
#####################################################