{"id":812,"date":"2018-12-01T15:10:34","date_gmt":"2018-12-01T15:10:34","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw93\/?p=812"},"modified":"2018-12-06T23:27:15","modified_gmt":"2018-12-06T23:27:15","slug":"microservices-made-easier-using-istio","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw93\/index.php\/2018\/12\/01\/microservices-made-easier-using-istio\/","title":{"rendered":"Microservices Made Easier Using Istio"},"content":{"rendered":"<p>&nbsp;<\/p>\n<h5>Expert Training in Kubernetes and Rancher<\/h5>\n<p>Join our free online training sessions to learn how to manage Kubernetes workloads with Rancher.<\/p>\n<p><a href=\"https:\/\/rancher.com\/training\/\" target=\"blank\">Sign up here<\/a><\/p>\n<p>Update: This tutorial on Istio was updated for Rancher 2.0 <a href=\"https:\/\/rancher.com\/blog\/2018\/2018-07-31-deploying-istio\/\">here<\/a>.<\/p>\n<p>One of the recent open source initiatives that has caught our interest<br \/>\nat Rancher Labs is <a href=\"https:\/\/istio.io\/\"><em>Istio<\/em><\/a>, the micro-services<br \/>\ndevelopment framework. It\u2019s a great technology, combining some of the<br \/>\nlatest ideas in distributed services architecture in an easy-to-use<br \/>\nabstraction. Istio does several things for you. Sometimes referred to as<br \/>\na \u201cservice mesh\u201c, it has facilities for API<br \/>\nauthentication\/authorization, service routing, service discovery,<br \/>\nrequest monitoring, request rate-limiting, and more. It\u2019s made up of a<br \/>\nfew modular components that can be consumed separately or as a whole.<br \/>\nSome of the concepts such as \u201ccircuit breakers\u201d are so sensible I<br \/>\nwonder how we ever got by without them.<\/p>\n<p><a href=\"http:\/\/microservices.io\/patterns\/reliability\/circuit-breaker.html\">Circuit breakers<\/a><br \/>\nare a solution to the problem where a service fails and incoming<br \/>\nrequests cannot be handled. This causes the dependent services making<br \/>\nthose calls to exhaust all their connections\/resources, either waiting<br \/>\nfor connections to timeout or allocating memory\/threads to create new<br \/>\nones. The circuit breaker protects the dependent services by<br \/>\n\u201ctripping\u201d when there are too many failures in a some interval of<br \/>\ntime, and then only after some cool-down period, allowing some<br \/>\nconnections to retry (effectively testing the waters to see if the<br \/>\nupstream service is ready to handle normal traffic again).<\/p>\n<p>Istio is<br \/>\nbuilt with <a href=\"https:\/\/kubernetes.io\/\">Kubernetes<\/a> in mind. Kubernetes is a<br \/>\ngreat foundation as it\u2019s one of the fastest growing platforms for<br \/>\nrunning container systems, and has extensive community support as well<br \/>\nas a wide variety of tools. Kubernetes is also built for scale, giving<br \/>\nyou a foundation that can grow with your application.<\/p>\n<h2>Deploying Istio with Helm<\/h2>\n<p>Rancher includes and enterprise Kubernetes distribution makes it easy to<br \/>\nrun Istio. First, fire up a Kubernetes environment on Rancher (watch<br \/>\nthis<br \/>\n<a href=\"https:\/\/www.youtube.com\/watch?v=kbsbZHCNfrg&amp;index=2&amp;list=PLfAoTEAPazb6s78XUwSn9VOV5vZ-M5TSC\">demo<\/a><br \/>\nor see our <a href=\"http:\/\/rancher.com\/docs\/rancher\/latest\/en\/quick-start-guide\/\">quickstart<br \/>\nguide<\/a> for<br \/>\nhelp). Next, use the helm chart from the Kubernetes Incubator for<br \/>\ndeploying Istio to start the framework\u2019s components. You\u2019ll need to<br \/>\ninstall helm, which you can do by following <a href=\"https:\/\/github.com\/kubernetes\/helm\/blob\/master\/docs\/install.md\">this<br \/>\nguide<\/a>.<br \/>\nOnce you have helm installed, you can add the helm chart repo from<br \/>\nGoogle to your helm client:<\/p>\n<p>helm repo add incubator http:\/\/storage.googleapis.com\/kubernetes-charts-incubator<\/p>\n<p>Then you can simply run:<\/p>\n<p>helm install -n istio incubator\/istio<\/p>\n<p><a href=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2017\/08\/23130416\/istio-microservices.png\"><img decoding=\"async\" src=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2017\/08\/23130416\/istio-microservices-1024x612.png\" alt=\"\" \/><\/a><br \/>\nA view in kube dash of the microservices that makeup Istio<br \/>\nThis will deploy a few micro-services that provide the functionality of<br \/>\nIstio. Istio gives you a framework for exchanging messages between<br \/>\nservices. The advantage of using it over building your own is you don\u2019t<br \/>\nhave to implement as much \u201cboiler-plate\u201d code before actually writing<br \/>\nthe business logic of your application. For instance, do you need to<br \/>\nimplement auth or ACLs between services? It\u2019s quite possible that your<br \/>\nneeds are the same as most other developers trying to do the same, and<br \/>\nIstio offers a well-written solution that just works. Its also has a<br \/>\ncommunity of developers whose focus is to make this one thing work<br \/>\nreally well, and as you build your application around this framework, it<br \/>\nwill continue to benefit from this innovation with minimal effort on<br \/>\nyour part.<\/p>\n<h2>Deploying an Istio Application<\/h2>\n<p>OK, so lets try this thing out. So far all we have is plumbing. To<br \/>\nactually see it do something you\u2019ll want to deploy an Istio<br \/>\napplication. The Istio team have put together a nice sample application<br \/>\nthey call \u201d<a href=\"https:\/\/istio.io\/docs\/samples\/bookinfo.html\">BookInfo<\/a>\u201d to<br \/>\ndemonstrate how it works. To work with Istio applications we\u2019ll need<br \/>\ntwo things: the Istio command line client, istioctl, and the Istio<br \/>\napplication templates. The istioctl client works in conjunction with<br \/>\nkubectl to deploy Istio applications. In this basic example,<br \/>\nistioctl serves as a preprocessor for kubectl, so we can dynamically<br \/>\ninject information that is particular to our Istio deployment.<br \/>\nTherefore, in many ways, you are working with normal Kubernetes resource<br \/>\nYAML files, just with some hooks where special Istio stuff can be<br \/>\ninjected. To make it easier to get started, you can get both istioctl<br \/>\nand the needed application templates from this repo:<br \/>\n<a href=\"https:\/\/github.com\/wjimenez5271\/rancher-istio\">https:\/\/github.com\/wjimenez5271\/rancher-istio<\/a>. Just clone it on your<br \/>\nlocal machine. This also assumes you have kubectl installed and<br \/>\nconfigured. If you need help installing that <a href=\"http:\/\/rancher.com\/docs\/rancher\/v1.6\/en\/kubernetes\/#kubectl\">see our<br \/>\ndocs.<\/a> Now<br \/>\nthat you\u2019ve cloned the above repo, \u201ccd\u201d into the directory and run:<\/p>\n<p>kubectl apply -f &lt;(istioctl kube-inject -f samples\/apps\/bookinfo\/bookinfo.yaml)<\/p>\n<p>This deploys the kubernetes resources using kubectl while injecting some<br \/>\nistio specific values. It will deploy new services to K8 that will serve<br \/>\nthe \u201cBookInfo\u201d application, but it will leverage the Istio services<br \/>\nwe\u2019ve already deployed. Once the BookInfo services finish deploying we<br \/>\nshould be able to view the UI of the web app. We\u2019ll need to get the<br \/>\naddress first, we can do that by running<\/p>\n<p>kubectl get services istio-ingress -o wide<\/p>\n<p>This should show you the IP address of the istio ingress (under the<br \/>\nEXTERNAL-IP column). We\u2019ll use this IP address to construct the URL to<br \/>\naccess the application. For example, my output with my local Rancher<br \/>\ninstall looks like: <a href=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2017\/08\/23131711\/example-kubectl-output-getservices.png\"><img decoding=\"async\" src=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2017\/08\/23131711\/example-kubectl-output-getservices.png\" alt=\"\" \/><\/a><br \/>\nExample output of kubectl get services istio-ingress -o wide<br \/>\nThe istio ingress is shared amongst your applications, and routes to the<br \/>\ncorrect service based on a URI pattern. Our application route is at<br \/>\n\/productpage so our request URL would be:<\/p>\n<p>http:\/\/$EXTERNAL_IP\/productpage<\/p>\n<p>Try loading that in your browser. If everything worked you should see<br \/>\na page like this: <a href=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2017\/08\/23130532\/bookinfo-istio-app.png\"><img decoding=\"async\" src=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2017\/08\/23130532\/bookinfo-istio-app-1024x452.png\" alt=\"\" \/><\/a><br \/>\nSample application \u201cBookInfo\u201c, built on Istio<\/p>\n<h2>Built-in metrics system<\/h2>\n<p>Now that we\u2019ve got our application working we can check out the built<br \/>\nin metrics system to see how its behaving. As you can see, Istio has<br \/>\ninstrumented our transactions automatically just by using their<br \/>\nframework. Its using the Prometheus metrics collection engine, but they<br \/>\nset it up for you out of the box. We can visualize the metrics using<br \/>\nGrafana. Using the helm chart in this article, accessing the endpoint of<br \/>\nthe Grafana pod will require setting up a local kubectl port forward<br \/>\nrule:<\/p>\n<p>export POD_NAME=$(kubectl get pods &#8211;namespace default -l &#8220;component=istio-istio-grafana&#8221; -o jsonpath=&#8221;{.items[0].metadata.name}&#8221;)<\/p>\n<p>kubectl port-forward $POD_NAME 3000:3000 &#8211;namespace default<\/p>\n<p>You can then access Grafana at:<br \/>\n<a href=\"http:\/\/127.0.0.1:3000\/dashboard\/db\/istio-dashboard\">http:\/\/127.0.0.1:3000\/dashboard\/db\/istio-dashboard<\/a> <a href=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2017\/08\/23130627\/grafana-dash.png\"><img decoding=\"async\" src=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2017\/08\/23130627\/grafana-dash-1024x572.png\" alt=\"\" \/><\/a><br \/>\nThe Grafana Dashboard with the included Istio template that highlights<br \/>\nuseful metrics Have you developed something cool with Istio<br \/>\non Rancher? If so, we\u2019d love to hear about it. Feel free to drop us a<br \/>\nline on twitter <a href=\"https:\/\/twitter.com\/rancher_labs\">@Rancher_Labs<\/a>, or<br \/>\non our user slack.<\/p>\n<p><a href=\"https:\/\/rancher.com\/microservices-made-easier-using-istio\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Expert Training in Kubernetes and Rancher Join our free online training sessions to learn how to manage Kubernetes workloads with Rancher. Sign up here Update: This tutorial on Istio was updated for Rancher 2.0 here. One of the recent open source initiatives that has caught our interest at Rancher Labs is Istio, the micro-services &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw93\/index.php\/2018\/12\/01\/microservices-made-easier-using-istio\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Microservices Made Easier Using Istio&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-812","post","type-post","status-publish","format-standard","hentry","category-kubernetes"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts\/812","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/comments?post=812"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts\/812\/revisions"}],"predecessor-version":[{"id":853,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts\/812\/revisions\/853"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/media?parent=812"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/categories?post=812"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/tags?post=812"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}