Linux:Vagrant搭建K3s集群:修订间差异

来自WHY42
Riguz留言 | 贡献
Riguz留言 | 贡献
 
(未显示同一用户的2个中间版本)
第55行: 第55行:


copy this token and it will be used in next steps.
copy this token and it will be used in next steps.
to view logs:
<syntaxhighlight lang="bash">
sudo journalctl -u k3s
</syntaxhighlight>


== install worker node ==
== install worker node ==
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
curl -sfL https://get.k3s.io | K3S_URL="https://192.168.100.100:6443" K3S_TOKEN="K1077f721bc580ceb19514bfcf32670ec8822b57be14a970d4df0cd7e54b468d170::server:917aefad605bdfcf9451e74bf67b0257" sh -
vagrant ssh node01
curl -sfL https://get.k3s.io | K3S_URL="https://192.168.100.100:6443" K3S_TOKEN="$TOKEN" sh -
 
# same for node02
</syntaxhighlight>
</syntaxhighlight>
[[Category:Linux/Unix]]

2021年10月13日 (三) 03:08的最新版本

Prepare vms

mkdir k3s
cd k3s
touch Vagratfile

The content of Vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :

NETWORK_BASE="192.168.100.10"

Vagrant.configure("2") do |config|
    config.vm.box = "ubuntu/focal64"
    config.vm.box_check_update = false

    config.vm.provider "virtualbox" do |vb|
        vb.memory = 2048
        vb.cpus = 2
    end

    (1..2).each do |i|
        config.vm.define "node0#{i}" do |node|
            node.vm.network "private_network", ip: "#{NETWORK_BASE}#{i}"
            node.vm.hostname = "node0#{i}.k3s.com"
        end
    end

    config.vm.define "master", primary: true do |master|
        master.vm.provider "virtualbox" do |vb|
            vb.memory = 1024
            vb.cpus = 1
        end
        master.vm.network "private_network", ip: "#{NETWORK_BASE}0"
        master.vm.hostname = "master.k3s.com"
    end
end

Start vms by using vagrant:

vagrant up

install k3s

install master node

vagrant ssh master
curl -sfL https://get.k3s.io | sh -
sudo cat /var/lib/rancher/k3s/server/node-token

copy this token and it will be used in next steps.

to view logs:

sudo journalctl -u k3s

install worker node

vagrant ssh node01
curl -sfL https://get.k3s.io | K3S_URL="https://192.168.100.100:6443" K3S_TOKEN="$TOKEN" sh -

# same for node02