wsl

Windows Subsystem for Linux

Install docker in wsl ubuntu 20.04.6 LTS

   1 sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release
   2 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
   3 echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
   4 sudo apt update
   5 sudo apt install docker-ce docker-ce-cli containerd.io
   6 sudo usermod -aG docker $USER
   7 sudo service docker start
   8 docker run hello-world
   9 sudo apt install net-tools
  10 docker pull vbodocker/cherrypy-test
  11 docker run --rm --name ctest -P -d vbodocker/cherrypy-test   
  12 docker stop ctest
  13 docker system prune -a
  14 docker run --detach --name some-mariadb --env MARIADB_USER=example-user --env MARIADB_PASSWORD=my_cool_secret --env MARIADB_ROOT_PASSWORD=my-secret-pw  mariadb:latest
  15 docker exec -it some-mariadb bash

Install k3s

   1 curl -sfL https://get.k3s.io | sh -
   2 sudo k3s server > /tmp/k3s.log  2>&1 &
   3 sudo chmod 644 /etc/rancher/k3s/k3s.yaml
   4 kubectl get node

Run cherrypy-test in k3s

   1 cd ~
   2 git clone https://github.com/vborrego/cherrypy-test.git
   3 cd cherrypy-test/
   4 cat README.md
   5 kubectl apply -f cherrypy-test-deployment.yaml
   6 curl $(kubectl get services | grep cherry | awk '//{print $3}'):8080
   7 kubectl get services
   8 kubectl get deployment
   9 cat cherrypy-test-deployment.yaml
  10 kubectl delete -f cherrypy-test-deployment.yaml

Certificate issue

Unable to connect to the server: x509: certificate has expired or is not yet valid: current time 2023-12-12T22:48:20Z is after 2023-05-17T21:01:11Z

   1 sudo rm /var/lib/rancher/k3s/server/tls/dynamic-cert.json
   2 sudo kubectl --insecure-skip-tls-verify=true delete secret -n kube-system k3s-serving
   3 kill <k3s pid>
   4 sudo k3s server > /tmp/k3s.log  2>&1 &  
   5 sudo chmod 644 /etc/rancher/k3s/k3s.yaml
   6 kubectl get pods

Install debian in WSL

   1 wsl --install -d Debian
   2 #Installing, this may take a few minutes...
   3 #Please create a default UNIX user account. The username does not need to match your Windows username.
   4 #For more information visit: https://aka.ms/wslusers
   5 #Enter new UNIX username: wsl
   6 #New password:
   7 #Retype new password:
   8 #passwd: password updated successfully
   9 #Installation successful!
  10 wsl -d debian 

   1 sudo apt update && sudo apt full-upgrade
   2 sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release
   3 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
   4 echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
   5 sudo apt update
   6 sudo apt install docker-ce docker-ce-cli containerd.io
   7 sudo usermod -aG docker $USER
   8 sudo update-alternatives --config iptables
   9 # * 1            /usr/sbin/iptables-legacy   10        manual mode
  10 exit
  11 sudo service docker start
  12 docker run hello-world
  13 sudo apt install net-tools
  14 docker pull vbodocker/cherrypy-test
  15 docker run --rm --name ctest -P -d vbodocker/cherrypy-test
  16 docker ps -a
  17 docker stop ctest
  18 docker system prune -a
  19 docker run --detach --name some-mariadb --env MARIADB_USER=example-user --env MARIADB_PASSWORD=my_cool_secret --env MARIADB_ROOT_PASSWORD=my-secret-pw  mariadb:latest
  20 docker exec -it some-mariadb bash
  21 # Install k3s
  22 curl -sfL https://get.k3s.io | sh -
  23 sudo k3s server > /tmp/k3s.log  2>&1 &
  24 sudo chmod 644 /etc/rancher/k3s/k3s.yaml
  25 kubectl get node
  26 cd ~
  27 git clone https://github.com/vborrego/cherrypy-test.git
  28 cd cherrypy-test/
  29 kubectl apply -f cherrypy-test-deployment.yaml
  30 curl $(kubectl get services | grep cherry | awk '//{print $3}'):8080
  31 kubectl get services
  32 kubectl get deployment
  33 kubectl get services
  34 kubectl get deployment
  35 curl $(kubectl get services | grep cherry | awk '//{print $3}'):8080

wsl (last edited 2024-01-25 11:19:11 by vitor)