Skip to content

Instantly share code, notes, and snippets.

@developerprofiles
Created March 27, 2020 16:45
Show Gist options
  • Save developerprofiles/3b557d258d29adf205a41612e8648686 to your computer and use it in GitHub Desktop.
Save developerprofiles/3b557d258d29adf205a41612e8648686 to your computer and use it in GitHub Desktop.
################################ Installation
Set-ExecutionPolicy Unrestricted
# Install Chocolatey
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
# Install Minikube (this also installs kubectl as a dependency)
choco install -y minikube -force
#choco install minikube kubernetes-cli
minikube config set WantUpdateNotification false
# Install Hyper-V
Get-WindowsOptionalFeature -FeatureName Microsoft-Hyper-V-All -Online
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All -NoRestart
# Docker for Windows requires Hyper-V
# Run from elevated prompt with (admin privileges)
bcdedit /set hypervisorlaunchtype auto
#bcdedit /set hypervisorlaunchtype off
# Reboot (required for Hyper-V)
Restart-Computer -Force
##########################################################
# Check Hyper-V is working
Get-VMHost
# Check Minikube is working
minikube version
# Check kubectl is working
# Note: Don't worry about the error message, this is normal since
# Kubernetes isn't running yet
kubectl version
##########################################################
systeminfo
# Configure Hyper-V networking
New-VMSwitch -name minikube -SwitchType Internal
## Note: You might find that after every reboot, you need to disable/re-enable network sharing.
##########################################################
# Starting your Kubernetes cluster
#minikube start --vm-driver=docker
$env:HYPERV_VIRTUAL_SWITCH="minikube"
minikube start — vm-driver=”hyperv” — hyperv-virtual-switch=”minikube”
# minikube start — vm-driver=”hyperv” — hyperv-virtual-switch=”minikube” --iso-url=C:\Users\intel\.minikube\cache\iso\minikube-v1.9.0
#--image-mirror-country=cn
#minikube start --image-mirror-country=cn --iso-url=https://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/iso/minikube-v1.6.0.iso --registry-mirror=https://registry.docker-cn.com
##########################################################
# If above step failed, so delete and restart
minikube delete
# C:\Users\current-user\ and delete .kube and .minikube folders.
Get-NetAdapter
$net = Get-NetAdapter -Name 'Ethernet'
New-VMSwitch -Name "External VM Switch" -AllowManagementOS $True -NetAdapterName $net.Name
##########################################################
#minikube config set driver hyperv
minikube config set vm-driver hyperv
#########################################################
# Test out Kubernetes
# kubectl should now report a version for the K8s server
kubectl version
# Checking how many nodes are in our cluster
kubectl get nodes
# Creating a deployment of aspnetcore
kubectl create deployment aspnetcore --image=mcr.microsoft.com/dotnet/core/samples:aspnetapp #deployment.apps/aspnetcore created
# The deployment should spin up an aspnetcore pod
kubectl get pod
# Expose the deployment via NodePort service so we can connect to it
kubectl expose deployment aspnetcore --type=NodePort --port=8182
# Check that the NodePort service is up
kubectl get service
# Open the example aspnetcore service
minikube service aspnetcore #http://192.168.99.100:30731/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment