Last active
November 17, 2021 19:14
-
-
Save avoidik/97d27132a3ba5bd633797a789f950c73 to your computer and use it in GitHub Desktop.
K3S on Vagrant with MetalLB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
namespace: metallb-system | |
name: config | |
data: | |
config: | | |
address-pools: | |
- name: default | |
protocol: layer2 | |
addresses: | |
- 192.168.0.100-192.168.0.199 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: networking.k8s.io/v1 | |
kind: Ingress | |
metadata: | |
name: nginx | |
annotations: | |
nginx.ingress.kubernetes.io/ssl-redirect: "false" | |
spec: | |
ingressClassName: nginx | |
rules: | |
- host: k8s.at.home | |
http: | |
paths: | |
- path: / | |
pathType: Prefix | |
backend: | |
service: | |
name: nginx | |
port: | |
number: 80 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DEFAULT_BOX = 'ubuntu/focal64' | |
WORKER_NODES = 2 | |
Vagrant.configure(2) do |config| | |
config.vm.define 'master' do |master| | |
master.vm.box = DEFAULT_BOX | |
master.vm.hostname = 'master' | |
master.vm.synced_folder '.', '/vagrant', type: 'virtualbox' | |
master.vm.network 'private_network', ip: '192.168.0.200' | |
master.vm.provider 'virtualbox' do |v| | |
v.memory = 2048 | |
v.cpus = 2 | |
v.name = 'k3s-master01' | |
v.customize ['modifyvm', :id, '--audio', 'none'] | |
end | |
master.vm.provision 'shell', inline: <<-'SHELL' | |
export DEBIAN_FRONTEND="noninteractive" | |
apt-get update | |
apt-get install -y -q etcd-server etcd-client | |
IPADDR=$(ip a show enp0s8 | grep "inet " | awk '{print $2}' | cut -d / -f1) | |
curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION="v1.21.5+k3s2" INSTALL_K3S_EXEC="--node-ip="${IPADDR}" --flannel-iface=enp0s8 --tls-san="${IPADDR}" --tls-san="k8s.at.home" --write-kubeconfig-mode=644 --kube-apiserver-arg="service-node-port-range=30000-30100" --no-deploy=servicelb --no-deploy=traefik" K3S_STORAGE_BACKEND=etcd3 K3S_STORAGE_ENDPOINT="http://127.0.0.1:2379" K3S_TOKEN="43bf98d8fb25e7fd4275ae06f33adacd" sh - | |
cp /etc/rancher/k3s/k3s.yaml /tmp/ | |
sed -i "s/127.0.0.1/${IPADDR}/" /tmp/k3s.yaml | |
cp /tmp/k3s.yaml /vagrant/ | |
SHELL | |
end | |
(1..WORKER_NODES).each do |n| | |
config.vm.define "node#{n}" do |node| | |
node.vm.box = DEFAULT_BOX | |
node.vm.hostname = "node#{n}" | |
node.vm.synced_folder '.', '/vagrant', type: 'virtualbox', disabled: true | |
node.vm.network 'private_network', ip: "192.168.0.2%02d" % n | |
node.vm.provider 'virtualbox' do |v| | |
v.memory = 2048 | |
v.cpus = 2 | |
v.name = "k3s-node#{n}" | |
v.customize ['modifyvm', :id, '--audio', 'none'] | |
end | |
node.vm.provision 'shell', inline: <<-'SHELL' | |
IPADDR=$(ip a show enp0s8 | grep "inet " | awk '{print $2}' | cut -d / -f1) | |
curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION="v1.21.5+k3s2" INSTALL_K3S_EXEC="--node-ip=${IPADDR} --flannel-iface=enp0s8" K3S_URL="https://192.168.0.200:6443" K3S_TOKEN="43bf98d8fb25e7fd4275ae06f33adacd" sh - | |
SHELL | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
continue with linkerd :) https://linkerd.io/2.11/getting-started/