本次要安装的集群环境一共 3 个节点,分别是
master: 192.168.33.100 agent1: 192.168.33.110 agent2: 192.168.33.120
首先在 master 节点上执行以下命令,安装控制节点
curl -sfL https://get.k3s.io | sh -s - --node-ip=192.168.33.100
命令执行成功后,复制下来 K3S_TOKEN 后面备用
cat /var/lib/rancher/k3s/server/node-token

然后在 agent1 上执行以下命令,安装 agent 节点
curl -sfL https://get.k3s.io | K3S_URL=https://192.168.33.100:6443 K3S_TOKEN=K104815ab55b18ea44f2a947c24221d3274dd74126e4b3f7ffb70905ea62d050a15::server:6014b6e37a06c7399ddfef4723302994 sh -s - --node-ip=192.168.33.110
在 agent2 上执行以下命令,同样安装 agent 节点
curl -sfL https://get.k3s.io | K3S_URL=https://192.168.33.100:6443 K3S_TOKEN=K104815ab55b18ea44f2a947c24221d3274dd74126e4b3f7ffb70905ea62d050a15::server:6014b6e37a06c7399ddfef4723302994 sh -s - --node-ip=192.168.33.120
回到 master 节点上看看这些 agent 是否已加入集群

试着创建一个 nginx 的部署环境
kubectl create deployment nginx --image=nginx --replicas=6
