Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Setup of a Local Kubernetes and Istio Dev Environment

DZone 's Guide to

Setup of a Local Kubernetes and Istio Dev Environment

For developers who prefer to work locally, check out this tutorial on setting up Kubernetes and Istio on your machine.

· Cloud Zone ·
Free Resource

As a developer, I like to do as much development as possible locally, because it's generally easier and faster to develop and debug code. In order to build cloud-native applications and microservices, it's very convenient to have a local Kubernetes cluster and Istio running locally. This article describes how to install these components and some additional tools like Kiali.

Minikube

In order to run Kubernetes clusters locally, there are different alternatives. One is to use the Kubernetes functionality integrated in Docker Desktop. The alternative that I've chosen is Minikube, which runs a single-node Kubernetes cluster inside a VM on your development machine.

Follow the instructions to install kubectl and Minikube. For a hypervisor, I'm using VirtualBox, which is supported on Mac, Linux, and Windows.

When running Istio and your own applications, you need more memory and CPUs than you get by default. Here are my settings:

$ minikube config set cpus 4
$ minikube config set memory 8192
$ minikube config set disk-size 50g
$ minikube addons enable ingress 
$ minikube start


 minikube start can take several minutes when starting for the first time. Be patient.

Sometimes minikube start doesn't work for me. In that case, I stop my VPN, invoke  minikube delete# , delete the .minikube directory, restart my machine and start it again.

After this, you can get the Minikube IP address and open the Kubernetes dashboard via these commands:

$ minikube ip
$ minikube dashboard


Minikube comes with it's own Docker daemon, so you don't have to use Docker Desktop. You only need the Docker CLI and to point it to Minikube:

$ eval $(minikube docker-env)


To stop the cluster run this command:

$ minikube stop


Istio

To download Istio, run this command:

$ curl -L https://git.io/getLatestIstio | sh -


Follow the instructions in the terminal to set the path.

To install Istio, run these commands:

$ cd istio-1.0.6
$ kubectl apply -f install/kubernetes/helm/istio/templates/crds.yaml
$ kubectl apply -f install/kubernetes/istio-demo.yaml


Make sure that all pods are running or completed before continuing. This can take several minutes when starting the pods for the first time. Be patient.

$ kubectl get pod -n istio-system


This screenshot shows all Istio pods running or completed (ignore the Kiali one for now).

In the last step, enable automatic sidecar injection:

$ kubectl label namespace default istio-injection=enabled


After the setup of Minikube and Istio you can use the following tools:

Kubernetes Dashboard

$ minikube dashboard


Jaeger Dashboard

$ kubectl port-forward -n istio-system $(kubectl get pod -n istio-system -l app=jaeger -o jsonpath='{.items[0].metadata.name}') 16686:16686


URL to Open Jaeger: http://localhost:16686

Grafana Dashboard

$ kubectl -n istio-system port-forward $(kubectl -n istio-system get pod -l app=grafana -o jsonpath='{.items[0].metadata.name}') 3000:3000 &


URL to open Grafana: http://localhost:3000/dashboard/db/istio-mesh-dashboard

Prometheus Dashboard

$ kubectl -n istio-system port-forward $(kubectl -n istio-system get pod -l app=prometheus -o jsonpath='{.items[0].metadata.name}') 9090:9090 &


URL to open Prometheus: http://localhost:9090

Kiali

Run the following command to install Kiali:

$ bash <(curl -L http://git.io/getLatestKialiKubernetes)


Note: For some reason the script didn't work for me. I had to replace one line:

get_downloader
github_api_url="https://api.github.com/repos/kiali/kiali/releases/latest"
kiali_version_we_want="v0.15.0"


To launch Kiali you need the IP address and NodePort:

$ minikube ip
$ kubectl get svc -n istio-system kiali --output 'jsonpath={.spec.ports[*].nodePort}'


URL to open Kiali: https://[minikube-ip]:[kiali-nodeport]/kiali

Sample Application

I'm working on a simple sample application that shows some of the Istio and MicroProfile functionality to build cloud-native applications. I'll blog more about this soon.

For now you can install two sample microservices from this project. Make sure Minikube runs and you have installed all the necessary prerequisites:

$ git clone https://github.com/nheidloff/cloud-native-starter.git
$ scripts/check-prerequisites.sh
$ scripts/deploy-articles-java-jee.sh
$ scripts/deploy-web-api-java-jee.sh


The following screenshot shows a BFF (backend for frontend) web-api microservice invoking another articleswebservice:

Most of the information in this article I got from Harald Uebele. Thanks Harald. I just added some details that I had to do differently.

Topics:
cloud ,kubernetes ,istio ,service mesh ,container ,local development ,tutorial

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}