Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@juliostanley
Last active July 24, 2022 18:20
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save juliostanley/622486d82cb8ed334d270ead5f684e89 to your computer and use it in GitHub Desktop.
Save juliostanley/622486d82cb8ed334d270ead5f684e89 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"
'@
@norcis
Copy link

norcis commented Jan 15, 2020

Why are you using not latest k3s (FROM rancher/k3s:v1.17.0-k3s.2-alpha1-amd64 in liifi-wsl-k3s.ps1)?

@juliostanley
Copy link
Author

I think latest tag was using to the old v1.0.1, v1.17.0-k3s.2-alpha1-amd64 is the latest, higher than v1.17.0-k3s.1 release. Using specific versions to keep things a little more reproducible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment