Skip to content

Dev Machine Installation

Shuo Wu edited this page Nov 29, 2022 · 45 revisions

Generate and Config SSH

Generate the SSH Key

ssh-keygen

Remote connection

Save the public key of your local machine into ~/.ssh/authorized_keys

Now you can connect your VM via this command:

ssh <username>@<IP>

Authentication Error

When encountering the below error message:

sudo tail -f /var/log/auth.log|grep 'sshd'

......
userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms [preauth]
......

Add this line in /etc/ssh/sshd_config.

PubkeyAcceptedAlgorithms=+ssh-rsa

And then restart sshd service.

sudo systemctl restart sshd

Config VM Fusion SSH

Window - Virtual Machine Library - right click your machine - connect to SSH - set username and password, then remember the IP address

Add user

adduser <user name>

usermod -aG sudo <user name>
su - <user name>

Set proxy

Set proxy for apt

sudo echo "Acquire {
  HTTP::proxy "http://127.0.0.1:7890";
  HTTPS::proxy "http://127.0.0.1:7890";
}
" > /etc/apt/apt.conf.d/proxy.conf

Set proxy for curl

curl --proxy $HTTP_PROXY

Install common tools

sudo apt-get install software-properties-common -y

Install vim

# sudo add-apt-repository ppa:jonathonf/vim
sudo apt update
sudo apt install vim -y

Set vim clipboard

sudo apt-get install vim-gtk -y
echo "set clipboard=unnamed" > ~/.vimrc

Docker

Install and setup in Ubuntu

  1. Install https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository
  2. Add your user to the "docker" group then reboot
sudo usermod -aG docker <your_vm_username>	
sudo reboot	

Install and setup in OpenSUSE

sudo zypper update
sudo zypper install docker-compose -y
sudo systemctl enable docker
sudo systemctl start docker

Login

docker login --username=<your_docker_username> --password=<your_password>

Take a try with the following cmd:

docker ps

Uninstall and cleanup in Ubuntu

Step 1

dpkg -l | grep -i docker

To identify what installed package you have:

Step 2

sudo apt-get purge -y docker-engine docker docker.io docker-ce  
sudo apt-get autoremove -y --purge docker-engine docker docker.io docker-ce  

The above commands will not remove images, containers, volumes, or user created configuration files on your host. If you wish to delete all images, containers, and volumes run the following commands:

sudo rm -rf /var/lib/docker
sudo rm /etc/apparmor.d/docker
sudo groupdel docker
sudo rm -rf /var/run/docker.sock

Install python3.6

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.6

curl https://bootstrap.pypa.io/get-pip.py | sudo -H python3.6

Install kubectl

sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubectl

zsh

Install

sudo apt install zsh -y
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

zsh plugins

Install following plugins

sudo apt install lua5.3

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-completions ~/.oh-my-zsh/custom/plugins/zsh-completions
git clone https://github.com/johanhaleby/kubetail.git ~/.oh-my-zsh/custom/plugins/kubetail
git clone https://github.com/skywind3000/z.lua.git ~/.oh-my-zsh/custom/plugins/z.lua

Then modify line plugins=(git) in ~/.zshrc to:

plugins=(git bgnotify urltools zsh-autosuggestions zsh-completions zsh-syntax-highlighting z.lua)

Theme (Recommendation)

Use ys

Or

curl -sSL git.io/jovial | sudo bash -s $USER~~

ENV

export GOPATH=$HOME/go
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
export LONGHORNTEST=$GOPATH/src/github.com/longhorn/longhorn-tests/manager/integration/tests:$GOPATH/src/github.com/longhorn/longhorn-engine/integration
export PYTHONPATH=$LONGHORNTEST:$PYTHONPATH

export REPO=shuowu

Import .profile

Add line [[ -e ~/.profile ]] && emulate sh -c 'source ~/.profile' in ~/.zshrc

Alias

Add the following lines at the end of ~/.zshrc:

alias zshconfig="mate ~/.zshrc"
alias ohmyzsh="mate ~/.oh-my-zsh"
alias g="git"
alias k="kubectl"
alias kl="kubectl -n=longhorn-system"
alias kt="kubetail"
alias qi="qemu-img"

Install Go

Install go from Web

https://go.dev/doc/install

Install go via pkg manager tools

sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt-get update
sudo apt-get install golang-go

You should add the gopath bin directory to your path. Add the following to your .profile or .bashrc or other shell file

export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin

Git

Config your git

git config --global -e

Add the following lines into the config files

[credential]
    helper = store
[user]
    name = Shuo Wu
    email = [email protected]
[color]
    diff = auto
    status = auto
    branch = auto
    interactive = auto
[help]
    format = html
[alias]
    br = branch
    ca = commit --amend
    ci = commit
    cp = cherry-pick
    co = checkout
    st = status
    oln = log --pretty=oneline --since='2 days ago' --color --graph --abbrev-commit
    olg = log -p -1 --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%ci) %C(bold blue) <%an>%Creset' --abbrev-commit
    lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%ci) %C(bold blue) <%an>%Creset' --abbrev-commit
    amend = !git log -n 1 --pretty=tformat:%s%n%n%b | git commit -F - --amend
    zip = !git archive --format zip master --output
    zipHead = !git archive --format=zip HEAD --output
    rmd = !git ls-files -d  -z | xargs -0 git rm
    df = diff
    lb = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n''         %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
    ri = rebase -i
    rc = rebase --continue
