As discussed in this article, Istio is simply an implementation of the service mesh paradigm or pattern as may be called. Recall what a service mesh is: it is simply a means of managing network traffic between services in an application.
An Istio Service Mesh is logically split into two components as explained earlier in this article:
The diagram below shows the Istio Service Mesh architecture:
To understand more of these Istio core components you can read all of that through this link.
In order to proceed in this article/hands-on demo, below are the requirements:
Before we go any further let’s get to understand what each of these tools are:
“Docker is basically an open-source platform used to containerize applications.”
“This is a tool that let’s users run kubernetes on their local machines. Minikube runs a single-node kubernetes cluster on your personal computer, in order to perform development related work.
This creates a VM on your local machine and runs docker containers inside of that virtual machine. Those docker containers are contained inside of the smallest execution unit in kubernetes called “pods”.
This is the kubernetes command-line tool which allows users to run commands such as deploying applications, inspecting and managing kubernetes clusters and their resources etc.
You must have the above requirements set up in your local machine in order to follow along properly. Links to tutorials to set up the requirements above have been dropped. Do kindly follow them if you don’t have any of the requirements installed.
Now that you have gotten the above set up, let’s get started! A Linux machine will be used for this hands-on demo.
curl -L https://istio.io/downloadIstio | sh –
As of the time of writing this article, the version of istio is 1.11.3.
Once your download is completed, the following should be displayed on your terminal:
Now that you have Istio downloaded on your local machine, let’s go ahead and “CD” into the downloaded package directory and add the Istioctl (Istio command utility) client to our OS path. In order to do all of the above mentioned, we perform the following commands below:
cd istio-1.11.3
export PATH=$PWD/bin:$PATH
Alright, we have successfully added the Istio command utility (istioctl) into our OS path. Let’s go ahead and install Istio on our local machine.
Let’s go ahead and start up minikube with specific resources and also install Istio with the following commands:
minikube start — cpus 4 — memory 4096
istioctl install
Finally, Istio has been installed on our local machine. Let’s go ahead and add a namespace label (Away or scope of organizing pods, services, and deployments in clusters) to instruct Istio to automatically inject Envoy sidecar proxies to each service that will be deployed shortly. In order to add the namespace label we can perform the following command:
kubectl label namespace default istio-injection=enabled
The output would be:
namespace/default labeled
That is to indicate that the namespace label has been added and an envoy proxy will be added to each service in deployment.
The application provided by Istio, is a demo or sample application for testing or getting to grips with Istio services. Let’s go ahead and use that.
This application’s manifest file is located inside of the istio folder “istio-1.11.3” we downloaded earlier. Without further-ado let’s “cd” into the “istio-1.11.3” folder and perform the following commands below:
kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml
Once the command above has been performed, this should be the desired output:
The application’s manifest file “bookinfo.yaml” has been applied and corresponding services defined in the manifest file, have been pulled from docker, then created and deployed. As each kubernetes pod gets ready, each service instance is deployed with an Envoy proxy or Istio sidecar.
kubectl get pods
Run the above command from time to time in order to check if the pods are up an running.
Immediately after the “bookinfo.yaml” file has been applied, the images and settings configured inside of the manifest file were pulled and deployed respectively.
minikube dashboard
Shortly after the above command has been implemented, a browser tab opens displaying the Kubernetes dashboard with all details and functions pertaining to Kubernetes.
Finally our pods containing different services with envoy proxies have been deployed, but unfortunately we cannot access the application from the outside. Let’s go ahead and configure Istio to allow the application to be accessible from the outside by creating an Istio Ingress Gateway. (Ingress meaning “Entrance”).
In order to link up an Istio gateway to our application we need to apply the manifest file containing configurations for this gateway. We do that by changing directories or “cd” into the “istio-1.11.3” folder on our terminal, and performing the following command:
kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml
The image above displays the configurations for the Istio gateway that have been created and deployed into the cluster.
kubectl get gateway
Before we get to linking up our application with the gateway, let’s get the IP address of the minikube instance currently running. We do that by performing the following command:
minikube ip
The output would be:
192.168.99.107
Above is the IP address of my minikube instance. The address is needed so we can link up the application with the gateway by way of setting up the “ingress IP” and “ingress ports”.
Let’s now go ahead and link up our gateway with the application that is currently running so we can access it from the outside.
export INGRESS_HOST=$(minikube ip)
export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath=’{.spec.ports[?(@.name==”http2″)].nodePort}’)
export SECURE_INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath=’{.spec.ports[?(@.name==”https”)].nodePort}’)
export GATEWAY_URL=$INGRESS_HOST:$INGRESS_PORT
printenv GATEWAY_URL
The output would be:
192.168.99.107:30330
<GATEWAY_URL>/productpage
Finally the application is up and running! and can be accessible via the browser. Now you have made your first Istio deployment.
If you wish to stop the minikube instance you can run the following command:
minikube stop
Otherwise if you wish to delete the sample application and its configurations, we perform the following commands:
istioctl manifest generate — set profile=demo | kubectl delete — ignore-not-found=true -f –
kubectl delete namespace istio-system
kubectl label namespace default istio-injection-
You have successfully implemented Istio in a microservice application, you now understand basically how a service mesh works in a practical sense. Now the rest is up to you to study more and practice more. Cheers on your learning journey!
2018, Cryptoland Theme by Artureanec - Ninetheme