DEV Community

Niklas Heidloff
Niklas Heidloff

Posted on

Setup of a Local Kubernetes and Istio Dev Environment

As 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. As hypervisor I’m using VirtualBox which is supported on Mac, Linux and Windows.

When running Istio and your own applications, you need more 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
Enter fullscreen mode Exit fullscreen mode

‘minikube start’ can take several minutes when starting it 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
Enter fullscreen mode Exit fullscreen mode

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

$ eval $(minikube docker-env)
Enter fullscreen mode Exit fullscreen mode

To stop the cluster run this command:

$ minikube stop
Enter fullscreen mode Exit fullscreen mode

Istio

To download Istio, run this command:

$ curl -L [https://git.io/getLatestIstio](https://git.io/getLatestIstio) | sh -
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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

setup-loca-id-kubernetes-1

In the last step enable automatic sidecar injection:

$ kubectl label namespace default istio-injection=enabled
Enter fullscreen mode Exit fullscreen mode

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

Kubernetes Dashboard

$ minikube dashboard
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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 &
Enter fullscreen mode Exit fullscreen mode

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 &
Enter fullscreen mode Exit fullscreen mode

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

Kiali

Run the following command to install Kiali:

$ bash <(curl -L [http://git.io/getLatestKialiKubernetes](http://git.io/getLatestKialiKubernetes))
Enter fullscreen mode Exit fullscreen mode

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](https://api.github.com/repos/kiali/kiali/releases/latest)"
kiali_version_we_want="v0.15.0"
Enter fullscreen mode Exit fullscreen mode

To launch Kiali you need the IP address and NodePort:

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

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 necessary prerequisites:

$ git clone [https://github.com/nheidloff/cloud-native-starter.git](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
Enter fullscreen mode Exit fullscreen mode

The following screenshot shows a BFF (backend for frontend) ‘web-api’ microservice invoking another ‘articles’ webservice:

setup-loca-id-kubernetes-2

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.

Top comments (1)

Collapse
 
crackitty profile image
Charlie Roche • Edited

Hey, nice article, just wanted to point out that since 1.1.2 Istio crds are no longer where you mention so the line:

kubectl apply -f install/kubernetes/helm/istio/templates/crds.yaml

should be

kubectl apply -f install/kubernetes/helm/istio-init/files

Also, for the Kiali part, that has changed in the meantime and now the install is:

bash <(curl -L https://git.io/getLatestKialiOperator)