[log]
    date = local
[core]
    excludesfile = ~/.gitignore_global
    whitespace = cr-at-eol
    quotepath = false
    attributesfile = ~/.gitattributes
[gui]
    encoding = utf-8
[push]
    default = current
[grep]
    lineNumber = true
[diff "exif"]
    textconv = exiftool
[diff "plist"]
    textconv = plutil -convert xml1 -o -
#[http]
#    proxy = socks5://127.0.0.1:1090
#[https]
#    proxy = socks5://127.0.0.1:1090

Set login info

echo "https:{<username>}:{<password>}@github.com" > ~/.git-credentials

Add ssh key in your online GitHub Settings.

Add Repos

mkdir -p ~/go/src/github.com/longhorn
mkdir -p ~/go/src/github.com/rancher

g clone https://github.com/longhorn/longhorn.git ~/go/src/github.com/longhorn/longhorn
cd ~/go/src/github.com/longhorn/longhorn
g remote add shuo-wu [email protected]:shuo-wu/longhorn.git

g clone https://github.com/longhorn/longhorn-manager.git ~/go/src/github.com/longhorn/longhorn-manager
cd ~/go/src/github.com/longhorn/longhorn-manager
g remote add shuo-wu [email protected]:shuo-wu/longhorn-manager.git

g clone https://github.com/longhorn/longhorn-engine.git ~/go/src/github.com/longhorn/longhorn-engine
cd ~/go/src/github.com/longhorn/longhorn-engine
g remote add shuo-wu [email protected]:shuo-wu/longhorn-engine.git

g clone https://github.com/longhorn/longhorn-instance-manager.git ~/go/src/github.com/longhorn/longhorn-instance-manager
cd ~/go/src/github.com/longhorn/longhorn-instance-manager
g remote add shuo-wu [email protected]:shuo-wu/longhorn-instance-manager.git

g clone https://github.com/longhorn/longhorn-tests.git ~/go/src/github.com/longhorn/longhorn-tests
cd ~/go/src/github.com/longhorn/longhorn-tests
g remote add shuo-wu [email protected]:shuo-wu/longhorn-tests.git

g clone https://github.com/longhorn/longhorn-share-manager.git ~/go/src/github.com/longhorn/longhorn-share-manager
cd ~/go/src/github.com/longhorn/longhorn-share-manager
g remote add shuo-wu [email protected]:shuo-wu/longhorn-share-manager.git

g clone https://github.com/longhorn/backing-image-manager.git ~/go/src/github.com/longhorn/backing-image-manager
cd ~/go/src/github.com/longhorn/backing-image-manager
g remote add shuo-wu [email protected]:shuo-wu/backing-image-manager.git

g clone https://github.com/longhorn/backupstore.git ~/go/src/github.com/longhorn/backupstore
cd ~/go/src/github.com/longhorn/backupstore
g remote add shuo-wu [email protected]:shuo-wu/backupstore.git

g clone https://github.com/longhorn/charts.git ~/go/src/github.com/longhorn/charts
cd ~/go/src/github.com/longhorn/charts
g remote add shuo-wu [email protected]:shuo-wu/longhorn-charts.git

g clone https://github.com/longhorn/go-iscsi-helper.git ~/go/src/github.com/longhorn/go-iscsi-helper
cd ~/go/src/github.com/longhorn/go-iscsi-helper
g remote add shuo-wu [email protected]:shuo-wu/go-iscsi-helper.git

g clone https://github.com/longhorn/sparse-tools.git ~/go/src/github.com/longhorn/sparse-tools
cd ~/go/src/github.com/longhorn/sparse-tools
g remote add shuo-wu [email protected]:shuo-wu/sparse-tools.git

g clone https://github.com/rancher/charts.git ~/go/src/github.com/rancher/charts
cd ~/go/src/github.com/rancher/charts
g remote add shuo-wu [email protected]:shuo-wu/charts.git

g clone https://github.com/rancher/tgt.git ~/go/src/github.com/rancher/tgt
cd ~/go/src/github.com/rancher/tgt
g remote add shuo-wu [email protected]:shuo-wu/tgt.git

g clone https://github.com/rancher/liblonghorn.git ~/go/src/github.com/rancher/liblonghorn
cd ~/go/src/github.com/rancher/liblonghorn
g remote add shuo-wu [email protected]:shuo-wu/liblonghorn.git

GRPC

protoc

wget https://github.com/protocolbuffers/protobuf/releases/download/v3.7.1/protoc-3.7.1-linux-x86_64.zip -O protoc.zip
unzip protoc.zip -d ./protoc
sudo cp ./protoc/bin/protoc /usr/local/bin/
rm -r ./protoc protoc.zip

Python code generator

pip3 install grpcio==1.22.0 grpcio_tools==1.22.0

Go code generator

mkdir -p ~/go/src/github.com/golang/
git clone https://github.com/golang/protobuf.git ~/go/src/github.com/golang/protobuf
cd ~/go/src/github.com/golang/protobuf
git checkout v1.3.2
cd protoc-gen-go
go build
sudo cp protoc-gen-go /usr/local/bin
cd ~

Run Rancher v2.5

sudo docker run -d --restart=unless-stopped -p 80:80 -p 443:443 --privileged rancher/rancher