Linux:Vagrant搭建K3s集群

来自WHY42
Riguz留言 | 贡献2021年10月12日 (二) 10:42的版本 (建立內容為「= Prepare vms = <syntaxhighlight lang="bash"> mkdir k3s cd k3s touch Vagratfile </syntaxhighlight> The content of Vagrantfile: <syntaxhighlight lang="bash"> # -*…」的新頁面)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

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

install worker node