Last active
February 15, 2022 07:18
-
-
Save azyu/68cd76e663d8003cd7cdbb48d4d2f515 to your computer and use it in GitHub Desktop.
Local kubernetes cluster on Windows (k3s)
This file contains 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
@echo off | |
multipass launch -c 1 -m 4G -d 8G -n k3s-master 20.04 --cloud-init cloud-init.yaml | |
multipass exec k3s-master eval "curl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE=644 sh -s -" | |
multipass launch -c 1 -m 2G -d 8G -n k3s-node-01 20.04 --cloud-init cloud-init.yaml | |
multipass launch -c 1 -m 2G -d 8G -n k3s-node-02 20.04 --cloud-init cloud-init.yaml | |
REM IPV4 | |
multipass info k3s-master | for /f ="tokens=2" %a in ('findstr "IPv4"') do @echo %a > k3s_url.txt | |
set /p K3S_URL=<k3s_url.txt | |
set K3S_URL=%K3S_URL: =% | |
REM echo %K3S_URL% | |
del k3s_url.txt | |
REM Token | |
multipass exec k3s-master -- /bin/bash -c "sudo cat /var/lib/rancher/k3s/server/node-token" > k3s_token.txt | |
set /p K3S_TOKEN=<k3s_token.txt | |
REM echo %K3S_TOKEN% | |
del k3s_token.txt | |
REM Command | |
echo multipass exec k3s-node-01 eval "curl -sfL https://get.k3s.io ^| K3S_TOKEN=%K3S_TOKEN% K3S_URL=https://%K3S_URL%:6443 sh -" > run.cmd | |
run.cmd | |
echo multipass exec k3s-node-02 eval "curl -sfL https://get.k3s.io ^| K3S_TOKEN=%K3S_TOKEN% K3S_URL=https://%K3S_URL%:6443 sh -" > run.cmd | |
run.cmd | |
del run.cmd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment