# Use Istio

## What Will You Do

In this exercise,

- You will be deploying a sample application with istio proxy

---

## Assumptions

- You have already provisioned or imported a Kubernetes cluster using the controller.
- You have successfully published a istio addon based cluster blueprint to your cluster.

For this example, we will use the bookinfo application.

---

## Step 1: Download Bookinfo sample application

```
curl -o bookinfo.yaml https://raw.githubusercontent.com/istio/istio/release-1.8/samples/bookinfo/platform/kube/bookinfo.yaml
curl -s https://raw.githubusercontent.com/istio/istio/release-1.8/samples/bookinfo/networking/bookinfo-gateway.yaml >> bookinfo.yaml
```

---

## Step 2: Create a Namespace for demo app

- Login into the Web Console and navigate to your Project as an Org Admin or Project Admin
- Under Infrastructure (or Applications if accessed with Project Admin role), select "Namespaces" and create a new namespace called "demo"
- Next in the Wizard, in the general section add the following label `istio-injection: enabled` and click save and go to placement.
- Select the appropriate cluster(s) and publish the namespace.

## Step 3: Create workload

- Go to Applications > Workloads
- Select "New Workload" to create a new workload called "bookinfo"
- Ensure that you select "k8s YAML" for Package Type and select the namespace as "demo"
- Click CONTINUE to next step
- Select Choose File and upload bookinfo.yaml file
- Save and Go to Placement
- In the Placement step, select the cluster(s) that you would like to deploy bookinfo application
- Publish the bookinfo workload to the selected cluster(s)

---

## Step 4: Verify Deployment

You can optionally verify whether the correct resources have been created on the cluster.

- First, we will verify the pod status

```
kubectl get po -n demo
NAME                              READY   STATUS    RESTARTS   AGE
details-v1-6bfd8cbcdb-q2l5p       2/2     Running   0          6m1s
productpage-v1-774bdff86b-znsz4   2/2     Running   0          6m1s
ratings-v1-75fb8f8646-jpggg       2/2     Running   0          6m4s
reviews-v1-5d89df7d4b-nndfh       2/2     Running   0          6m4s
reviews-v2-f47f8b6d8-mvn98        2/2     Running   0          6m1s
reviews-v3-65b7f987b6-48jwv       2/2     Running   0          6m1s
```

- Then, we will verify the gateway and virtualservice.

```
kubectl get gateway -n demo
NAME               AGE
bookinfo-gateway   108s
kubectl get virtualservice -n demo
NAME       GATEWAYS             HOSTS   AGE
bookinfo   [bookinfo-gateway]   [*]     112s
```

You can see that all the pods have a istio proxy attached. You can also check this from Rafay console -> cluster resources

---

## Recap

Congratulations! You successfully deployed an application with istio sidecar injection.
