K3S 集群的安装与配置
介绍
前面忘了,中间忘了
应该就是轻量化简单版的 K8S 吧
文中的 Server 节点类似 K8S 中的 Master 节点
安装
快速一键安装
curl -sfL https://get.k3s.io | sh -
⚠️:k3s-server 需要
6443
端口才能被所有节点访问。
仅能使用 Https 协议
Server 节点
使用这一脚本安装的服务器,会默认同时作为 Server 节点和 Agent 节点
💡:单节点 Server 安装是一个功能齐全的 Kubernetes 集群,它包括了托管工作负载 pod 所需的所有数据存储、control plane、kubelet 和容器运行时组件。除非你希望向集群添加容量或冗余,否则没有必要添加额外的 Server 或 Agent 节点。
curl -sfL https://get.k3s.io | sh -
Agent 节点
K3S_TOKEN
使用的值存储在 Server 节点上的 /var/lib/rancher/k3s/server/node-token
中。
使用以下命令进行查看
cat -n /var/lib/rancher/k3s/server/node-token
具体的 Node 加入指令
curl -sfL https://get.k3s.io | K3S_URL=https://myserver:6443 K3S_TOKEN=mynodetoken sh -
💡:尾随--node-name
安装成功
root@hk-claw:~# kubectl get nodes
NAME STATUS ROLES AGE VERSION
agent-hk-hd-01 Ready <none> 2m15s v1.32.4+k3s1
agent-jp-claw-01 Ready <none> 59s v1.32.4+k3s1
agent-us-digital Ready <none> 26s v1.32.4+k3s1
server-hk-claw-01 Ready control-plane,master 6m9s v1.32.4+k3s1
补充
如果你想使用 K9S 进行管理的话,还需要做一定的调整
安装
以 Debian 12 为例
wget https://github.com/derailed/k9s/releases/latest/download/k9s_linux_amd64.deb && apt install ./k9s_linux_amd64.deb && rm k9s_linux_amd64.deb
调整
# 创建 .kube (如果不存在)
mkdir -p /root/.kube
# 创建软链接
ln -sf /etc/rancher/k3s/k3s.yaml /root/.kube/config