安装 k3s + KubeSphere

确保你是一台干净的 CentOS7 服务器。
按照惯例先更新,更新前顺便把源换为国内的yum源。

# 改国内yum源

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

# 更新

yum update -y

修改主机名

hostnamectl set-hostname k3s-master

 使用 docker 安装

# 安装 docker-ce

yum remove -y docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine

yum install -y yum-utils yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

yum install -y docker-ce docker-ce-cli containerd.io

或者:

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

# 解决内核检查问题 重启生效

grubby --args="user_namespace.enable=1" --update-kernel="$(grubby --default-kernel)" systemctl enable docker

systemctl start docker

# 修改 docker 源

cat << EOF > /etc/docker/daemon.json
{
    "registry-mirrors":["https://3laho3y3.mirror.aliyuncs.com"]
}
EOF

systemctl daemon-reload

systemctl restart docker

# 安装 docker 结束
# 关 firewalld 防火墙
systemctl stop firewalld
systemctl disable firewalld
# 安装 k3s
curl -sfL http://rancher-mirror.cnrancher.com/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn sh -s - --docker

安装指定版本的k3s参考:

curl -sfL http://rancher-mirror.cnrancher.com/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn INSTALL_K3S_VERSION=v1.19.13+k3s1 sh -s - --docker

安装完检查

# 运行配置检查
k3s check-config

如果出现:(RHEL7/CentOS7: User namespaces disabled; add 'user_namespace.enable=1' to boot command line)

方案一:跳过,不关注。

方案二:

grubby --args="user_namespace.enable=1" --update-kernel="$(grubby --default-kernel)"

reboot


# 查看节点状态以及 k3s 版本
[root@k3s-master ~]# kubectl get node
NAME             STATUS   ROLES                  AGE   VERSION
vm-16-8-centos   Ready    control-plane,master   52m   v1.21.5+k3s2
# 查看所有 pod 信息
[root@k3s-master ~]# kubectl get pods -A
NAMESPACE     NAME                                      READY   STATUS      RESTARTS   AGE
kube-system   local-path-provisioner-5ff76fc89d-bbps4   1/1     Running     0          52m
kube-system   coredns-7448499f4d-42v9x                  1/1     Running     0          52m
kube-system   metrics-server-86cbb8457f-xqlrg           1/1     Running     0          52m
kube-system   helm-install-traefik-crd-9wk9v            0/1     Completed   0          52m
kube-system   helm-install-traefik-d8llf                0/1     Completed   3          52m
kube-system   svclb-traefik-jqxvf                       2/2     Running     0          49m
kube-system   traefik-97b44b794-wv6zv                   1/1     Running     0          49m 

在work服务器节点执行如下命令(向k3s集群添加工作节点):

curl -sfL http://rancher-mirror.cnrancher.com/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn INSTALL_K3S_EXEC="--docker" INSTALL_K3S_VERSION=v1.19.13+k3s1 K3S_URL=https://172.31.32.102:6443 K3S_TOKEN=K1071c46540e5f1f404eb096ad12e60570a958069ef5be959c7d3a05a9be3797b44::server:cffda9a3201f5e8ce305895317e7e9d9 sh -

mynodetoken 为K3S_TOKEN使用的值存储在你的服务器节点上的/var/lib/rancher/k3s/server/node-token

k3s集群中快速部署KubeSphere(此过程可能会因为网络原因过慢,失败后可以多试几次)

k3s kubectl apply -f https://github.com/kubesphere/ks-installer/releases/download/v3.2.1/kubesphere-installer.yaml
k3s kubectl apply -f https://github.com/kubesphere/ks-installer/releases/download/v3.2.1/cluster-configuration.yaml

安装过程可通过以下脚本查看

k3s kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f


出现如下日志,则说明安装成功

Collecting installation results ...
#####################################################
###              Welcome to KubeSphere!           ###
#####################################################

Console: http://192.168.200.241: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             2022-01-16 13:03:38
#####################################################

通过如上日志输出的地址及账号信息访问  KubeSphere UI 即可。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值