Skip to content

Instantly share code, notes, and snippets.

@powareverb
Created April 2, 2020 05:48
Show Gist options
  • Select an option

  • Save powareverb/695d8f661e8a8bd1b1c1b2a51f31d567 to your computer and use it in GitHub Desktop.

Select an option

Save powareverb/695d8f661e8a8bd1b1c1b2a51f31d567 to your computer and use it in GitHub Desktop.
K3S and Rio on WSL2

Install Rio on K3S running in WSL2 on Windows

Info

  • K3S is a certified kubernetes distro for edge and other scenarios
  • Rio simplifies application development on kubernetes
  • WSL2 run linux on windows, nicer and more integrated than a traditional vm on hyper-v

Prerequisites

  • Windows 10 with WSL2 set as default
    wsl --set-default-version 2
  • Docker for Windows installed. Used to create the WSL2 image.

Steps

  • Open powershell
  • Ensure you can run the next script by running:
    Set-ExecutionPolicy RemoteSigned -scope CurrentUser
  • Run:
    iex (new-object net.webclient).downloadstring('https://gist.github.com/juliostanley/622486d82cb8ed334d270ead5f684e89/raw/445d8b336b68c98064d79603034ecd0ede38fbfe/install-k3s-rio-wsl2.ps1')

NOTE: If you are on a machine with 8GB of RAM or less. You should prob use a config similar to this. Set it at ~/.wslconfig, WSL2 will return RAM only on some scenarios so for now its better to restrict it until it can do better.

[wsl2]
memory=2GB
swap=8GB
localhostForwarding=true
#!/usr/bin/env pwsh
Write-Host "Install rio via scoop (also k3d for fun)" -ForegroundColor Yellow
iex (new-object net.webclient).downloadstring("https://get.scoop.sh");
scoop install https://raw.githubusercontent.com/liifi/workstation/master/bucket/rio.json
scoop install https://raw.githubusercontent.com/liifi/workstation/master/bucket/k3d.json
Write-Host "Create docker image and import it into WSL 2" -Foreground Yellow
iex (new-object net.webclient).downloadstring("https://raw.githubusercontent.com/liifi/workstation/master/lib/scripts/liifi-wsl-k3s.ps1")
Write-Host "Run the following line by line" -ForegroundColor Yellow
Write-Host @'
wsl -d liifi-k3s
k3s server --no-deploy traefik > /dev/null 2>&1 &
exit
'@
Write-Host "Copy paste the following. After ~2 minutes, press ctrl+c to stop watching and complete installation of rio" -ForegroundColor Yellow
Write-Host @'
$env:KUBECONFIG='//wsl$/liifi-k3s/etc/rancher/k3s/k3s.yaml'
sc //wsl$/liifi-k3s/etc/rancher/k3s/k3s.yaml ((gc -raw //wsl$/liifi-k3s/etc/rancher/k3s/k3s.yaml) -replace '127.0.0.1','localhost')
kubectl get po --all-namespaces -w
rio install
rio dashboard
Write-Host "You can point VSCode to //wsl$/liifi-k3s/etc/rancher/k3s/k3s.yaml"
Write-Host "Done"
'@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment