DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • Spinnaker Meets Minikube: Part 1
  • The Evolution of Scalable and Resilient Container Infrastructure
  • Scaling Microservices With Docker and Kubernetes on Production
  • Can You Run a MariaDB Cluster on a $150 Kubernetes Lab? I Gave It a Shot

Trending

  • Traditional Testing and RAGAS: A Hybrid Strategy for Evaluating AI Chatbots
  • Distributed Consensus: Paxos vs. Raft and Modern Implementations
  • Tired of Spring Overhead? Try Dropwizard for Your Next Java Microservice
  • A Guide to Auto-Tagging and Lineage Tracking With OpenMetadata
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Kubernetes Local Development With Minikube on Hyper-V Windows 10

Kubernetes Local Development With Minikube on Hyper-V Windows 10

Devs typically like to be online when they work, but this tutorial will show you how to develop with Kubernetes offline.

By 
Ion Mudreac user avatar
Ion Mudreac
·
Updated Apr. 22, 20 · Tutorial
Likes (6)
Comment
Save
Tweet
Share
30.4K Views

Join the DZone community and get the full member experience.

Join For Free

Most software development is currently done online, especially development that requires Kubernetes and the cloud. In many cases when developers travel and don’t have reliable access to the Internet, it's good to have a local development environment that can be run on a laptop and provide basic Kubernetes setup to continue the development process in a more productive way.

In this article, I show how minikube allows you to run functional Kubernetes as single node cluster on a laptop in Windows 10 using Hyper-V Hypervisor.

Let’s start by installing and configuring minikube with Grafana, Prometheus, Helm, and Istio on Windows 10.

Prerequisites for Development Machine Environment

  • VT-x/AMD-v virtualization must be enabled in BIOS (requires machine restart)
  • Enable Hyper-V: Go to "Windows features On or Off," and you will see a dialog box with a list of Windows features as shown below. Navigate to the Hyper-V section and enable it (requires machine restart).

Hyper-V Installation

Hyper-V is included with Windows since Windows Server 2008 as well as Windows 8, 8.1 and 10 in the Pro versions. It can be enabled from Control Panel at “Turn Windows features On or Off” under “Programs and Features.” Activate the “Hyper-V” checkbox, apply the change, and follow the directions on-screen.

Image title

Network Configuration

First, you must configure a new virtual switch so that your virtual machine will be able to connect to the Internet. Once Hyper-V is enabled, start the Hyper-V Manager.

Configuration can be done in GUI by opening PowerShell as Administrator and running Hyper-V Manager

mmc.exe virtmgmt.msc

Or we can use only PowerShell for the rest of the configurations.

Creating External Switch

Using PowerShell (run as Administrator)

  • Get a list of the network adapters in the host. In a laptop, you should typically see "Ethernet" and "Wi-Fi"
Get-NetAdapter
  • Create the external switch with a name of VM-External-Switch, bound to the network adapter named Wi-Fi retrieved from the previous command. You may need to change your -NetAdapterName to an interface connected to the internet.
New-VMSwitch -name ExternalSwitch  -NetAdapterName "Ethernet 3"  -AllowManagementOS $true

The easiest way to install minikube is to deployed from choco.

Chocolatey is a package manager for Windows (like apt-get or yum but for Windows). It was designed to be a decentralized framework for quickly installing applications and tools that you need. It is built on the NuGet infrastructure currently using PowerShell as its focus for delivering packages.

Follow the Installation Guide or follow the below PowerShell commands

