Git Product home page Git Product logo

res-edge-wsl's Introduction

Deploying Res-Edge on WSL

  • Read more about Res-Edge
  • You need access to pizza-labs in order to complete this lab

Install WSL (version 2)

  • From an elevated Command Prompt
    • You may have to run --update multiple times

      wsl --update
      • The most recent version of Windows Subsystem for Linux is already installed.
    • Set WSL to always use verion 2

      wsl --set-default-version 2

Install AKS Edge Essentials (optional)

# check install
Set-ExecutionPolicy RemoteSigned -Scope Process -Force
Import-Module AksEdge
Get-Command -Module AKSEdge | Format-Table Name, Version

# check device settings
Install-AksEdgeHostFeatures

# create single machine config
New-AksEdgeConfig -DeploymentType SingleMachineCluster -outFile .\single-config.json | Out-Null

# create AKS EE from config
New-AksEdgeDeployment -JsonConfigFilePath .\single-config.json

# check K8s
kubectl get pods -A

# check network
Get-VMNetworkAdapter -All
Get-VMSwitch
Get-NetIPInterface

# route WSL network to AKS EE network
# you may need to update the interface names
Get-NetIPInterface | where {$_.InterfaceAlias -eq 'vEthernet (WSL)' -or $_.InterfaceAlias -eq 'vEthernet (aksedgesw-int)'} | Set-NetIPInterface -Forwarding Enabled -Verbose

Start Ubuntu in WSL

  • Enter your user name and password

    • Using the same user name as Windows will make things easier
    set USERNAME
    
    wsl --install ubuntu
    

Update IP Tables

  • Once WSL starts, you will be in a bash prompt inside your Ubuntu VM
  • You will have to enter you're password the first time you run sudo
echo "choose Legacy IP Tables"
echo ""

sudo update-alternatives --config iptables

Set root password

  • Set the root password to something you can remember - in case you need it
echo ""
echo "set the root password"
sudo passwd

Set environment variables

  • Your PAT should have access to the GitOps repo Res-Edge uses

Do NOT check your PAT into GitHub!!!

export PAT=MyGitHubPat

Set git config

  • Change the values
git config --global user.name bartr
git config --global user.email [email protected]

Set git-credentials

git config --global credential.helper store
echo "https://$(git config user.name):$PAT@github.com" > $HOME/.git-credentials

Clone pizza-labs

# clone pizza-labs
### some of the WSL changes are only in the bartr branch
cd $HOME

git clone https://github.com/cse-labs/pizza-labs
cd pizza-labs
git checkout bartr
git pull
cp -r .kic ..
cp -r .ds ..
git clone https://github.com/cse-labs/pizza-labs .gitops
cd .gitops
git checkout labs --
git pull
cd $HOME

Clone this repo

cd $HOME

git clone https://github.com/bartr/res-edge-wsl wsl
cd wsl

Install components

# install tools
sudo ./install.sh

# Configure User
./config.sh

AKS EE Client Setup

  • If you are using this image as a bash shell to manage AKS EE, you have to complete these steps

Update vSwitch

  • This step allows the vSwitches to communicate
  • If you used a differnt vSwitch, change before running
  • From an elevated PowerShell (on the Windows host) prompt

Get-NetIPInterface | where {$_.InterfaceAlias -eq 'vEthernet (WSL)' -or $_.InterfaceAlias -eq 'vEthernet (aksedgesw-int)'} | Set-NetIPInterface -Forwarding Enabled -Verbose

Copy Kubectl Config

  • From your WSL SSH session
  • You may have to update the path
cd $HOME
mkdir -p .kube
# we set KUBECONFIG to $HOME/.kube and /mnt/c/Users/$USER/.kube
# you may have to update paths in $HOME/.zshenv
# cp /mnt/c/Users/$USER/.kube/config .kube

Finish Setup

  • exit the WSL shell

  • Restart the WSL shell

    wsl -- code ~
  • Use "ctl `" to open a terminal

mkdir -p "$HOME/.oh-my-zsh/completions"
kic completion zsh > "$HOME/.oh-my-zsh/completions/_kic"
ds completion zsh > "$HOME/.oh-my-zsh/completions/_ds"
kubectl completion zsh > "$HOME/.oh-my-zsh/completions/_kubectl"
k3d completion zsh > "$HOME/.oh-my-zsh/completions/_k3d"
kustomize completion zsh > "$HOME/.oh-my-zsh/completions/_kustomize"
gh completion zsh > "$HOME/.oh-my-zsh/completions/_gh"
flux completion zsh > "$HOME/.oh-my-zsh/completions/_flux"
helm completion zsh > "$HOME/.oh-my-zsh/completions/_helm"
compinit

Check AKS EE Cluster

  • This will only work if you setup the AKS EE cluster
kic pods

Create a Cluster

  • This will create the k3d cluster
  • It will also install Flux and configure as lab-01
cd $HOME/pizza-labs

kic cluster create

Test the Cluster

http localhost

http localhost/heartbeat/16

Save the Image (optional)

  • Use WSL to save the image for reuse
  • Exit WSL into the Command Prompt
  • Change to the directory you want to store the file (3 - 8 GB)
# delete the cluster (optional)
wsl -- kic cluster delete

# stop the instance
wsl -t ubuntu

# export the image
wsl --export ubuntu kic.tar

# unregister ubuntu
wsl --unregister ubuntu

# import the image as "kic" - store in ./kic
wsl --import kic kic kic.tar

# start the image
# run kic cluster create if you deleted the cluster
# copy the AKS EE .kube/config file if running as client
wsl -- code ~

Stop the WSL Instance

wsl -t ubuntu

Destroy the WSL Instance

wsl --unregister ubuntu

Support

This project uses GitHub Issues to track bugs and feature requests. Please search the existing issues before filing new issues to avoid duplicates. For new issues, file your bug or feature request as a new issue.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

res-edge-wsl's People

Contributors

bartr avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.