快速部署单机k3s+Kuboard控制面板
1. 修改主机名 ,确保主机名都为小写。(踩过坑,K3s 默认会将宿主机 hostname 转换为全小写作为节点名称,如果主机名中有大写字母,后面部署Kuboard时会失败)
需要修改两个配置文件,确保重启后主机名保持不变。
步骤 1:修改
/etc/hostname(系统启动时读取的主机名)sudo vim /etc/hostname
将文件中的内容替换为你的新主机名(例如
iz7xvfl3f5nrbh32wyp7ywz),保存退出。步骤 2:修改 /etc/hosts(本地 DNS 解析,确保主机名与 IP 绑定)
sudo vim /etc/hosts
找到包含旧主机名的行(通常是
127.0.1.1 旧主机名),将旧主机名替换为新主机名,例如:127.0.0.1 localhost 127.0.1.1 iz7xvfl3f5nrbh32wyp7ywz # 替换为新主机名# 其他内容保持不变
步骤 3:重启系统或生效配置
sudo reboot
验证主机名是否修改成功
执行以下命令查看当前主机名:
hostname # 显示临时/当前主机名
cat /etc/hostname # 显示永久配置的主机名
两者输出一致,说明修改成功。
2. 配置K3S容器加速源
mkdir -p /etc/rancher/k3s/ cat >> /etc/rancher/k3s/registries.yaml << EOF mirrors:docker.io:endpoint:- "https://docker.m.daocloud.io"gcr.io:endpoint:- "https://gcr.m.daocloud.io"quay.io:endpoint:- "https://quay.m.daocloud.io"registry.k8s.io:endpoint:- "https://k8s.m.daocloud.io" EOF
3.执行k3s安装命令 (k3s资料 https://docs.k3s.io/zh/quick-start)
curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn sh -
root@iz7xvfl3f5nrbh32wyp7ywz:~# curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn sh - [INFO] Finding release for channel stable [INFO] Using v1.33.5+k3s1 as release [INFO] Downloading hash rancher-mirror.rancher.cn/k3s/v1.33.5-k3s1/sha256sum-amd64.txt [INFO] Downloading binary rancher-mirror.rancher.cn/k3s/v1.33.5-k3s1/k3s [INFO] Verifying binary download [INFO] Installing k3s to /usr/local/bin/k3s [INFO] Skipping installation of SELinux RPM [INFO] Creating /usr/local/bin/kubectl symlink to k3s [INFO] Creating /usr/local/bin/crictl symlink to k3s [INFO] Creating /usr/local/bin/ctr symlink to k3s [INFO] Creating killall script /usr/local/bin/k3s-killall.sh [INFO] Creating uninstall script /usr/local/bin/k3s-uninstall.sh [INFO] env: Creating environment file /etc/systemd/system/k3s.service.env [INFO] systemd: Creating service file /etc/systemd/system/k3s.service [INFO] systemd: Enabling k3s unit Created symlink /etc/systemd/system/multi-user.target.wants/k3s.service → /etc/systemd/system/k3s.service. [INFO] systemd: Starting k3s
4.执行Kuboard安装命令 (Kuboard安装 https://kuboard.cn/install/v3/install-in-k8s.html#%E5%AE%89%E8%A3%85)
kubectl apply -f https://addons.kuboard.cn/kuboard/kuboard-v3-swr.yaml
执行指令 watch kubectl get pods -n kuboard,等待 kuboard 名称空间中所有的 Pod 就绪,如下所示,

访问 Kuboard
在浏览器中打开链接 http://your-node-ip-address:30080
输入初始用户名和密码,并登录
用户名: admin
密码: Kuboard123