Using PowerShell (run as Administrator):

Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString(‘https://chocolatey.org/install.ps1'))

Using cmd (run as Administrator):

@”%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe” -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command “iex ((New-Object System.Net.WebClient).DownloadString(‘https://chocolatey.org/install.ps1'))" && SET “PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin”

Once installed check for any Upgrades available for Chocolatey:

choco upgrade chocolatey

Install kubectl cli:

choco install kubernetes-cli

Install minikube:

Using PowerShell (run as Administrator):

choco install minikube

Test minikube installation:

minikube version

Check available Version of Kubernetes:

minikube get-k8s-versions

Update minikube:

minikube update-check

Initiate minikube

Check available initialization options:

minikube.exe start — help
  •  vm-driver Hyper-V : Specifies Hypervisor driver to be used
  •  cpus 4 : Specifies number of CPU “cores” allocation, if not specified, “Default is 2”
  •  memory=4096 : Specifies the amount of RAM allocated, if not specified, “Default is 2048”
  •  hyperv-virtual-switch “VM-External-Switch” : Specify virtual network switch to be used “VM-External-Switch was created in previous steps”
  •  kubernetes-version string : Specify version of Kubernetes to be installed (ex. v1.2.3)

Post Install minikube

  • Stop minikube k8s VM

minikube stop

Disable Dynamic RAM allocation in Hyper V

Set-VMMemory minikube -DynamicMemoryEnabled $false

Start minikube k8s VM

minikube start

Deploy additional Kubernetes components

List minikube addons

minikube addons list

Enable Hipster for cluster performance monitoring

minikube addons enable heapster

Post Install checks minikube

Check minikube status

minikube status
minikube service list

Launch Kubernetes dashboard

minikube dashboard

Check dashboard URL

minikube dashboard — url

Ssh into minikube

minikube ssh

Run kubectl commands against minikube

kubectl config use-context minikube
kubectl config current-context
kubectl get po -n kube-system
kubectl get po — all-namespaces
kubectl get all — all-namespaces
kubectl api-versions | grep rbac
kubectl version
kubectl cluster-info
kubectl api-versions

Test minikube Kubernetes deployment

kubectl run hello-minikube — image=k8s.gcr.io/echoserver:1.4 — port=8080 
kubectl expose deployment hello-minikube — type=NodePort
kubectl get services
kubectl get deploy
kubectl get pod

Find IP

minikube ip

Find mapped port

kubectl describe service hello-minikube
kubectl get svc hello-minikube

curl http://$IP:$PORT

Remove testing deployment

kubectl delete services hello-minikube
kubectl delete deployment hello-minikube

eval $(minikube docker-env)
docker info

Minikube Add-Ons

List minikube available addons

minikube addons list

Enable Ingress for minikube K8s

minikube addons enable ingress

Enable Elastic Fluentd Kibana

minikube addons enable efk

Install Helm cli and initialise tiller

choco install kubernetes-helmhelm init

Post Helm installation configuration

kubectl — namespace=kube-system edit deployment/tiller-deploy

Change automountServiceAccountToken  to true 

automountServiceAccountToken true

Or you can do it in one liner

kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"automountServiceAccountToken":true}}}}'

Check Helm installation

helm versionhelm search
kubectl get svc -n kube-system
helm ls — debug

Upgrade Helm

helm init --upgrade

Helm update repositories

helm repo update

Let’s try to deploy some packages and inspect using MySQL as an example.

helm inspect stable/mysql
helm install stable/mysql

Install helm packages for Prometheus and Grafana.

helm install stable/prometheus
helm install stable/grafana

Get Access to Prometheus.

  • Get the Prometheus server URL

  • Get POD_NAME   for running Prometheus server

kubectl get pods — namespace default -l “app=prometheus,component=server” -o jsonpath=”{.items[0].metadata.name}”

Note: Replace $POD_NAME   with output from previous command

kubectl — namespace default port-forward $POD_NAME 9090

Get the Alertmanager URL

Get POD_NAME   for running Prometheus alert manager

kubectl get pods — namespace default -l “app=prometheus,component=alertmanager” -o jsonpath=”{.items[0].metadata.name}”
   Note: Replace $POD_NAME with  output from previous command  
kubectl — namespace default port-forward $POD_NAME 9093

Get the PushGateway URL

Get POD_NAME   for running Prometheus push gateway

kubectl get pods — namespace default -l “app=prometheus,component=pushgateway” -o jsonpath=”{.items[0].metadata.name}”

Replace $POD_NAME   with output from previous command

kubectl — namespace default port-forward $POD_NAME 9091

Get Access to Grafana

Get your ‘admin’ user password in base64 and decode by running:

Note: This works only under Linux.

kubectl get secret — namespace default interested-moth-grafana -o jsonpath=”{.data.admin-password}” | base64 — decode ; echo
  • Get the Grafana URL

  • Get POD_NAME   for running Grafana

kubectl get pods — namespace default -l “app=grafana” -o jsonpath=”{.items[0].metadata.name}”

  Note: Replace $POD_NAME   with the output from the previous command. 

kubectl — namespace default port-forward $POD_NAME 3000

Deploy k8s dashboard for docker k8s “minikube comes with dashboard deployed”

helm install stable/kubernetes-dashboard
kubectl proxy

In web browser use below link to access Kubernetes dashboard:

http://localhost:8001/ui

Or open in browser

http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/

Get Istio installation.

git clone https://github.com/istio/istio.git 
cd istio
kubectl create -f install/kubernetes/helm/helm-service-account.yaml
helm init — service-account tiller
helm install install/kubernetes/helm/istio — name istio
helm delete — purge istio
Hyper-V Kubernetes

Opinions expressed by DZone contributors are their own.

Related

  • Spinnaker Meets Minikube: Part 1
  • The Evolution of Scalable and Resilient Container Infrastructure
  • Scaling Microservices With Docker and Kubernetes on Production
  • Can You Run a MariaDB Cluster on a $150 Kubernetes Lab? I Gave It a Shot

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!