# Up and Running with Istio within minutes

# Istio Overview

[Istio](https://istio.io/) is an open source service mesh that layers transparently onto distributed applications running on [Kubernetes](https://kubernetes.io/). Istio's powerful features provide a uniform and more efficient way to secure, connect, and monitor services.

In this post, I'll explain the bare minimum steps needed in order to successfully install and test Istio on your local machine.

# Prerequisites

1. A local Kubernetes cluster such as [minikube,](https://minikube.sigs.k8s.io/docs/start/) [kind](https://kind.sigs.k8s.io/), [K3s](https://k3s.io/) or [microk8s](https://microk8s.io/). In this blog post I have chosen `minikube` with the use of the [`minikube tunnel`](https://minikube.sigs.k8s.io/docs/commands/tunnel/) to provide a load balancer for use by Istio.
    
2. The [kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl) command line tool to interact with the Kubernetes cluster.
    

# Installation

Create a new minikube cluster:

```plaintext
minikube start -p minikube-istio
```

Start a minikube tunnel to provide a load balancer for use by Istio:

```plaintext
minikube tunnel -p minikube-istio
```

Download Istio as per the instructions in [this](https://istio.io/latest/docs/setup/getting-started/#download) link:

```plaintext
curl -L https://istio.io/downloadIstio | sh -
```

Add the istio-\*/bin directory to your environment PATH variable and check the version:

```plaintext
istioctl version
```

The output should be similar to:

```plaintext
no ready Istio pods in "istio-system"
1.20.3
```

Install Istio with the *demo* profile:

```plaintext
istioctl install --set profile=demo
```

After successful installation, you should have an istio-system namespace available

```plaintext
kubectl get ns
```

You should see an output similar to:

```plaintext
NAME              STATUS   AGE
kube-system       Active   4m22s
default           Active   4m22s
kube-public       Active   4m22s
kube-node-lease   Active   4m22s
istio-system      Active   2m49s
```

Check the Pods inside the istio-system namespace:

```plaintext
kubectl get pods -n istio-system
```

You should see the `istiod`, `istio-ingressgateway` and the `istio-egressgateway` pods up and running.

# Automatic Injection of Sidecars

Automatic injection of sidecar containers is achieved by setting the label `istio-injection=enabled` on namespaces.

```plaintext
kubectl label ns default istio-injection=enabled
```

Create a simple deployment of nginx to test the sidecar injection:

```plaintext
kubectl create deploy my-nginx --image=nginx
```

Get the details of the pod:

```plaintext
kubectl get pod
```

You will see two containers for the Pod, as it includes the sidecar container:

```plaintext
NAME                      READY   STATUS    RESTARTS   AGE
my-nginx-b8dd4cd6-4kh4x   2/2     Running   0          24s
```

Delete this deployment as we do not need it anymore:

```plaintext
kubectl delete deploy my-nginx
```

# Demo Application

We will deploy an application with two Spring Boot microservices named [`customers`](https://github.com/adityasamant25/customers) and [`rest-client`](https://github.com/adityasamant25/rest-client).

The `customers` microservice is a CRUD microservice that provides APIs to manipulate customer data.

The `rest-client` microservice acts as a client to the `customers` microservice and invokes it using the new [`RestClient`](https://docs.spring.io/spring-framework/reference/integration/rest-clients.html#rest-restclient) in Spring Framework 6.1.x

Create the [Gateway](https://istio.io/latest/docs/reference/config/networking/gateway/) Resource:

```plaintext
kubectl apply -f https://raw.githubusercontent.com/adityasamant25/courses/main/istio/demo/gateway.yaml
```

Create the [Deployment](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/) and [Service](https://kubernetes.io/docs/concepts/services-networking/service/) for the `rest-client` application:

```plaintext
kubectl apply -f https://raw.githubusercontent.com/adityasamant25/courses/main/istio/demo/rest-client.yaml
```

Create the Deployment and Service for the `customers` application:

```plaintext
kubectl apply -f https://raw.githubusercontent.com/adityasamant25/courses/main/istio/demo/customers-v1.yaml
```

Create a [Virtual Service](https://istio.io/latest/docs/reference/config/networking/virtual-service/) for the `rest-client` and bind it to the Gateway resource:

```plaintext
kubectl apply -f https://raw.githubusercontent.com/adityasamant25/courses/main/istio/demo/rest-client-vs.yaml
```

Run CURL against the following URL:

```plaintext
curl http://127.0.0.1/api/customers
```

You should see an output of 3 customers as follows:

```json
[
{"id":1,"firstName":"John","lastName":"Doe"},
{"id":2,"firstName":"Alice","lastName":"Smith"},
{"id":3,"firstName":"Bob","lastName":"Stevens"}
]
```

# Summary

Congratulations! You have a functional Istio cluster up and running on your local machine.

You can now use this cluster to further explore the various features of Istio.  

# What's Next

Dig deeper into Istio's main features such as [Observability](https://articles.adityasamant.dev/blog/istio/observability/), [Traffic Management](https://articles.adityasamant.dev/blog/istio/traffic-management/) and [Security](https://articles.adityasamant.dev/blog/istio/security/).
