copyright | lastupdated | ||
---|---|---|---|
|
2018-11-13 |
{:new_window: target="_blank"} {:shortdesc: .shortdesc} {:screen: .screen} {:pre: .pre} {:table: .aria-labeledby="caption"} {:codeblock: .codeblock} {:tip: .tip} {:note: .note} {:important: .important} {:deprecated: .deprecated} {:download: .download}
{: #istio_tutorial}
Istio is an open platform to connect, secure, control, and observe services on cloud platforms such as Kubernetes in {{site.data.keyword.containerlong}}. With Istio, you can manage network traffic, load balance across microservices, enforce access policies, verify service identity, and more. {:shortdesc}
In this tutorial, you can see how to install Istio alongside four microservices for a simple mock bookstore app called BookInfo. The microservices include a product web page, book details, reviews, and ratings. When you deploy BookInfo's microservices into an {{site.data.keyword.containerlong}} cluster where Istio is installed, you inject the Istio Envoy sidecar proxies in the pods of each microservice.
- Deploy the Istio Helm chart in your cluster
- Deploy the BookInfo sample app
- Verify the BookInfo app deployment and round robin through the three versions of the ratings service
30 minutes
This tutorial is intended for software developers and network administrators who are using Istio for the first time.
- Install the IBM Cloud CLI, the {{site.data.keyword.containerlong_notm}} plug-in, and the Kubernetes CLI. Istio requires the Kubernetes version 1.9 or higher. Make sure to install the
kubectl
CLI version that matches the Kubernetes version of your cluster. - Create a cluster that runs Kubernetes version 1.9 or later, or update an existing cluster to version 1.9 or later.
- Target the CLI to your cluster.
{: #istio_tutorial1}
Download and install Istio in your cluster. {:shortdesc}
-
Install Istio by using the IBM Istio Helm chart .
- Set up Helm in your cluster and add the
ibm-charts
repository to your Helm instance. - For Helm versions 2.9 or earlier only: Install Istio’s custom resource definitions.
{: pre}
kubectl apply -f https://raw.githubusercontent.com/IBM/charts/master/stable/ibm-istio/templates/crds.yaml
- Install the Helm chart to your cluster.
{: pre}
helm install ibm-charts/ibm-istio --name=istio --namespace istio-system
- Set up Helm in your cluster and add the
-
Ensure the pods for the 9 Istio services and the pod for Prometheus are all fully deployed before you continue.
kubectl get pods -n istio-system
{: pre}
NAME READY STATUS RESTARTS AGE istio-citadel-748d656b-pj9bw 1/1 Running 0 2m istio-egressgateway-6c65d7c98d-l54kg 1/1 Running 0 2m istio-galley-65cfbc6fd7-bpnqx 1/1 Running 0 2m istio-ingressgateway-f8dd85989-6w6nj 1/1 Running 0 2m istio-pilot-5fd885964b-l4df6 2/2 Running 0 2m istio-policy-56f4f4cbbd-2z2bk 2/2 Running 0 2m istio-sidecar-injector-646655c8cd-rwvsx 1/1 Running 0 2m istio-statsd-prom-bridge-7fdbbf769-8k42l 1/1 Running 0 2m istio-telemetry-8687d9d745-mwjbf 2/2 Running 0 2m prometheus-55c7c698d6-f4drj 1/1 Running 0 2m
{: screen}
Good work! You successfully installed Istio into your cluster. Next, deploy the BookInfo sample app into your cluster.
{: #istio_tutorial2}
Deploy the BookInfo sample app's microservices to your Kubernetes cluster. {:shortdesc}
These four microservices include a product web page, book details, reviews (with several versions of the review microservice), and ratings. When you deploy BookInfo, Envoy sidecar proxies are injected as containers into your app microservices' pods before the microservice pods are deployed. Istio uses an extended version of the Envoy proxy to mediate all inbound and outbound traffic for all microservices in the service mesh. For more about Envoy, see the Istio documentation .
-
Download the Istio package containing the necessary BookInfo files.
-
Either download Istio directly from https://github.com/istio/istio/releases and extract the installation files, or get the latest version by using cURL:
curl -L https://git.io/getLatestIstio | sh -
{: pre}
-
Change the directory to the Istio file location.
cd <filepath>/istio-1.0
{: pre}
-
Add the
istioctl
client to your PATH. For example, run the following command on a MacOS or Linux system:export PATH=$PWD/istio-1.0/bin:$PATH
{: pre}
-
-
Label the
default
namespace withistio-injection=enabled
.kubectl label namespace default istio-injection=enabled
{: pre}
-
Deploy the BookInfo app. When the app microservices deploy, the Envoy sidecar is also deployed in each microservice pod.
kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml
{: pre}
-
Ensure that the microservices and their corresponding pods are deployed:
kubectl get svc
{: pre}
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE details ClusterIP 172.21.19.104 <none> 9080/TCP 1m productpage ClusterIP 172.21.168.196 <none> 9080/TCP 1m ratings ClusterIP 172.21.11.131 <none> 9080/TCP 1m reviews ClusterIP 172.21.117.164 <none> 9080/TCP 1m
{: screen}
kubectl get pods
{: pre}
NAME READY STATUS RESTARTS AGE details-v1-6865b9b99d-7v9h8 2/2 Running 0 2m productpage-v1-f8c8fb8-tbsz9 2/2 Running 0 2m ratings-v1-77f657f55d-png6j 2/2 Running 0 2m reviews-v1-6b7f6db5c5-fdmbq 2/2 Running 0 2m reviews-v2-7ff5966b99-zflkv 2/2 Running 0 2m reviews-v3-5df889bcff-nlmjp 2/2 Running 0 2m
{: screen}
-
To verify the app deployment, get the public address for your cluster.
-
Standard clusters:
-
To expose your app on a public ingress IP, deploy the BookInfo gateway.
kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml
{: pre}
-
Set the ingress host.
export INGRESS_HOST=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
{: pre}
-
Set the ingress port.
export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].port}')
{: pre}
-
Create a
GATEWAY_URL
environment variable that uses the ingress host and port.export GATEWAY_URL=$INGRESS_HOST:$INGRESS_PORT
{: pre}
-
-
Free clusters:
-
Get the public IP address of any worker node in your cluster.
ibmcloud ks workers <cluster_name_or_ID>
{: pre}
-
Create a GATEWAY_URL environment variable that uses the public IP address of the worker node.
export GATEWAY_URL=<worker_node_public_IP>:$(kubectl get svc istio-ingressgateway -n istio-system -o jsonpath='{.spec.ports[0].nodePort}')
{: pre}
-
-
-
Curl the
GATEWAY_URL
variable to check that the BookInfo app is running. A200
response means that the BookInfo app is running properly with Istio.curl -o /dev/null -s -w "%{http_code}\n" http://${GATEWAY_URL}/productpage
{: pre}
-
View the BookInfo web page in a browser.
For Mac OS or Linux:
open http://$GATEWAY_URL/productpage
{: pre}
For Windows:
start http://$GATEWAY_URL/productpage
{: pre}
-
Try refreshing the page several times. Different versions of the reviews section round robin through red stars, black stars, and no stars.
Good work! You successfully deployed the BookInfo sample app with Istio Envoy sidecars. Next, you can clean up your resources or continue with more tutorials to explore Istio further.
{: #istio_tutorial_cleanup}
If you're finished working with Istio and don't want to continue exploring, then you can clean up the Istio resources in your cluster. {:shortdesc}
-
Delete all BookInfo services, pods, and deployments in the cluster.
samples/bookinfo/platform/kube/cleanup.sh
{: pre}
-
Uninstall the Istio Helm deployment.
helm del istio --purge
{: pre}
-
If you used Helm 2.9 or earlier:
- Delete the extra job resource.
kubectl -n istio-system delete job --all
{: pre} 2. Optional: Delete the Istio custom resource definitions.
kubectl delete -f https://raw.githubusercontent.com/IBM/charts/master/stable/ibm-istio/templates/crds.yaml
{: pre}
{: #istio_tutorial_whatsnext}
- Looking to expose your app with both {{site.data.keyword.containerlong_notm}} and Istio? Learn how to connect the {{site.data.keyword.containerlong_notm}} Ingress ALB and an Istio Gateway in this blog post .
- To explore Istio further, you can find more guides in the Istio documentation .
- Intelligent Routing : This example shows how to route traffic to a specific version of BookInfo's reviews and ratings microservices by using Istio's traffic management capabilities.
- In-Depth Telemetry : This example includes how to get uniform metrics, logs, and traces across BookInfo's microservices by using Istio Mixer and the Envoy proxy.
- Take the Cognitive Class: Getting started with Microservices with Istio and IBM Cloud Kubernetes Service . Note: You can skip the Istio installation section of this course.
- Check out this blog post on using Vistio to visualize your Istio service mesh.