Author : MD TAREQ HASSAN | Updated : 2021/12/01
Chocholatey
Chocolatey is a package manager for windows (similar to homebrew in Mac or yum in Linux).
Installing chocholatey using Windows PowerShell
#
# PowerShell 5.1 comes with Windows by default
# Open Windows PowerShell as administrator
# command:
#
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
Installing chocholatey using cmd
#
# Open cmd as as administrator
# command:
#
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
# Details:
# https://docs.chocolatey.org/en-us/choco/setup
Upgrade
choco upgrade chocolatey -y
Version check
choco upgrade --noop
Uninstalling: https://community.chocolatey.org/courses/installation/uninstalling
PowerShell
See: PowerShell setup
Azure CLI
Install
# Using chocholatey
choco install azure-cli -y
# Using PowerShell
Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'; rm .\AzureCLI.msi
# Using MSI installer (download and install):
# https://aka.ms/installazurecliwindows
Upgrade
az upgrade
Version check
az --version
Azure CloudShell
What is CloudShell?
- Azure Cloud Shell is an interactive, authenticated, browser-accessible shell for managing Azure resources
- It provides the flexibility of choosing the shell experience that best suits the way you work - either Bash or PowerShell
- Pricing: The machine hosting Cloud Shell is free, with a pre-requisite of a mounted Azure Files share. Regular storage costs apply
Accessing CloudShell
- Direct link: https://shell.azure.com
- Azure portal: Select the Cloud Shell icon on the Azure portal (top right corner)
Initial Setup
- Cloushell requires Azure Storage Account file share
- Create Storage Account > Launch cloudshell > set it up
How to Use Manifest File in Command (i.e. to deploy K8s workload)
- Open cloudshell and expand the window
- Open code editor by either of the following ways:
- Click ‘
{ }
’- need to save file with extension to get code highlights (click top right elipses > save)
- shows files on left side
- Run: ‘
code xyz.yaml
’ (or ‘code xyz.json
’) -> does not show files on left side
- Click ‘
- Copy paste or write yaml or json content > save
- Refer file with flag in kubectl command: ‘
kubectl apply -f xyz.yaml
’
Re-mount fileshare
- Create new fileshare in target storage account if needed & copy the name of the fileshare (i.e. ‘xxx-fs’)
- Open cloudshell (Azure portal > top right icon)
clouddrive unmount
(session will be terminated and cloudshell will be re-started)- Select subscription and click “Show Advanced settings”
- Select location
- Select resource group, select storage account, paste fileshare name (i.e. ‘xxx-fs’)
Connecting and running CloudShell in VSCode
- Download and install nodejs: https://nodejs.org/en/download/current/
- Download and install VS Code: https://code.visualstudio.com/download
- Install “Azure Account” extension: https://marketplace.visualstudio.com/items?itemName=ms-vscode.azure-account
- Press “F1” > write “> Azure: Open PowerShell”
- Login to Azure (default browser will open)
- Cloud shell is connected
Running Azure CloudShell Locally
- Azure CloudShell has “20 minutes” session timeout. Sometimes it’s annoying and therefore you might want to run CloudShell locally
- CloudShell Github repo: https://github.com/Azure/CloudShell
- PowerShell Script Courtesy: https://thewindowsupdate.com/2020/11/10/how-to-setup-and-run-azure-cloud-shell-locally/
PowerShell launcher script
- Create a folder in C drive named “az-cloudshell” (
C:\az-cloudshell
) - Create a PowerShell script named “
cloudshell-launcer.ps1
” (C:\az-cloudshell\cloudshell-launcer.ps1
) - Create a folder named “scripts” (
C:\az-cloudshell\scrips
) - All of your scripts should be in “
C:\az-cloudshell\scrips
” folder and those scripts would be available in the mounted folder (/usr/cloudshell
) in container
C:\az-cloudshell\cloudshell-launcer.ps1
$startShellType = "/usr/bin/pwsh" # PowerShell, for bash -> "/bin/bash"
$cloudshellImageName = "mcr.microsoft.com/azure-cloudshell"
$sourceScriptFolder = "`"C:\az-cloudshell\scripts`"" # the folder where your local scrips are located, double quote is required ('`' to escape double quote)
$targetScriptFolder = "/usr/cloudshell" # mounted folder in container
$container = $(docker ps -q --filter ancestor=$cloudshellImageName)
$containerIsRunning = ($container -ne $null)
if ($containerIsRunning) {
Write-Host "Container is running. Connecting to container..."
docker exec -it $container $startShellType
} else {
Write-Host "Container is not running. Updating container image..."
docker pull "$($cloudshellImageName):latest"
Write-Host "Mapping '$($sourceScriptFolder)' to '$($targetScriptFolder)'. Connecting to cloudshell (interactive)... `r`n`r`n"
$volumeMount = "$($sourceScriptFolder):$($targetScriptFolder)"
docker run -it -v $volumeMount mcr.microsoft.com/azure-cloudshell $startShellType
}
Create shortcut with following
"C:\Program Files\PowerShell\7\pwsh.exe" -ExecutionPolicy Bypass -File "C:\az-cloudshell\cloudshell-launcer.ps1"
Now right click on shortcut and run (as “Admin” if required)
To connect azure account, use Device Authentication: DeviceAuthentication - Connect Azure Account in CloudShell when MFA is Enabled
Windows Subsystem for Linux (WSL)
Do following for a fresh installation in Windows 11:
- Right click on taskbar “start” icon > installed apps
- Serach “Ubuntu” and if installed, unistall it
- Serach “Windows Subsystem for Linux” and if installed, unistall it
- Taskbar search “turn windows feature”
- Uncheck “Virtual Machine Platform”
- Uncheck “Windows Subsystem for Linux”
- Restart
Installation
- Open cmd or PowerShell as admin
- install wsl
*
wsl --install
(restart)- cmd will open automatically
- Enter new UNIX username: xxx
- New password: yyy
- Now you can execute Ubuntu commands
- To exit: type “exit” and enter
- Note:
- Admin user is “root”
- To run a command as admin user “sudo
”
- cmd will open automatically
- Open cmd >
wsl --version
- To launch Ubuntu: taskbar search “Ubuntu”
- Links
wsl Commands
wsl --install # retart
wsl --version
wsl -l -v
wsl --list --online
wsl --install -d ubuntu
wsl --update
wsl --status
wsl --set-version <distro name> 2
wsl --set-version Ubuntu 2
wsl --shutdown
Notes:
- The Store version of WSL is now the default version of WSL
- “
wsl --install
” will now automatically install the Store version of WSL, and will no longer enable the “Windows Subsystem for Linux” optional component, or install the WSL kernel or WSLg MSI packages as they are no longer needed (The Virtual machine platform optional component will still be enabled, and by default Ubuntu will still be installed)
Global configuration:
- Open “run”
- type “%UserProfile%”
- create a file “.wslconfig”
.wslconfig
[wsl2]
memory=8GB
processors=4
[boot]
systemd=true
# https://learn.microsoft.com/en-us/windows/wsl/wsl-config#example-wslconfig-file
Using linux commands:
- Taskbar search “Ubuntu”
- Update Ubuntu
sudo apt update && sudo apt upgrade -y
sudo apt-get update -y
- Use:
pwd
ls
cd /mnt/c/
whoami
- ect.
Access linux (i.e. Ubuntu) files
- File explorer
- Open file explorer
- Type:
\\wsl$
- Enter
- PowerShell
- Open PowerShell
cd \\wsl$\Ubuntu
wsl wsl whoami
Docker
Choice of backend for Docker Desktop: docker can be installed using either of followings:
- Windows Subsystem for Linux 2 (WSL2) backend
- Hyper-V backend
WSL2 backend
- Enable wsl (descrive above)
- Download: https://www.docker.com/products/docker-desktop
- Double-click Docker Desktop Installer.exe to run the installer
- Check “Use WSL 2 instead of Hyper-V (recommended)” option
- Install > Click “Close and restart” (or restart manually)
- Open docker > sign-in
- Set Docker Desktop resource quota
- Open “Run” > %UserProfile% > Create/Edit “.wslconfig” file (assuming docker backend is wsl)
- Set cpu, memory in “.wslconfig” (https://learn.microsoft.com/en-us/windows/wsl/wsl-config#example-wslconfig-file)
- Save “.wslconfig”
- Restart PC (otherwise docker will be running with befault cpu and memory quota)
Hyper-V backend
- Hyper-V features must be enabled
- See: https://docs.docker.com/desktop/install/windows-install/#hyper-v-backend-and-windows-containers
Installing Docker in Azure Windows VM
- Window Server 2022 VM
- WSL2 is not supported
- Github issue: https://github.com/microsoft/WSL/issues/6301#issuecomment-858816891
- Windows Server 2019 VM
- Open PowerShell as Admin and execute commands
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
- Download and install:** https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
- Reboot VM
- Open PowerShell as Admin and execute commands
- Courtesy: https://petri.com/how-to-install-wsl-on-windows-server
Links
- https://www.thomasmaurer.ch/2019/08/how-to-install-wsl-2-on-windows-server/
- https://www.thomasmaurer.ch/2015/11/nested-virtualization-in-windows-server-2016-and-windows-10/
Minikube
Installation
choco install minikube -y
#
# cleanup
#
# minikube delete --all --purge
#
Minikube driver
minikube can be deployed:
- As bare-metal: run minikube directly on local machine without hypervisor (
minikube start --driver=none
) - As container: Docker Desktop (
minikube start --driver=docker
) - As VM
- A simple local kubernetes cluster having one Virtual Machine
- To create that Virtual Machine, Minikube needs a hypervisor
- Hyper-V (
minikube start --driver=hyperv
) - VirtualBox (
minikube start --driver=virtualbox
)
- Hyper-V (
Start minikube with Container (docker) driver
#
# 1. Set Docker Desktop resource quota
# Open "Run" > %UserProfile% > Create/Edit ".wslconfig" file (assuming docker backend is wsl)
# > set cpu, memory > save
# > restart PC (otherwise docker will be running with befault cpu and memory quota)
#
#
# 2. Set docket as default driver
#
docker context use default # https://stackoverflow.com/a/77252383/4802664
minikube config set driver docker
#
# 3. minikube
#
# minikube start --driver=docker
minikube delete # must delete the cluster before setting cpu & memory
minikube start
minikube start --cpus 4 --memory 8192 # Max docker RAM is set in ".wslconfig" file, so don't set RAM more than that
# Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
Start minikube with Hyper-V driver
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Tools-All -All
minikube start --driver=hyperv
#
# set docket as default driver
#
minikube config set driver hyperv
# minikube start --driver=hyperv --cpus <core count> --memory <n in MB>
minikube start --driver=hyperv --cpus 2 --memory 1800 (1800 MB -> minimum required by minikube)
minikube start --driver=hyperv --cpus 2 --memory 2090 (when 4GB RAM is used for hyper-v VM startup RAM)
minikube start --driver=hyperv --cpus 4 --memory 4096
#4GB -> 4096
#8GB -> 8192
#10GB -> 10240
minikube start --vm-driver hyperv --hyperv-virtual-switch "<switch name>"
minikube start --vm-driver hyperv --hyperv-virtual-switch "Primary Virtual Switch"
#(https://learn.microsoft.com/en-us/windows-server/virtualization/hyper-v/get-started/create-a-virtual-switch-for-hyper-v-virtual-machines?tabs=hyper-v-manager)
Once minikube is started, we can interact with it using kubectl:
- If kubectl is not installed
- If kubectl is not installed locally, minikube already includes kubectl
- Use minikube kubectl like this:
minikube kubectl -- <kubectl commands>
- kubectl is not installed
choco install kubernetes-cli -y
- By default, kubectl gets configured to access the kubernetes cluster control plane inside minikube when the minikube start command is executed
Start minikube with Bare-metal driver
Note: The driver ‘none’ is not supported on windows/amd64
# 'none' is not supported on windows/amd64
minikube start --driver=none
minikube start --driver=none --cpus 4 --memory 8192 # 4 CPUs, 8GB RAM
#
# Set as default
#
minikube config set driver none
# https://minikube.sigs.k8s.io/docs/start/
Test local minikube cluster using kubectl
# On successfull start, you will get similar message to the following:
# Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
# if kubectl is not installed: minikube kubectl -- get pods -A
# If kubectl is already installed:
kubectl get pods -A
kubectl get nodes -o wide
Dashboard
# Enable metric server
minikube addons enable metrics-server
# Launch dashboard (will enable first if not enabled)
minikube dashboard
Stop minikube
minikube status
minikube stop
Pulumi
Install
# using chocolatey
choco install pulumi -y
# download and install:
# https://www.pulumi.com/docs/get-started/install/
Version check
pulumi version
Cmder
Install using chocholatey
# using chocolatey
choco install cmder -y
choco upgrade cmder
Open Cmder
- Location: ‘
C:\tools\Cmder
’ - Open ‘cmd’ > write “cmder” > enter
- Open ‘Run’ > cmder > enter
Or download latest version and extract (put it in ‘C:\tools’): https://github.com/cmderdev/cmder/releases/
Note: use ‘/d’ to change directory i.e. “cd /d
Connect Cmder to Azure
- Login to Azure using default browser
- Taskbar > Search: “default apps” > Set the browser which you used to login to Azure
- Cmder >
az login
- Default browser will open > login to Azure portal
- Cmder is now connected to Azure portal
az aks login
Using Cmder to Interact with AKS Cluster
# if you are not logged in yet
az aks login
# get aks credential
az aks get-credentials --resource-group xyz-rg --name xyz-aks-cluster
AKS cluster Access Control
- Cluster configuration
- RBAC is enabled
- AKS-managed Azure Active Directory is enabled
- If you try to execute kubctl command, it will ask you to authenticate (cluster level authentication)
- Execute ‘
kubectl get pods --namespace xyz
’ - Reply in console form AKS cluster: ‘To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code XYZABC to authenticate’
- Go to: https://microsoft.com/devicelogin and enter the code (i.e. XYZABC from reply in console) to authenticate
- Execute ‘
Once authenticated into AKS cluster, now execute kubectl commands
# make sure you set the correct namespace
kubectl config view --minify | grep namespace # check namespace, for default namespace no value (empty) might be shown
kubectl config set-context --current --namespace xyz # set namespace
# Nodes
kubectl get nodes
# Pods
kubectl get pods
# Services
kubectl get svc
Kubectl
Install
# using chocolatey
choco install kubernetes-cli -y
choco upgrade kubernetes-cli
Version check
kubectl version --client
Helm
Install
# using chocolatey
choco install kubernetes-helm -y
Upgrade
choco upgrade kubernetes-helm -f -y
Add Helm to ‘Path’ environment variable
- In Windows 10 (64-bit), helm will be installed (by chocolatey) in the folder:
C:\ProgramData\chocolatey\lib\kubernetes-helm\tools\windows-amd64
- Search taskbar “environment” > Edit the system environment variables
- Environment variables > System variables > select “Path” > Edit
- New > Add path > Ok
Check if Helm was istalled successfully (open PowerShell or cmd)
# you might need to restart your cmd/Cmder/Git Bash/PowerShell
helm version
NVM and Nodejs
Prerequisites:
- Make sure that chocholatey is already installed
- Check compatibility nodejs depending on your target angular version
- Compatibility matrix: https://gist.github.com/LayZeeDK/c822cc812f75bb07b7c55d07ba2719b3
- nodejs releases: https://nodejs.org/download/release/
Install NVM
# Open cmd or PowerShell ad Admin
choco install nvm -y
# or download and install (windows): https://github.com/coreybutler/nvm-windows#installation--upgrades
Install Nodejs using NVM
# Restart cmd or PowerShell
nvm install latest
# make latest as current
nvm use latest
# check
nvm current
# nvm ls
Check if nodejs is laready installed or not
node -v
npm
# check version
npm -v
# install
npm i -g npm # check again: npm -v
NVM in MAC
Run this in terminal:
touch ~/.bash_profile
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash
DO NOT forget to Restart your terminal.
Now in the terminal, use command nvm --version
and you should see the version.
See: https://stackoverflow.com/a/43037695
Angular CLI
Prerequisites:
- Make sure that chocholatey is already installed (to install NodeJS)
- NodeJS
Global installation
npm uninstall -g @angular/cli
npm cache clean --force
npm cache verify
npm install -g @angular/cli@latest
Local installation: Go to the priject folder and install local with --save-dev
rm -rf node_modules dist
npm install --save-dev @angular/cli@latest
npm i
ng update @angular/cli
ng update @angular/core
npm install --save-dev @angular-devkit/build-angular
Install specific version
npm install -g @angular/cli@11.2.14
npm install --save-dev @angular/cli@11.2.14
Check version
ng version
Uninstall Angular CLI
npm uninstall -g @angular/cli
npm uninstall @angular/cli
npm cache clean --force
#
# If you installed specific version
# i.e. version 11.2.11
#
npm uninstall -g @angular/cli@11.2.11
npm uninstall @angular/cli@11.2.11
npm cache clean --force
jq
# make sure that chocholatey is already installed
choco install jq -y
# flag '-y' for accepting all
OpenSSL
#
# Check if already installed
#
openssl version
#
# Install
#
choco install openssl
Ruby and Jekyll
Install Ruby and DevKit
- Download and install: https://rubyinstaller.org/downloads/
- Install Ruby only (no DevKit)
- After installing Ruby, install DevKit (MSYS2 and Mingw toolchain):
- Open cmd as admin
- Command:
ridk install 3 2
Install Jekyll
gem install jekyll bundler
jekyll -v
Create a Jekyll site:
jekyll new xxx-blog
cd xxx-blog
- Open Gemfile, edit and save (don’t forget to add
gem "webrick", "~> 1.7"
in plugin section)
Gemfile
# This will help ensure the proper Jekyll version is running.
gem 'jekyll'
# This is the default theme for new Jekyll sites. You may change this to anything you like.
# gem "minima", "~> 2.0"
# If you want to use GitHub Pages, remove the uncomment "gem jekyll" above and
# uncomment the line below. To upgrade, run `bundle update github-pages`.
gem "github-pages", group: :jekyll_plugins
gem 'jekyll-theme-cayman', '~> 0.0.3'
# If you have any plugins, put them here!
# gem 'jekyll-analytics'
group :jekyll_plugins do
gem "jekyll-feed", "~> 0.6"
gem "jekyll-seo-tag"
gem 'jekyll-toc', "<= 0.12.2"
gem 'jekyll-commonmark-ghpages'
gem "webrick", "~> 1.7"
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]
# Performance-booster for watching directories on Windows
gem "wdm", "~> 0.1.0" if Gem.win_platform?
Install and update gems:
bundle install
bundle update
bundle update github-pages
Run locally:
bundle exec jekyll serve
bundle exec jekyll serve --livereload
bundle exec jekyll serve --watch
bundle exec jekyll serve --incremental
bundle exec jekyll serve --incremental --livereload
bundle exec jekyll serve --trace
SQL Server
choco install sql-server-2022
# check version: https://www.microsoft.com/en-us/sql-server/sql-server-downloads
SQL Server Management Studio
choco install sql-server-management-studio -y