devops,

Setup Workstation

Cui Cui Follow Jan 01, 2021 · 4 mins read
Setup Workstation
Share this

“Place which dreams come true “ - Art by painter Julia Makors

Install ChatGPT, Brave, iTerm

Install homebrew, zsh/ohmyzsh, sdkman, etc

homebrew

   /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
   brew tap homebrew/cask-versions

zsh

Homebrew should have installed zsh for you.

   brew install zsh
   sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
   chsh -s $(which zsh)

OhMyZsh! - zsh configuration management, setup ohmyzsh theme/plugins

Keep in mind: Plugins could slow down startup zsh!

Theme:

   brew install font-hack-nerd-font
   brew install powerlevel10k
   echo "source $(brew --prefix)/share/powerlevel10k/powerlevel10k.zsh-theme" >>~/.zshrc

Plugins:

   git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
   
   vi ~/.zshrc
   plugins=(zsh-autosuggestions)

Java SDKMAN

   curl -s "https://get.sdkman.io" | bash
   source "$HOME/.sdkman/bin/sdkman-init.sh"
   sdk version

sdkman install Java, Maven, Gradle, etc

   sdk install java 22.0.1-open
   sdk install maven
   sdk install gradle

SSH Keys

If you move from old workstation, and keep keys that still active

   Copy ~/.ssh keys
   Copy ~/.kube configuration 
   Copy ~/.bash_profile, .bash_history
   Copy ~/.zshrc, .zprofile, .zsh_history 
   Copy ~/.m2/settings.xml

If you want to create brand new keys

   KEY_TYPE=github
   KEY_NAME=`whoami`-$KEY_TYPE-`date +%Y-%m-%d`
   mkdir -p ~/.ssh/$KEY_TYPE

   ssh-keygen -t rsa -b 2048 -C $KEY_NAME -f ~/.ssh/$KEY_TYPE/$KEY_NAME
   ssh-keygen -l -E md5 -f ~/.ssh/$KEY_TYPE/$KEY_NAME

   chmod 600 $KEY_NAME
   chmod 644 $KEY_NAME.pub

   ssh-add --apple-use-keychain --apple-load-keychain ~/.ssh/$KEY_TYPE/$KEY_NAME
   # macOS reboot service
   vi ~/.ssh/config
   Host *
      AddKeysToAgent yes
      UseKeychain yes
      IdentityFile ~/.ssh/$KEY_TYPE/$KEY_NAME

Multi-Git Identities setup

Update .ssh config, to allow personal account for specific host

   vi ~/.ssh/config
   # default config
   Host github.com
      HostName github.com
      User git
      IdentityFile ~/.ssh/$KEY_TYPE/$KEY_NAME

   # removes all ssh entries from the ssh-agent, and add the only you want to use
   ssh-add -D
   ssh-add --apple-use-keychain --apple-load-keychain ~/.ssh/$KEY_TYPE/$KEY_NAME

Confirm local git config is right identity info

   # list all global git config
   git config --global -l

   # update global git config
   vi ~/.gitconfig
   [user]
      name = WorkIdentity
      email = work@gmail.com
   [includeIf "gitdir/i:~/Workspace/GitHub/"]
      path = ~/.github.gitconfig

   # create specific config for the personal identity
   vi ~/.github.gitconfig
   [user]
      name = PersonalIdentity
      email = personal@gmail.com

Git Repo

# This will use personal Git Identity
   cd ~/Workspace/GitHub/
   git clone git@github.com:xxxxxxxx/yyyyyyyyyy.git

   # This will use work Git Identity
   cd ~/Workspace/AnyOtherFolders
   git clone git@github.com:xxxxxxxx/yyyyyyyyyy.git

A bunch of GUIs I use

  • JetBrains/Intellij
  • VS Code
  • Sublime
  • Postman
  • Docker Desktop
  • Studio3T (MongoDB)
  • pgAdmin (PostgreSQL)
  • Wubi (Chinese Input method)
  • Youdao (Chinese Dictionary)
  • CreateStudio3
  • Adobe PS 5

Install CLIs

Azure, Kubernetes, Terraform CLI

   brew install azure-cli,
   brew install kubectl
   brew install Azure/kubelogin/kubelogin
   brew install tfenv
   tfenv install (terraform-cli)
   tfenv use x.y.z

MongoDB CLI

   brew tap mongodb/brew
   brew install mongodb-community-shell
   brew install mongocli
   brew install mongodb-database-tools

   # Upgrade
   brew upgrade mongodb-database-tools

Useful Cloud commands

  • Azure AKS CLI
   az login
   az account set --subscription "Subscription Name"
   az aks get-credentials --name kube-cluster-name --resource-group group-name
   # set default namespace
   kubectl config set-context kube-cluster-name --namespace=application
   # switch between k8s clusters
   kubectl config use-context kube-cluster-name
  • GCP CLI
   brew install --cask google-cloud-sdk

   # zsh
   export CLOUDSDK_PYTHON="/usr/local/opt/python@3.8/libexec/bin/python"
   source "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc"
   source "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc"

   # gcloud
   gcloud init

   # k8s
   gcloud container clusters get-credentials cluster1 --region europe-west2 --project project-name

Others, e.g. tree, fzf, ack

Join Newsletter
Get the latest news right in your inbox. We never spam!
Cui
Written by Cui Follow
Hi, I am Z, the coder for cuizhanming.com!