istio.io/archive/v0.1/docs/samples/bookinfo.html

35 lines
16 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html><html lang="en" itemscope itemtype="https://schema.org/WebPage" style="overflow-y: scroll;"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="title" content="BookInfo"><meta name="og:title" content="BookInfo"><meta name="og:image" content="/v0.1/img/logo.png"/><meta name="description" content="This sample deploys a simple application composed of four separate microservices which will be used to demonstrate various features of the Istio service mesh."><meta name="og:description" content="This sample deploys a simple application composed of four separate microservices which will be used to demonstrate various features of the Istio service mesh."><title>Istioldie 0.1 / BookInfo</title><script> window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date; ga('create', 'UA-98480406-2', 'auto'); ga('send', 'pageview'); </script> <script async src='https://www.google-analytics.com/analytics.js'></script><link href='https://fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,400italic,500,500italic,700,700italic,900,900italic' rel='stylesheet' type='text/css'><link rel="alternate" type="application/rss+xml" title="Istio Blog RSS" href="/v0.1/feed.xml"><link rel="apple-touch-icon" href="/v0.1/favicons/apple-touch-icon.png" sizes="180x180"><link rel="icon" type="image/png" href="/v0.1/favicons/android-chrome-96x96.png" sizes="96x96" ><link rel="icon" type="image/png" href="/v0.1/favicons/favicon-32x32.png" sizes="32x32"><link rel="icon" type="image/png" href="/v0.1/favicons/favicon-16x16.png" sizes="16x16"><link rel="manifest" href="/v0.1/favicons/manifest.json"><link rel="mask-icon" href="/v0.1/favicons/safari-pinned-tab.svg" color="#2DA6B0"><meta name="msapplication-TileColor" content="#ffffff"><meta name="msapplication-TileImage" content="/v0.1/favicons/mstile-150x150.png"><link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet"><link rel="stylesheet" href="/v0.1/css/all.css"><link rel="stylesheet" href="/v0.1/css/prism.css"><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script></head><body class="language-unknown"><div class="nav-hero-container" style="z-index: 200000;"><nav id="header-nav" class="navbar navbar-inverse" role="navigation"><div class="container"><div class="row"><div class="col-md-11 nofloat center-block "><div class="navbar-header"> <button type="button" class="hamburger navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse-1" aria-expanded="false"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="/v0.1/"><div> <img src="/v0.1/img/logo.png" alt="Istio" width="36px" height="54px"/> <span class="brand-name">Istioldie 0.1</span></div></a></div><div class="collapse navbar-collapse" id="navbar-collapse-1"><ul class="nav navbar-nav navbar-right"><li><a href="/v0.1/about/" >About</a></li><li><a href="/v0.1/docs/" class='current'>Docs</a></li><li><a href="/v0.1/blog/" >Blog</a></li><li><a href="/v0.1/community/" >Community</a></li><li><a href="/v0.1/faq/" >FAQ</a></li><li class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" href=""> <i class='fa fa-lg fa-cog'></i> <span class="caret"></span> </a><ul class="dropdown-menu"><h6 class="dropdown-header">Other versions of this site</h6><li> <a href="https://istio.io">Current Release</a></li><li> <a href="https://preliminary.istio.io">Next Release</a></li><li> <a href="https://archive.istio.io">Older Releases</a></li></ul></li><li><form name="cse" id="searchbox_demo" class="navbar-form navbar-right" role="search"> <input type="hidden" name="cx" value="013699703217164175118:iwwf17ikgf4" /> <input type="hidden" name="ie" value="utf-8" /> <input type="hidden" name="hl" value="en" /><div class="form-group"><div class="input-group"> <input name="q" class="form-control" type="text" size="30" /><div class="input-group-addon"> <span class="btn-search glyphicon glyphicon-search"></span></div></div></div></form> <script type="text/javascript" src="https://www.google.com/cse/brand?form=searchbox_demo"></script></li></ul></div></div></div></div></nav></div><div class="container"><div class="row"><div class="col-md-11 nofloat center-block" style="margin-top: 3px;"><ul class="col-sm-10 nav nav-tabs"><li role="presentation" ><a href="/v0.1/docs/index.html">Welcome</a></li><li role="presentation" ><a href="/v0.1/docs/concepts/index.html">Concepts</a></li><li role="presentation" ><a href="/v0.1/docs/tasks/index.html">Tasks</a></li><li role="presentation" class='active'><a href="/v0.1/docs/samples/index.html">Samples</a></li><li role="presentation" ><a href="/v0.1/docs/reference/index.html">Reference</a></li></ul></div></div></div><script src="/v0.1/js/navtree.js"></script><div class="container docs"><div class="row"><div class="col-md-11 nofloat center-block"><div class="row"><div id="sidebar-container" class="col-sm-3"><ul class="doc-side-nav"><li><h5 class='doc-side-nav-title'>Samples</h5></li><script type="text/javascript"> var docs = []; docs.push({path: [ "bookinfo.md", ], url: "/docs/samples/bookinfo.html", title: "BookInfo", order: 10, overview: "This sample deploys a simple application composed of four separate microservices which will be used to demonstrate various features of the Istio service mesh."}); docs.push({path: [ "index.md", ], url: "/docs/samples/index.html", title: "Samples", order: 30, overview: "Samples include a variety of fully working example uses for Istio that you can experiment with."}); genNavBarTree(docs) </script></ul></div><div id="tab-container" class="col-xs-1 tab-neg-margin pull-left"> <a id="sidebar-tab" class="glyphicon glyphicon-chevron-left" href="javascript:void 0;"></a></div><div id="content-container" class="thin-left-border col-sm-9 markdown"><div id="toc" class="toc"></div><div id="doc-content"><h1>BookInfo</h1><p>This sample deploys a simple application composed of four separate microservices which will be used to demonstrate various features of the Istio service mesh.</p><h2 id="before-you-begin">Before you begin</h2><ul><li><p>If you use GKE, please ensure your cluster has at least 4 standard GKE nodes.</p></li><li><p>Setup Istio by following the instructions in the <a href="/v0.1/docs/tasks/installing-istio.html">Installation guide</a>.</p></li></ul><h2 id="overview">Overview</h2><p>In this sample we will deploy a simple application that displays information about a book, similar to a single catalog entry of an online book store. Displayed on the page is a description of the book, book details (ISBN, number of pages, and so on), and a few book reviews.</p><p>The BookInfo application is broken into four separate microservices:</p><ul><li><em>productpage</em>. The productpage microservice calls the <em>details</em> and <em>reviews</em> microservices to populate the page.</li><li><em>details</em>. The details microservice contains book information.</li><li><em>reviews</em>. The reviews microservice contains book reviews. It also calls the <em>ratings</em> microservice.</li><li><em>ratings</em>. The ratings microservice contains book ranking information that accompanies a book review.</li></ul><p>There are 3 versions of the reviews microservice:</p><ul><li>Version v1 doesnt call the ratings service.</li><li>Version v2 calls the ratings service, and displays each rating as 1 to 5 black stars.</li><li>Version v3 calls the ratings service, and displays each rating as 1 to 5 red stars.</li></ul><p>The end-to-end architecture of the application is shown below.</p><figure><img src="./img/bookinfo/noistio.svg" alt="BookInfo Application without Istio" title="BookInfo Application without Istio" /><figcaption>BookInfo Application without Istio</figcaption></figure><p>This application is polyglot, i.e., the microservices are written in different languages.</p><h2 id="start-the-application">Start the application</h2><ol><li><p>Change directory to the root of the Istio installation directory.</p></li><li><p>Bring up the application containers:</p><pre><code class="language-bash">kubectl apply -f &lt;(istioctl kube-inject -f samples/apps/bookinfo/bookinfo.yaml)
</code></pre><p>The above command launches four microservices and creates the gateway ingress resource as illustrated in the diagram below. The reviews microservice has 3 versions: v1, v2, and v3.</p><blockquote><p>Note that in a realistic deployment, new versions of a microservice are deployed over time instead of deploying all versions simultaneously.</p></blockquote><p>Notice that the <code>istioctl kube-inject</code> command is used to modify the <code>bookinfo.yaml</code> file before creating the deployments. This injects Envoy into Kubernetes resources as documented <a href="/v0.1/docs/reference/commands/istioctl.html#istioctl-kube-inject">here</a>. Consequently, all of the microservices are now packaged with an Envoy sidecar that manages incoming and outgoing calls for the service. The updated diagram looks like this:</p><figure><img src="./img/bookinfo/withistio.svg" alt="BookInfo Application" title="BookInfo Application" /><figcaption>BookInfo Application</figcaption></figure></li><li><p>Confirm all services and pods are correctly defined and running:</p><pre><code class="language-bash">kubectl get services
</code></pre><p>which produces the following output:</p><pre><code class="language-bash">NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
details 10.0.0.31 &lt;none&gt; 9080/TCP 6m
istio-ingress 10.0.0.122 &lt;pending&gt; 80:31565/TCP 8m
istio-pilot 10.0.0.189 &lt;none&gt; 8080/TCP 8m
istio-mixer 10.0.0.132 &lt;none&gt; 9091/TCP,42422/TCP 8m
kubernetes 10.0.0.1 &lt;none&gt; 443/TCP 14d
productpage 10.0.0.120 &lt;none&gt; 9080/TCP 6m
ratings 10.0.0.15 &lt;none&gt; 9080/TCP 6m
reviews 10.0.0.170 &lt;none&gt; 9080/TCP 6m
</code></pre><p>and</p><pre><code class="language-bash">kubectl get pods
</code></pre><p>which produces</p><pre><code class="language-bash">NAME READY STATUS RESTARTS AGE
details-v1-1520924117-48z17 2/2 Running 0 6m
istio-ingress-3181829929-xrrk5 1/1 Running 0 8m
istio-pilot-175173354-d6jm7 2/2 Running 0 8m
istio-mixer-3883863574-jt09j 2/2 Running 0 8m
productpage-v1-560495357-jk1lz 2/2 Running 0 6m
ratings-v1-734492171-rnr5l 2/2 Running 0 6m
reviews-v1-874083890-f0qf0 2/2 Running 0 6m
reviews-v2-1343845940-b34q5 2/2 Running 0 6m
reviews-v3-1813607990-8ch52 2/2 Running 0 6m
</code></pre></li><li><p>Determine the gateway ingress URL:</p><pre><code class="language-bash">kubectl get ingress -o wide
</code></pre><pre><code class="language-bash">NAME HOSTS ADDRESS PORTS AGE
gateway * 130.211.10.121 80 1d
</code></pre><p>If your Kubernetes cluster is running in an environment that supports external load balancers, and the Istio ingress service was able to obtain an External IP, the ingress resource ADDRESS will be equal to the ingress service external IP.</p><pre><code class="language-bash">export GATEWAY_URL=130.211.10.121:80
</code></pre><blockquote><p>Sometimes when the service is unable to obtain an external IP, the ingress ADDRESS may display a list of NodePort addresses. In this case, you can use any of the addresses, along with the NodePort, to access the ingress. If, however, the cluster has a firewall, you will also need to create a firewall rule to allow TCP traffic to the NodePort. In GKE, for instance, you can create a firewall rule using the following command:</p><pre><code class="language-bash">gcloud compute firewall-rules create allow-book --allow tcp:$(kubectl get svc istio-ingress -o jsonpath='{.spec.ports[0].nodePort}')
</code></pre></blockquote><p>If your deployment environment does not support external load balancers (e.g., minikube), the ADDRESS field will be empty. In this case you can use the service NodePort instead:</p><pre><code class="language-bash">export GATEWAY_URL=$(kubectl get po -l istio=ingress -o 'jsonpath={.items[0].status.hostIP}'):$(kubectl get svc istio-ingress -o 'jsonpath={.spec.ports[0].nodePort}')
</code></pre></li><li><p>Confirm that the BookInfo application is running with the following <code>curl</code> command:</p><pre><code class="language-bash">curl -o /dev/null -s -w "%{http_code}\n" http://${GATEWAY_URL}/productpage
</code></pre><pre><code class="language-bash">200
</code></pre></li></ol><h2 id="cleanup">Cleanup</h2><p>When youre finished experimenting with the BookInfo sample, you can uninstall it as follows:</p><ol><li><p>Delete the routing rules and terminate the application pods</p><pre><code class="language-bash">samples/apps/bookinfo/cleanup.sh
</code></pre></li><li><p>Confirm shutdown</p><pre><code class="language-bash">istioctl get route-rules #-- there should be no more routing rules
kubectl get pods #-- the BookInfo pods should be deleted
</code></pre></li></ol><h2 id="whats-next">Whats next</h2><p>Now that you have the BookInfo sample up and running, you can point your browser to <code>http://$GATEWAY_URL/productpage</code> to see the running application and use Istio to control traffic routing, inject faults, rate limit services, etc..</p><p>To get started, check out the <a href="/v0.1/docs/tasks/request-routing.html">request routing task</a>.</p></div></div></div></div></div></div><script src="/v0.1/js/sidemenu.js"></script><footer><div class="container"><div class="row"><div class="col-md-2"></div><div class="col-md-3 col-sm-4 col-xs-12 center-block"><ul class="toggle"><p class="header">Docs</p><li><a href="/v0.1/docs/">Welcome</a></li><li><a href="/v0.1/docs/concepts">Concepts</a></li><li><a href="/v0.1/docs/tasks">Tasks</a></li><li><a href="/v0.1/docs/samples">Samples</a></li><li><a href="/v0.1/docs/reference">Reference</a></li></ul></div><hr class="footer-sections" /><div class="col-md-3 col-sm-4 col-xs-12 center-block"><ul class="toggle"><p class="header">Resources</p><li><a href="/v0.1/faq">Frequently Asked Questions</a></li><li><a href="/v0.1/troubleshooting">Troubleshooting Guide</a></li><li><a href="/v0.1/bugs">Report a Bug</a></li><li><a href="https://github.com/istio/istio.github.io/issues/new?title=Issue with _docs/samples/bookinfo.md">Report a Doc Issue</a></li><li><a href="https://github.com/istio/istio.github.io/edit/master/_docs/samples/bookinfo.md">Edit This Page on GitHub</a></li></ul></div><hr class="footer-sections" /><div class="col-md-3 col-sm-4 col-xs-12 center-block"><ul class="toggle"><p class="header">Community</p><li><a href="https://groups.google.com/forum/#!forum/istio-users" target="_blank"><span class="group">User</span></a> | <a href="https://groups.google.com/forum/#!forum/istio-dev" target="_blank">Dev Mailing Lists</a></li><li><a href="https://twitter.com/IstioMesh" target="_blank"><span class="twitter">Twitter</span></a></li><li><a href="https://github.com/istio/istio" target="_blank"><span class="github">GitHub</span></a></li></ul></div><div class="col-md-1"></div></div><div class="row"><p class="description small text-center"> Copyright &copy; 2017 Istio Authors<br> Istio 0.1<br> Archived on 20-Jul-2017</p></div></div></footer><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.15.0/jquery.validate.min.js"></script> <script src="/v0.1/js/jquery.form.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script> <script src="/v0.1/js/slick.min.js"></script> <script src="/v0.1/js/jquery.visible.min.js"></script> <script src="/v0.1/js/common.js" type="text/javascript" charset="utf-8"></script> <script src="/v0.1/js/buttons.js"></script> <script src="/v0.1/js/search.js"></script> <script src="/v0.1/js/prism.js"></script></body></html>