{"componentChunkName":"component---src-templates-tag-js","path":"/tags/service-mesh/","result":{"data":{"site":{"siteMetadata":{"title":"LoginRadius Blog"}},"allMarkdownRemark":{"totalCount":3,"edges":[{"node":{"fields":{"slug":"/engineering/istio-installation-and-service-configuration/"},"html":"<p>An infrastructure layer that allows you to manage communication between the microservices of your application is a service mesh. As more developers work with microservices, by consolidating common management and administrative tasks in a distributed setup, service meshes have developed to make the job easier and more effective.</p>\n<p>To know more about Istio, you can read this article on <a href=\"https://www.loginradius.com/blog/engineering/istio-service-mesh\">Istio service mesh</a> to understand the basic terminology, In this tutorial, will explain how to install and configure Istio. Let's get started.</p>\n<h2 id=\"installing-istio\" style=\"position:relative;\"><a href=\"#installing-istio\" aria-label=\"installing istio permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Installing Istio</h2>\n<p>Get the latest Istio release:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"0\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">curl -L https://istio.io/downloadIstio | sh -</span></code></pre>\n<p>Extract the archive and export the bin directory in the environment path.</p>\n<p>This will also install istioctl, a command-line tool to manage Istio service mesh.</p>\n<h3 id=\"configuration-profiles\" style=\"position:relative;\"><a href=\"#configuration-profiles\" aria-label=\"configuration profiles permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Configuration Profiles</h3>\n<p>Istio provides various built-in configuration profiles, a set of pre-defined configs related to data and control plane. We can customize the configs according to our needs.</p>\n<p>For testing locally or trying it ou, you can use a demo profile. For dev and other environments, we will be using the default configuration profile.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"1\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">istioctl install --set profile=demo</span></code></pre>\n<h3 id=\"customizing-configs\" style=\"position:relative;\"><a href=\"#customizing-configs\" aria-label=\"customizing configs permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Customizing configs</h3>\n<p>Run:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"2\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">istioctl profile dump default</span></code></pre>\n<p>to see the various configurations. We can change those flag using istioctl commands and --set flag.</p>\n<p>For development purpose, we can enabled/changes following flags:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"3\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">istioctl install --set addonComponents.kiali.enabled=true \\ </span>\n<span class=\"grvsc-line\">--set components.telemetry.enabled=true \\ </span>\n<span class=\"grvsc-line\">--set components.citadel.enabled=true \\ </span>\n<span class=\"grvsc-line\">--set values.global.proxy.privileged=true \\ </span>\n<span class=\"grvsc-line\">--set addonComponents.tracing.enabled=true \\ </span>\n<span class=\"grvsc-line\">--set values.pilot.traceSampling=100.0 \\ </span>\n<span class=\"grvsc-line\">--set values.global.proxy.tracer=datadog</span></code></pre>\n<p>The path value of <code>--set</code> flag is the YAML path, which you can see in the profile dump command.</p>\n<blockquote>\n<p>While changing any config, make sure to pass all the previous flags with the new ones. For example, if first time, you enabled istioctl install --set addonComponents.kiali.enabled=true and now let’s say, you want to enable citadel, then you have to pass both flags like this: istioctl install --set addonComponents.kiali.enabled=true --set components.telemetry.enabled=true.\nFailing to add any previously enabled variable will revert the config to its default values.\nOne way to store the dump in a file and do istioctl apply or use helm charts for Istio.</p>\n</blockquote>\n<h3 id=\"sidecar-injection\" style=\"position:relative;\"><a href=\"#sidecar-injection\" aria-label=\"sidecar injection permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Sidecar injection</h3>\n<p>For Istio to work properly, a sidecar Envoy proxy needs to be enabled for the services. By default, the Istio control plane will not enable any sidecar to any services. To enable sidecar, we have to add labels at the namespace level.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"4\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">kubectl label namespace dsl-test istio-injection=enabled</span></code></pre>\n<p>You need to have this label even if you do not want to add a sidecar to all your services.</p>\n<p>You need to restart the pods.</p>\n<p>For services, which do not require sidecar, we need to add the following annotation in the deployment template:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"5\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"># Pod Annotations </span>\n<span class=\"grvsc-line\">podAnnotations: </span>\n<span class=\"grvsc-line\">\tsidecar.istio.io/inject: &quot;false&quot;</span></code></pre>\n<h2 id=\"configuring-services\" style=\"position:relative;\"><a href=\"#configuring-services\" aria-label=\"configuring services permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Configuring Services</h2>\n<p>For demonstration, we will take two demo services demo-1 and demo-2, and configure both services with Istio, and will try to call demo-2 service from demo-1. Make sure there is an env variable in demo-1, which we will configure with demo-2 internal DNS url. The programming language for the two services does not matter here.</p>\n<p>A service configuration requires a VirtualService, DestinationRule, PeerAuthentication, and optionally a Gateway configuration.</p>\n<h3 id=\"gateway\" style=\"position:relative;\"><a href=\"#gateway\" aria-label=\"gateway permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Gateway</h3>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"6\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">apiVersion: networking.istio.io/v1alpha3 </span>\n<span class=\"grvsc-line\">kind: Gateway </span>\n<span class=\"grvsc-line\">metadata: </span>\n<span class=\"grvsc-line\">\tname: demo-1</span>\n<span class=\"grvsc-line\">spec: </span>\n<span class=\"grvsc-line\">\tselector: </span>\n<span class=\"grvsc-line\">\t\tistio: ingressgateway </span>\n<span class=\"grvsc-line\">\tservers: </span>\n<span class=\"grvsc-line\">\t- port: </span>\n<span class=\"grvsc-line\">\t\tnumber: 80 </span>\n<span class=\"grvsc-line\">\t\tname: http </span>\n<span class=\"grvsc-line\">\t\tprotocol: HTTP </span>\n<span class=\"grvsc-line\">\t- hosts: </span>\n<span class=\"grvsc-line\">\t\t- &quot;demo-1.example.com&quot;</span></code></pre>\n<p>Gateway is used when we want to access the services from the public network.</p>\n<p>Here we are using the default gateway provided by the Istio. We can also create multiple gateways and assign the proper name here.</p>\n<p>The above gateway configuration enables both HTTP and HTTPS communication. In the case of HTTPS, we have to supply the secret containing the CA certs and key.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"7\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">spec:</span>\n<span class=\"grvsc-line\">\tservers: </span>\n<span class=\"grvsc-line\">\t- port: </span>\n<span class=\"grvsc-line\">\t\tnumber: 443</span>\n<span class=\"grvsc-line\">\t\tname: http </span>\n<span class=\"grvsc-line\">\t\tprotocol: HTTP</span>\n<span class=\"grvsc-line\">\t  tls: </span>\n<span class=\"grvsc-line\">\t\tmode: SIMPLE </span>\n<span class=\"grvsc-line\">\t\tcredentialName: div4-dev-certs</span>\n<span class=\"grvsc-line\">\t  hosts: </span>\n<span class=\"grvsc-line\">\t\t- &quot;demo-1.example.com&quot;</span></code></pre>\n<p>We can apply the same gateway for demo-2. We just have to update the hosts and metadata name. Since we will demo-2 internally from demo-1, there is no need for an external gateway for demo-2 here.</p>\n<h3 id=\"virtualservices\" style=\"position:relative;\"><a href=\"#virtualservices\" aria-label=\"virtualservices permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>VirtualServices</h3>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"8\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">---</span>\n<span class=\"grvsc-line\">apiVersion: networking.istio.io/v1alpha3</span>\n<span class=\"grvsc-line\">kind: VirtualService</span>\n<span class=\"grvsc-line\">metadata:</span>\n<span class=\"grvsc-line\">  name: demo-1</span>\n<span class=\"grvsc-line\">spec:</span>\n<span class=\"grvsc-line\">  hosts:</span>\n<span class=\"grvsc-line\">  - &quot;demo-1.test.svc.cluster.local&quot;</span>\n<span class=\"grvsc-line\">  - &quot;demo-1.example.com&quot;</span>\n<span class=\"grvsc-line\">  gateways:</span>\n<span class=\"grvsc-line\">    - demo-1</span>\n<span class=\"grvsc-line\">  http:</span>\n<span class=\"grvsc-line\">  - route:</span>\n<span class=\"grvsc-line\">    - destination:</span>\n<span class=\"grvsc-line\">        host: demo-1.test.svc.cluster.local</span>\n<span class=\"grvsc-line\">        port:</span>\n<span class=\"grvsc-line\">          number: 80</span></code></pre>\n<p><strong>spec.hosts:</strong> Specifies the URL which the caller of the service will use. Here, dsl-es.pbdp.svc.cluster.local will be used by the services calling internally. The endpoint demo-1.example.com will be exposed publicly, and it should match the <strong>spec.servers.hosts</strong> value in Gateway config.</p>\n<p><strong>spec.gateways:</strong> In order for the gateways configured above to reach the service, we need to define the gateway metadata name here.</p>\n<p><strong>http.route.destination.host:</strong> This value should be the actual service FQDN.</p>\n<h3 id=\"destinationrule\" style=\"position:relative;\"><a href=\"#destinationrule\" aria-label=\"destinationrule permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>DestinationRule</h3>\n<p>After the virtualservice decides the destination hosts, DestinationRule defines the configuration on the actual service. DestinationRule is optional and is needed only in case we want to override the default behavior.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"9\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">---</span>\n<span class=\"grvsc-line\">apiVersion: networking.istio.io/v1alpha3</span>\n<span class=\"grvsc-line\">kind: DestinationRule</span>\n<span class=\"grvsc-line\">metadata:</span>\n<span class=\"grvsc-line\">  name: demo-1</span>\n<span class=\"grvsc-line\">spec:</span>\n<span class=\"grvsc-line\">  host: &quot;demo-1.test.svc.cluster.local&quot;</span>\n<span class=\"grvsc-line\">  trafficPolicy:</span>\n<span class=\"grvsc-line\">    loadBalancer:</span>\n<span class=\"grvsc-line\">      simple: ROUND_ROBIN</span>\n<span class=\"grvsc-line\">    tls:</span>\n<span class=\"grvsc-line\">      mode: ISTIO_MUTUAL</span></code></pre>\n<p><strong>spec.host:</strong> specifies service FQDN</p>\n<p><strong>spec.trafficPolicy:</strong> Specifies policy on the traffic. Here we can specify load balancing algorithms, TLS mode, circuit breaking policies.</p>\n<p><strong>spec.trafficPolicy.tls.mode:</strong> ISTIO_MUTUAL mode is a TLS mode where we will use the certificates generated by the Istio.</p>\n<p>A configuration like circuit breakers, outlier detection comes under the Destination Rule.</p>\n<h3 id=\"peerauthentication\" style=\"position:relative;\"><a href=\"#peerauthentication\" aria-label=\"peerauthentication permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>PeerAuthentication</h3>\n<p>This configuration defines how the other services will connect.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"10\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">---</span>\n<span class=\"grvsc-line\">apiVersion: security.istio.io/v1beta1</span>\n<span class=\"grvsc-line\">kind: PeerAuthentication</span>\n<span class=\"grvsc-line\">metadata:</span>\n<span class=\"grvsc-line\">  name: demo-1</span>\n<span class=\"grvsc-line\">spec:</span>\n<span class=\"grvsc-line\">  selector:</span>\n<span class=\"grvsc-line\">    matchLabels:</span>\n<span class=\"grvsc-line\">      app: demo-1</span>\n<span class=\"grvsc-line\">  mtls:</span>\n<span class=\"grvsc-line\">    mode: STRICT</span></code></pre>\n<p><strong>spec.selector.matchLabels.app:</strong> Specify the deployment label on which this configuration will be applied.</p>\n<p><strong>spec.mtls.mode:</strong> TLS mode. STRICT being the connection will always be mutual tls.</p>\n<p>PeerAuthentication can be applied to a whole namespace. This is useful when all the services in the namespace are part of the mesh.</p>\n<blockquote>\n<p>Apply the same configuration for virutalservice, destination, and peerauthentication by replacing demo-1 with demo-2 assuming both services are in the same namespace.</p>\n</blockquote>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"11\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">kubectl apply -f &lt;file&gt;.yaml -n test</span></code></pre>\n<p>Access the objects:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"12\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">kubectl get virtualservices -n pbdp</span>\n<span class=\"grvsc-line\">kubectl get gateways -n pbdp</span>\n<span class=\"grvsc-line\">kubectl get destinationrule -n pbdp</span>\n<span class=\"grvsc-line\">kubectl get peerauthentication -n pbdp</span></code></pre>\n<p>Now update the env for demo-2 with <code>demo-2.test.svc.cluster.local</code> in demo-1 service.</p>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n  }\n  \n  .grvsc-code {\n    display: inline-block;\n    min-width: 100%;\n  }\n  \n  .grvsc-line {\n    display: inline-block;\n    box-sizing: border-box;\n    width: 100%;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-line-highlighted {\n    background-color: var(--grvsc-line-highlighted-background-color, transparent);\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, transparent);\n  }\n  \n  .dark-default-dark {\n    background-color: #1E1E1E;\n    color: #D4D4D4;\n  }\n</style>","frontmatter":{"date":"January 22, 2021","updated_date":null,"title":"How to Install and Configure Istio","tags":["Istio","Service Mesh"],"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.5037593984962405,"src":"/static/452f4d9f7cb358e3d6224ed3aba3d5d6/ee604/Istio.png","srcSet":"/static/452f4d9f7cb358e3d6224ed3aba3d5d6/69585/Istio.png 200w,\n/static/452f4d9f7cb358e3d6224ed3aba3d5d6/497c6/Istio.png 400w,\n/static/452f4d9f7cb358e3d6224ed3aba3d5d6/ee604/Istio.png 800w,\n/static/452f4d9f7cb358e3d6224ed3aba3d5d6/db955/Istio.png 900w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Piyush Kumar","github":"kpiyush17","avatar":null}}}},{"node":{"fields":{"slug":"/engineering/istio-service-mesh/"},"html":"<h2 id=\"what-is-istio\" style=\"position:relative;\"><a href=\"#what-is-istio\" aria-label=\"what is istio permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What is Istio?</h2>\n<p>Istio is an Open Source service mesh (developed in partnership between teams from Google, IBM, and Lyft), providing a dedicated infrastructure layer for creating service-to-service communication that is safe, fast, and reliable. Having such a fanatical communication layer can provide various advantages, like providing observability into communications, providing secure connections, or automating retries and backoff for failed requests.</p>\n<p>A service mesh also often has more complex operational requirements, like A/B testing, canary rollouts, rate limiting, access control, and end-to-end authentication.</p>\n<p>Istio does this by adding a sidecar proxy which intercepts all network communication between microservices, then configures and manages Istio using its control plane functionality, which incorporates:</p>\n<ol>\n<li>Granular control over the service-to-service communication and its routing with the additional functionality of retries, fault injection, circuit breakers.</li>\n<li>Providing secure mTLS without any changes in the application code.</li>\n<li>Cluster to cluster communication using ingress and egress gateways.</li>\n</ol>\n<h2 id=\"istio-architecture\" style=\"position:relative;\"><a href=\"#istio-architecture\" aria-label=\"istio architecture permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Istio Architecture</h2>\n<p>An Istio service mesh is logically split into a data plane and a control plane.</p>\n<p>The data plane is composed of Envoy proxy deployed as sidecars. Envoy itself is an L7 proxy and communication bus designed for modern microservices-based architecture. These proxies intercept and control all network communication between microservices. They also collect and report telemetry on all mesh traffic.</p>\n<p>The control plane manages and configures the proxies to route traffic.</p>\n<p><img src=\"https://istio.io/latest/docs/ops/deployment/architecture/arch.svg\" alt=\"Istio Architecture\"></p>\n<h2 id=\"istio-core-components\" style=\"position:relative;\"><a href=\"#istio-core-components\" aria-label=\"istio core components permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Istio Core Components</h2>\n<h3 id=\"pilot\" style=\"position:relative;\"><a href=\"#pilot\" aria-label=\"pilot permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Pilot</h3>\n<p>Istio Pilot manages and configures all the Envoy proxy instances deployed. It takes the rules for traffic behavior provided by the control plane and converts them into configurations applied by Envoy.</p>\n<h3 id=\"citadel\" style=\"position:relative;\"><a href=\"#citadel\" aria-label=\"citadel permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Citadel</h3>\n<p>Responsible for controlling the authentication and identity management between services. Allow developers to build a zero-trust network based on service identity.</p>\n<h3 id=\"mixer\" style=\"position:relative;\"><a href=\"#mixer\" aria-label=\"mixer permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Mixer</h3>\n<p>Responsible for enforcing access control and usage policies across the service mesh and collects telemetry data from the Envoy proxy and other services.</p>\n<h2 id=\"istio-features\" style=\"position:relative;\"><a href=\"#istio-features\" aria-label=\"istio features permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Istio Features</h2>\n<h3 id=\"traffic-management\" style=\"position:relative;\"><a href=\"#traffic-management\" aria-label=\"traffic management permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Traffic Management</h3>\n<p>It is the basic feature of Istio, which facilitates the routing between services. Istio simplifies the configuration of service-level properties like circuit breakers, timeouts, and retries.\nAll traffic that your mesh services send and receive (data plane traffic) is proxied through Envoy, making it easy to direct and control traffic around your mesh without making any changes to your services.</p>\n<p>For discovering all the services in the ecosystem, Istio connects to the Service discovery System and populates its service registry. The Envoy sidecar proxy then uses this registry to route traffic to the correct service.</p>\n<p>Here are a few resources you can add for your deployment apart from the basic service discovery and load balancing:</p>\n<h3 id=\"virtual-services\" style=\"position:relative;\"><a href=\"#virtual-services\" aria-label=\"virtual services permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Virtual Services</h3>\n<p>Virtual services play a key role in making Istio's traffic management flexible and powerful. They do this by strongly decoupling where clients send their requests from the destination workloads that actually implement them.<br>\nSo, instead of sending requests directly to a service data plane, you send traffic through this virtual service. Using virtual service, you can route requests to different versions of the same service or different hostnames based on particular endpoints. This helps us to do various other things like A/B testing or doing canary rollouts.  </p>\n<p>A typical example:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"yaml\" data-index=\"0\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk4\">apiVersion</span><span class=\"mtk1\">: </span><span class=\"mtk8\">networking.istio.io/v1alpha3</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">kind</span><span class=\"mtk1\">: </span><span class=\"mtk8\">VirtualService</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">metadata</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">name</span><span class=\"mtk1\">: </span><span class=\"mtk8\">bookinfo</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">spec</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">hosts</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    - </span><span class=\"mtk8\">bookinfo.com</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">http</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  - </span><span class=\"mtk4\">match</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    - </span><span class=\"mtk4\">uri</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        </span><span class=\"mtk4\">prefix</span><span class=\"mtk1\">: </span><span class=\"mtk8\">/reviews</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk4\">route</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    - </span><span class=\"mtk4\">destination</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        </span><span class=\"mtk4\">host</span><span class=\"mtk1\">: </span><span class=\"mtk8\">reviews  &lt;-- Resolves to reviews.&lt;namespace&gt;.svc.cluster.local</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  - </span><span class=\"mtk4\">match</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    - </span><span class=\"mtk4\">uri</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        </span><span class=\"mtk4\">prefix</span><span class=\"mtk1\">: </span><span class=\"mtk8\">/ratings</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk4\">route</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    - </span><span class=\"mtk4\">destination</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        </span><span class=\"mtk4\">host</span><span class=\"mtk1\">: </span><span class=\"mtk8\">ratings</span></span></code></pre>\n<h3 id=\"destination-rule\" style=\"position:relative;\"><a href=\"#destination-rule\" aria-label=\"destination rule permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Destination Rule</h3>\n<p>We use destination rules to configure what happens to traffic for that destination. Destination rules are applied after virtual service routing rules are evaluated, so they apply to the traffic's real destination.<br>\nUsing destination rules, we specify the subsets of the service using labels, which are then used by the virtual service to route requests to a particular subset. In addition to that, we can also customize traffic policy, load balancing policy, connection pool settings, mTLS, etc.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"yaml\" data-index=\"1\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk4\">apiVersion</span><span class=\"mtk1\">: </span><span class=\"mtk8\">networking.istio.io/v1alpha3</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">kind</span><span class=\"mtk1\">: </span><span class=\"mtk8\">DestinationRule</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">metadata</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">name</span><span class=\"mtk1\">: </span><span class=\"mtk8\">my-destination-rule</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">spec</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">host</span><span class=\"mtk1\">: </span><span class=\"mtk8\">my-svc</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">trafficPolicy</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk4\">loadBalancer</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk4\">simple</span><span class=\"mtk1\">: </span><span class=\"mtk8\">RANDOM</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">subsets</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk3\">#### This will work only if we have defined version label in the deployment</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  - </span><span class=\"mtk4\">name</span><span class=\"mtk1\">: </span><span class=\"mtk8\">v1</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk4\">labels</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk4\">version</span><span class=\"mtk1\">: </span><span class=\"mtk8\">v1</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  - </span><span class=\"mtk4\">name</span><span class=\"mtk1\">: </span><span class=\"mtk8\">v2</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk4\">labels</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk4\">version</span><span class=\"mtk1\">: </span><span class=\"mtk8\">v2</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk4\">trafficPolicy</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk4\">loadBalancer</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        </span><span class=\"mtk4\">simple</span><span class=\"mtk1\">: </span><span class=\"mtk8\">ROUND_ROBIN</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  - </span><span class=\"mtk4\">name</span><span class=\"mtk1\">: </span><span class=\"mtk8\">v3</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk4\">labels</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk4\">version</span><span class=\"mtk1\">: </span><span class=\"mtk8\">v3</span></span></code></pre>\n<p>Here we have defined destination rule for service <strong>my-svc</strong> and defined subsets and traffic policy global and per subset.</p>\n<h3 id=\"gateway\" style=\"position:relative;\"><a href=\"#gateway\" aria-label=\"gateway permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Gateway</h3>\n<p>It is used to manage inbound and outbound traffic for your mesh, letting you specify which traffic you want to enter or leave the mesh. Gateway configurations are applied to standalone Envoy proxies running at the edge of the mesh, rather than sidecar Envoy proxies running alongside your service workloads. Using this, we can expose our services to the internet.  </p>\n<p>A typical example would be:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"yaml\" data-index=\"2\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk4\">apiVersion</span><span class=\"mtk1\">: </span><span class=\"mtk8\">networking.istio.io/v1alpha3</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">kind</span><span class=\"mtk1\">: </span><span class=\"mtk8\">Gateway</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">metadata</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">name</span><span class=\"mtk1\">: </span><span class=\"mtk8\">my-svc-gateway</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">namespace</span><span class=\"mtk1\">: </span><span class=\"mtk8\">test</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">spec</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">selector</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk4\">istio</span><span class=\"mtk1\">: </span><span class=\"mtk8\">ingressgateway</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">servers</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  - </span><span class=\"mtk4\">port</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk4\">number</span><span class=\"mtk1\">: </span><span class=\"mtk7\">80</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk4\">name</span><span class=\"mtk1\">: </span><span class=\"mtk8\">http</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk4\">protocol</span><span class=\"mtk1\">: </span><span class=\"mtk8\">HTTP</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk4\">hosts</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    - </span><span class=\"mtk8\">my-svc.example.com</span></span></code></pre>\n<p><strong>istio: ingressgateway</strong> is the gateway which is enabled by default after installation. We can create our custom gateway. Here, the hosts <strong>my-svc.example.com</strong> will resolve to the load balancer provided by the Istio by default. To use this gateway, one has to add config in the virtual service like for example:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"yaml\" data-index=\"3\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk4\">apiVersion</span><span class=\"mtk1\">: </span><span class=\"mtk8\">networking.istio.io/v1alpha3</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">kind</span><span class=\"mtk1\">: </span><span class=\"mtk8\">VirtualService</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">metadata</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">name</span><span class=\"mtk1\">: </span><span class=\"mtk8\">my-svc</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">spec</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">hosts</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  - </span><span class=\"mtk8\">my-svc</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  - </span><span class=\"mtk8\">my-svc.example.com   &lt;-- The host should match</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">gateways</span><span class=\"mtk1\">:               </span><span class=\"mtk8\">&lt;--- gateway config</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    - </span><span class=\"mtk8\">my-svc-gateway</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">http</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  - </span><span class=\"mtk4\">route</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    - </span><span class=\"mtk4\">destination</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        </span><span class=\"mtk4\">host</span><span class=\"mtk1\">: </span><span class=\"mtk8\">my-svc.test.svc.cluster.local</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        </span><span class=\"mtk4\">port</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">          </span><span class=\"mtk4\">number</span><span class=\"mtk1\">: </span><span class=\"mtk7\">80</span><span class=\"mtk1\"> </span></span></code></pre>\n<h3 id=\"network-resilience\" style=\"position:relative;\"><a href=\"#network-resilience\" aria-label=\"network resilience permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Network Resilience</h3>\n<p>This feature provides network configuration dynamically at runtime, which includes retries, fault injection, circuit breakers, and timeouts.</p>\n<h3 id=\"service-entries\" style=\"position:relative;\"><a href=\"#service-entries\" aria-label=\"service entries permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Service Entries</h3>\n<p>This object is used to add an external service as part of the service mesh, including a service running in a VM or other K8s cluster in case of multi-cluster installation.</p>\n<p>A typical example would be connecting a service to a database cluster that is not part of the mesh.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"yaml\" data-index=\"4\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk4\">apiVersion</span><span class=\"mtk1\">: </span><span class=\"mtk8\">networking.istio.io/v1alpha3</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">kind</span><span class=\"mtk1\">: </span><span class=\"mtk8\">ServiceEntry</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">metadata</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">name</span><span class=\"mtk1\">: </span><span class=\"mtk8\">elasticsearch</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">namespace</span><span class=\"mtk1\">: </span><span class=\"mtk8\">test</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">spec</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">hosts</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  - </span><span class=\"mtk8\">elasticsearch.elasticsearch.svc.cluster.local</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">location</span><span class=\"mtk1\">: </span><span class=\"mtk8\">MESH_INTERNAL</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">ports</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  - </span><span class=\"mtk4\">name</span><span class=\"mtk1\">: </span><span class=\"mtk8\">https</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk4\">number</span><span class=\"mtk1\">: </span><span class=\"mtk7\">9200</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk4\">protocol</span><span class=\"mtk1\">: </span><span class=\"mtk8\">TCP</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">resolution</span><span class=\"mtk1\">: </span><span class=\"mtk8\">DNS</span></span></code></pre>\n<p>The Service Entry should be in the same namespace as that of the calling service. This is helpful, especially in the case where the service is not exposed to a public endpoint and can be accessed using internal service DNS like the above example.</p>\n<h3 id=\"security\" style=\"position:relative;\"><a href=\"#security\" aria-label=\"security permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Security</h3>\n<p>Istio provides security features that will help us to establish a zero-trust network. Istio enables security by default and provides various authentication and authorization policy to regulate security.</p>\n<p>For example:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"yaml\" data-index=\"5\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk4\">apiVersion</span><span class=\"mtk1\">: </span><span class=\"mtk8\">security.istio.io/v1beta1</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">kind</span><span class=\"mtk1\">: </span><span class=\"mtk8\">PeerAuthentication</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">metadata</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">name</span><span class=\"mtk1\">: </span><span class=\"mtk8\">dsl-es</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">namespace</span><span class=\"mtk1\">: </span><span class=\"mtk8\">pdp-test</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">spec</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">selector</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk4\">matchLabels</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk4\">app</span><span class=\"mtk1\">: </span><span class=\"mtk8\">dsl-es</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">mtls</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk4\">mode</span><span class=\"mtk1\">: </span><span class=\"mtk8\">STRICT</span></span></code></pre>\n<p>Here we define a peer authentication object for a service labeled <strong>my-svc</strong>, which tells that any service that needs to talk to <strong>my-svc</strong> will communicate using mtls. The service will accept only TLS connection. By default, Istio enables <strong>PERMISSIVE</strong> mode, which accepts both plaintext and encrypted communication. </p>\n<p>We can define peer authentication on the mesh, namespace, and pod level.</p>\n<p>That is all for the introduction to Istio. In the next part, we will look at installing Istio and configuring services to use Istio.</p>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n  }\n  \n  .grvsc-code {\n    display: inline-block;\n    min-width: 100%;\n  }\n  \n  .grvsc-line {\n    display: inline-block;\n    box-sizing: border-box;\n    width: 100%;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-line-highlighted {\n    background-color: var(--grvsc-line-highlighted-background-color, transparent);\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, transparent);\n  }\n  \n  .dark-default-dark {\n    background-color: #1E1E1E;\n    color: #D4D4D4;\n  }\n  .dark-default-dark .mtk4 { color: #569CD6; }\n  .dark-default-dark .mtk1 { color: #D4D4D4; }\n  .dark-default-dark .mtk8 { color: #CE9178; }\n  .dark-default-dark .mtk3 { color: #6A9955; }\n  .dark-default-dark .mtk7 { color: #B5CEA8; }\n</style>","frontmatter":{"date":"December 07, 2020","updated_date":null,"title":"Istio Service Mesh: A Beginners Guide","tags":["Istio","Service Mesh"],"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.5037593984962405,"src":"/static/452f4d9f7cb358e3d6224ed3aba3d5d6/ee604/Istio.png","srcSet":"/static/452f4d9f7cb358e3d6224ed3aba3d5d6/69585/Istio.png 200w,\n/static/452f4d9f7cb358e3d6224ed3aba3d5d6/497c6/Istio.png 400w,\n/static/452f4d9f7cb358e3d6224ed3aba3d5d6/ee604/Istio.png 800w,\n/static/452f4d9f7cb358e3d6224ed3aba3d5d6/db955/Istio.png 900w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Piyush Kumar","github":"kpiyush17","avatar":null}}}},{"node":{"fields":{"slug":"/engineering/service-mesh-with-envoy/"},"html":"<p>This post will cover a demo working setup of a service mesh architecture using Envoy using a demo application. In this service mesh architecture, we will be using Envoy proxy for both control and data plane. The setup is deployed in a Kubernetes cluster using Amazon EKS.</p>\n<h1 id=\"pre-requisites\" style=\"position:relative;\"><a href=\"#pre-requisites\" aria-label=\"pre requisites permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Pre-requisites</h1>\n<p>We will be deploying an echo-grpc test application provided by Google in their article related to gRPC load balancing and was used as a reference to test the service mesh setup with Envoy. The article covers setting up Envoy as an edge proxy only.\nThis is a simple gRPC application that exposes a unary method that takes a string in the content request field and responds with the content unaltered.\nRepo: <a href=\"https://github.com/GoogleCloudPlatform/grpc-gke-nlb-tutorial\">grpc-gke-nlb-tutorial</a></p>\n<ul>\n<li>Clone this repo.</li>\n<li>Go to the echo-grpc directory.</li>\n<li>Using the Dockerfile provided in the folder, we would have to build the image and push it to the Docker registry of choice. Since we are not using GCP, Docker Hub is used as the registry.</li>\n<li>Run docker login and login with your hub credentials.</li>\n<li>Build the image docker build -t echo-grpc .</li>\n<li>Tag the image docker tag echo-grpc <hub-username>/echo-grpc</li>\n<li>Push the image docker push <hub-username>/echo-grpc</li>\n<li>Create a separate folder to put all the YAML files.</li>\n<li>Create namespace in k8s:\n<code>kubectl create namespace envoy</code></li>\n<li>Install grpcurl tool which is similar to curl but for gRPC for testing:\n<code>go get github.com/fullstorydev/grpcurl</code></li>\n</ul>\n<h1 id=\"sidecar-deployment\" style=\"position:relative;\"><a href=\"#sidecar-deployment\" aria-label=\"sidecar deployment permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Sidecar Deployment</h1>\n<p>Configuration of envoy for the sidecar deployment:</p>\n<p><strong>envoy-echo.yaml:</strong></p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"0\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">apiVersion: v1</span>\n<span class=\"grvsc-line\">kind: ConfigMap</span>\n<span class=\"grvsc-line\">metadata:</span>\n<span class=\"grvsc-line\">  name: envoy-echo</span>\n<span class=\"grvsc-line\">data:</span>\n<span class=\"grvsc-line\">  envoy.yaml: |</span>\n<span class=\"grvsc-line\">    static_resources:</span>\n<span class=\"grvsc-line\">      listeners:</span>\n<span class=\"grvsc-line\">      - address:</span>\n<span class=\"grvsc-line\">          socket_address:</span>\n<span class=\"grvsc-line\">            address: 0.0.0.0</span>\n<span class=\"grvsc-line\">            port_value: 8786</span>\n<span class=\"grvsc-line\">        filter_chains:</span>\n<span class=\"grvsc-line\">        - filters:</span>\n<span class=\"grvsc-line\">          - name: envoy.http_connection_manager</span>\n<span class=\"grvsc-line\">            config:</span>\n<span class=\"grvsc-line\">              access_log:</span>\n<span class=\"grvsc-line\">              - name: envoy.file_access_log</span>\n<span class=\"grvsc-line\">                config:</span>\n<span class=\"grvsc-line\">                  path: &quot;/dev/stdout&quot;</span>\n<span class=\"grvsc-line\">              codec_type: AUTO</span>\n<span class=\"grvsc-line\">              stat_prefix: ingress_https</span>\n<span class=\"grvsc-line\">              route_config:</span>\n<span class=\"grvsc-line\">                name: local_route</span>\n<span class=\"grvsc-line\">                virtual_hosts:</span>\n<span class=\"grvsc-line\">                - name: https</span>\n<span class=\"grvsc-line\">                  domains:</span>\n<span class=\"grvsc-line\">                  - &quot;*&quot;</span>\n<span class=\"grvsc-line\">                  routes:</span>\n<span class=\"grvsc-line\">                  - match:</span>\n<span class=\"grvsc-line\">                      prefix: &quot;/api.Echo/&quot;</span>\n<span class=\"grvsc-line\">                    route:</span>\n<span class=\"grvsc-line\">                      cluster: echo-grpc</span>\n<span class=\"grvsc-line\">              http_filters:</span>\n<span class=\"grvsc-line\">              - name: envoy.health_check</span>\n<span class=\"grvsc-line\">                config:</span>\n<span class=\"grvsc-line\">                  pass_through_mode: false</span>\n<span class=\"grvsc-line\">                  headers:</span>\n<span class=\"grvsc-line\">                  - name: &quot;:path&quot;</span>\n<span class=\"grvsc-line\">                    exact_match: &quot;/healthz&quot;</span>\n<span class=\"grvsc-line\">                  - name: &quot;x-envoy-livenessprobe&quot;</span>\n<span class=\"grvsc-line\">                    exact_match: &quot;healthz&quot;</span>\n<span class=\"grvsc-line\">              - name: envoy.router</span>\n<span class=\"grvsc-line\">                config: {}</span>\n<span class=\"grvsc-line\">      clusters:</span>\n<span class=\"grvsc-line\">      - name: echo-grpc</span>\n<span class=\"grvsc-line\">        connect_timeout: 0.5s</span>\n<span class=\"grvsc-line\">        type: STATIC</span>\n<span class=\"grvsc-line\">        lb_policy: ROUND_ROBIN</span>\n<span class=\"grvsc-line\">        http2_protocol_options: {}</span>\n<span class=\"grvsc-line\">        load_assignment:</span>\n<span class=\"grvsc-line\">          cluster_name: echo-grpc</span>\n<span class=\"grvsc-line\">          endpoints:</span>\n<span class=\"grvsc-line\">          - lb_endpoints:</span>\n<span class=\"grvsc-line\">            - endpoint:</span>\n<span class=\"grvsc-line\">                address:</span>\n<span class=\"grvsc-line\">                  socket_address:</span>\n<span class=\"grvsc-line\">                    address: &quot;127.0.0.1&quot;</span>\n<span class=\"grvsc-line\">                    port_value: 8081</span>\n<span class=\"grvsc-line\">        health_checks:</span>\n<span class=\"grvsc-line\">          timeout: 1s</span>\n<span class=\"grvsc-line\">          interval: 10s</span>\n<span class=\"grvsc-line\">          unhealthy_threshold: 2</span>\n<span class=\"grvsc-line\">          healthy_threshold: 2</span>\n<span class=\"grvsc-line\">          grpc_health_check: {}</span>\n<span class=\"grvsc-line\">    admin:</span>\n<span class=\"grvsc-line\">      access_log_path: &quot;/dev/stdout&quot;</span>\n<span class=\"grvsc-line\">      address:</span>\n<span class=\"grvsc-line\">        socket_address:</span>\n<span class=\"grvsc-line\">          address: 127.0.0.1</span>\n<span class=\"grvsc-line\">          port_value: 8090</span></code></pre>\n<p>A couple things to note here. </p>\n<ul>\n<li>We are exposing sidecar on 8786 port on the container. </li>\n<li>Filter <strong>envoy.http<em>connection</em>manager</strong> handles the HTTP traffic. </li>\n<li><strong>route_config</strong> is used to define the routes for each domain to their respective clusters. Here we are keeping the domain as <code>*</code>, allowing all domains to pass-through.</li>\n<li>A cluster is envoy defines the services that will be called based on the route.</li>\n<li>In the cluster, the <strong>lb_policy</strong> defines the algorithm for load balancing, keeping as ROUND<em>ROBIN, with type STATIC because it is a sidecar and needs to communicate to only one pod always which leads to the reason for keeping the address in socket</em>address as localhost while port_value is what will be exposed by that particular service’s deployment.</li>\n</ul>\n<p>Run:\n<code>kubectl apply -f envoy-echo.yaml -n envoy</code></p>\n<p>Deployment of echo-grpc application with 3 replicas. The config contains two containers, one for application and another being the Envoy image.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"1\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">apiVersion: apps/v1</span>\n<span class=\"grvsc-line\">kind: Deployment</span>\n<span class=\"grvsc-line\">metadata:</span>\n<span class=\"grvsc-line\">  name: echo-grpc</span>\n<span class=\"grvsc-line\">spec:</span>\n<span class=\"grvsc-line\">  replicas: 3</span>\n<span class=\"grvsc-line\">  selector:</span>\n<span class=\"grvsc-line\">    matchLabels:</span>\n<span class=\"grvsc-line\">      app: echo-grpc</span>\n<span class=\"grvsc-line\">  template:</span>\n<span class=\"grvsc-line\">    metadata:</span>\n<span class=\"grvsc-line\">      labels:</span>\n<span class=\"grvsc-line\">        app: echo-grpc</span>\n<span class=\"grvsc-line\">    spec:</span>\n<span class=\"grvsc-line\">      containers:</span>\n<span class=\"grvsc-line\">      - name: echo-grpc</span>\n<span class=\"grvsc-line\">        image: &lt;hub-username&gt;/echo-grpc</span>\n<span class=\"grvsc-line\">        imagePullPolicy: Always</span>\n<span class=\"grvsc-line\">        resources: {}</span>\n<span class=\"grvsc-line\">        env:</span>\n<span class=\"grvsc-line\">        - name: &quot;PORT&quot;</span>\n<span class=\"grvsc-line\">          value: &quot;8081&quot;</span>\n<span class=\"grvsc-line\">        ports:</span>\n<span class=\"grvsc-line\">        - containerPort: 8081</span>\n<span class=\"grvsc-line\">        readinessProbe:</span>\n<span class=\"grvsc-line\">          exec:</span>\n<span class=\"grvsc-line\">            command: [&quot;/bin/grpc_health_probe&quot;, &quot;-addr=:8081&quot;]</span>\n<span class=\"grvsc-line\">          initialDelaySeconds: 1</span>\n<span class=\"grvsc-line\">        livenessProbe:</span>\n<span class=\"grvsc-line\">          exec:</span>\n<span class=\"grvsc-line\">            command: [&quot;/bin/grpc_health_probe&quot;, &quot;-addr=:8081&quot;]</span>\n<span class=\"grvsc-line\">          initialDelaySeconds: 1</span>\n<span class=\"grvsc-line\">      - name: envoy</span>\n<span class=\"grvsc-line\">        image: envoyproxy/envoy:v1.9.1</span>\n<span class=\"grvsc-line\">        resources: {}</span>\n<span class=\"grvsc-line\">        ports:</span>\n<span class=\"grvsc-line\">        - name: https</span>\n<span class=\"grvsc-line\">          containerPort: 443</span>\n<span class=\"grvsc-line\">        volumeMounts:</span>\n<span class=\"grvsc-line\">        - name: config</span>\n<span class=\"grvsc-line\">          mountPath: /etc/envoy</span>\n<span class=\"grvsc-line\">      volumes:</span>\n<span class=\"grvsc-line\">        - name: config</span>\n<span class=\"grvsc-line\">          configMap:</span>\n<span class=\"grvsc-line\">            name: envoy-echo</span></code></pre>\n<p>Here, echo-grpc is test application and envoy is being deployed in the same pod. Config volumes are mounted so that the envoy can read the configmaps.</p>\n<p>Run:\n<code>kubectl apply -f echo-deployment.yaml -n envoy</code></p>\n<h1 id=\"headless-service-configuration\" style=\"position:relative;\"><a href=\"#headless-service-configuration\" aria-label=\"headless service configuration permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Headless Service Configuration</h1>\n<p>We are using headless service for echo-grpc. Using service as headless will expose the Pods IP to the DNS server of kubernetes which will be used by Envoy to do service discovery for the pods.</p>\n<p><strong>echo-service.yaml</strong></p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"2\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">apiVersion: v1</span>\n<span class=\"grvsc-line\">kind: Service</span>\n<span class=\"grvsc-line\">metadata:</span>\n<span class=\"grvsc-line\">  name: echo-grpc</span>\n<span class=\"grvsc-line\">spec:</span>\n<span class=\"grvsc-line\">  type: ClusterIP</span>\n<span class=\"grvsc-line\">  clusterIP: None</span>\n<span class=\"grvsc-line\">  selector:</span>\n<span class=\"grvsc-line\">    app: echo-grpc</span>\n<span class=\"grvsc-line\">  ports:</span>\n<span class=\"grvsc-line\">  - name: http2-echo</span>\n<span class=\"grvsc-line\">    protocol: TCP</span>\n<span class=\"grvsc-line\">    port: 8786</span>\n<span class=\"grvsc-line\">  - name: http2-service</span>\n<span class=\"grvsc-line\">    protocol: TCP</span>\n<span class=\"grvsc-line\">    port: 8081</span></code></pre>\n<p>In the above config file, we are exposing two ports, one for envoy sidecar (this is the same port we mentioned in the config map of sidecar envoy) and one for the service itself.</p>\n<p>Run:\n<code>kubectl apply -f echo-service.yaml -n envoy</code></p>\n<h1 id=\"front-envoy-configuration\" style=\"position:relative;\"><a href=\"#front-envoy-configuration\" aria-label=\"front envoy configuration permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Front Envoy Configuration</h1>\n<p>Creating a service of type LoadBalancer so that client can access the backend service.</p>\n<p><strong>envoy-service.yaml:</strong></p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"3\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">apiVersion: v1</span>\n<span class=\"grvsc-line\">kind: Service</span>\n<span class=\"grvsc-line\">metadata:</span>\n<span class=\"grvsc-line\">  name: envoy</span>\n<span class=\"grvsc-line\">spec:</span>\n<span class=\"grvsc-line\">  type: LoadBalancer</span>\n<span class=\"grvsc-line\">  selector:</span>\n<span class=\"grvsc-line\">    app: envoy</span>\n<span class=\"grvsc-line\">  ports:</span>\n<span class=\"grvsc-line\">  - name: https</span>\n<span class=\"grvsc-line\">    protocol: TCP</span>\n<span class=\"grvsc-line\">    port: 443</span>\n<span class=\"grvsc-line\">    targetPort: 443</span></code></pre>\n<h3 id=\"creating-self-signed-certificates\" style=\"position:relative;\"><a href=\"#creating-self-signed-certificates\" aria-label=\"creating self signed certificates permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Creating self-signed certificates</h3>\n<p>Run:\n<code>kubectl apply -f envoy-service.yaml -n envoy</code></p>\n<p>Since we are deploying front envoy LoadBalancer on port 443, we have to create a self-signed certificate to make it terminate SSL/TLS connection.</p>\n<ul>\n<li>Get the external IP:\n<code>kubectl describe svc/envoy -n envoy</code></li>\n<li>Copy the LoadBalancer address in the EXTERNAL-IP section and do a nslookup and copy the IP address:\n<code>nslookup &#x3C;your load balancer aadess></code></li>\n<li>Create a self-signed cert and key:\n<code>openssl req -x509 -nodes -newkey rsa:2048 -days 365 -keyout privkey.pem -out cert.pem -subj \"/CN=&#x3C;ip-address>\"</code></li>\n<li>Create a Kubernetes TLS Secret called envoy-certs that contains the self-signed SSL/TLS certificate and key:\n<code>kubectl create secret tls envoy-certs --key privkey.pem --cert cert.pem --dry-run -o yaml</code></li>\n</ul>\n<h3 id=\"edge-envoy-configuration\" style=\"position:relative;\"><a href=\"#edge-envoy-configuration\" aria-label=\"edge envoy configuration permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Edge Envoy configuration</h3>\n<p>Configuration for the edge Envoy:</p>\n<p><strong>envoy-configmap.yaml</strong></p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"4\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">apiVersion: v1</span>\n<span class=\"grvsc-line\">kind: ConfigMap</span>\n<span class=\"grvsc-line\">metadata:</span>\n<span class=\"grvsc-line\">  name: envoy-conf</span>\n<span class=\"grvsc-line\">data:</span>\n<span class=\"grvsc-line\">  envoy.yaml: |</span>\n<span class=\"grvsc-line\">    static_resources:</span>\n<span class=\"grvsc-line\">      listeners:</span>\n<span class=\"grvsc-line\">      - address:</span>\n<span class=\"grvsc-line\">          socket_address:</span>\n<span class=\"grvsc-line\">            address: 0.0.0.0</span>\n<span class=\"grvsc-line\">            port_value: 443</span>\n<span class=\"grvsc-line\">        filter_chains:</span>\n<span class=\"grvsc-line\">        - filters:</span>\n<span class=\"grvsc-line\">          - name: envoy.http_connection_manager</span>\n<span class=\"grvsc-line\">            config:</span>\n<span class=\"grvsc-line\">              access_log:</span>\n<span class=\"grvsc-line\">              - name: envoy.file_access_log</span>\n<span class=\"grvsc-line\">                config:</span>\n<span class=\"grvsc-line\">                  path: &quot;/dev/stdout&quot;</span>\n<span class=\"grvsc-line\">              codec_type: AUTO</span>\n<span class=\"grvsc-line\">              stat_prefix: ingress_https</span>\n<span class=\"grvsc-line\">              route_config:</span>\n<span class=\"grvsc-line\">                name: local_route</span>\n<span class=\"grvsc-line\">                virtual_hosts:</span>\n<span class=\"grvsc-line\">                - name: https</span>\n<span class=\"grvsc-line\">                  domains:</span>\n<span class=\"grvsc-line\">                  - &quot;*&quot;</span>\n<span class=\"grvsc-line\">                  routes:</span>\n<span class=\"grvsc-line\">                  - match:</span>\n<span class=\"grvsc-line\">                      prefix: &quot;/api.Echo/&quot;</span>\n<span class=\"grvsc-line\">                    route:</span>\n<span class=\"grvsc-line\">                      cluster: echo-grpc</span>\n<span class=\"grvsc-line\">              http_filters:</span>\n<span class=\"grvsc-line\">              - name: envoy.health_check</span>\n<span class=\"grvsc-line\">                config:</span>\n<span class=\"grvsc-line\">                  pass_through_mode: false</span>\n<span class=\"grvsc-line\">                  headers:</span>\n<span class=\"grvsc-line\">                  - name: &quot;:path&quot;</span>\n<span class=\"grvsc-line\">                    exact_match: &quot;/healthz&quot;</span>\n<span class=\"grvsc-line\">                  - name: &quot;x-envoy-livenessprobe&quot;</span>\n<span class=\"grvsc-line\">                    exact_match: &quot;healthz&quot;</span>\n<span class=\"grvsc-line\">              - name: envoy.router</span>\n<span class=\"grvsc-line\">                config: {}</span>\n<span class=\"grvsc-line\">          tls_context:</span>\n<span class=\"grvsc-line\">            common_tls_context:</span>\n<span class=\"grvsc-line\">              tls_certificates:</span>\n<span class=\"grvsc-line\">              - certificate_chain:</span>\n<span class=\"grvsc-line\">                  filename: &quot;/etc/ssl/envoy/tls.crt&quot;</span>\n<span class=\"grvsc-line\">                private_key:</span>\n<span class=\"grvsc-line\">                  filename: &quot;/etc/ssl/envoy/tls.key&quot;</span>\n<span class=\"grvsc-line\">      clusters:</span>\n<span class=\"grvsc-line\">      - name: echo-grpc</span>\n<span class=\"grvsc-line\">        connect_timeout: 0.5s</span>\n<span class=\"grvsc-line\">        type: STRICT_DNS</span>\n<span class=\"grvsc-line\">        lb_policy: ROUND_ROBIN</span>\n<span class=\"grvsc-line\">        http2_protocol_options: {}</span>\n<span class=\"grvsc-line\">        load_assignment:</span>\n<span class=\"grvsc-line\">          cluster_name: echo-grpc</span>\n<span class=\"grvsc-line\">          endpoints:</span>\n<span class=\"grvsc-line\">          - lb_endpoints:</span>\n<span class=\"grvsc-line\">            - endpoint:</span>\n<span class=\"grvsc-line\">                address:</span>\n<span class=\"grvsc-line\">                  socket_address:</span>\n<span class=\"grvsc-line\">                    address: echo-grpc.envoy.svc.cluster.local</span>\n<span class=\"grvsc-line\">                    port_value: 8786</span>\n<span class=\"grvsc-line\">        health_checks:</span>\n<span class=\"grvsc-line\">          timeout: 1s</span>\n<span class=\"grvsc-line\">          interval: 10s</span>\n<span class=\"grvsc-line\">          unhealthy_threshold: 2</span>\n<span class=\"grvsc-line\">          healthy_threshold: 2</span>\n<span class=\"grvsc-line\">          grpc_health_check: {}</span>\n<span class=\"grvsc-line\">    admin:</span>\n<span class=\"grvsc-line\">      access_log_path: &quot;/dev/stdout&quot;</span>\n<span class=\"grvsc-line\">      address:</span>\n<span class=\"grvsc-line\">        socket_address:</span>\n<span class=\"grvsc-line\">          address: 127.0.0.1</span>\n<span class=\"grvsc-line\">          port_value: 8090</span></code></pre>\n<p>Since we will be offloading HTTPS, we are using port_value of 443. Most of the configurations are same as of sidecar envoy except for three things:</p>\n<ul>\n<li>A <strong>tls_context</strong> config is required to mention the tls certifications needed for authentication purposes.</li>\n<li>In clusters, the type has been to STATIC to STRICT_DNS which is a kind of service discovery mechanism making use of Headless service we deployed earlier.</li>\n<li>The socket_address’s address value has been changed to the FQDN of the service.</li>\n</ul>\n<p>Run:\n<code>kubectl apply -f envoy-configmap.yaml -n envoy</code></p>\n<h3 id=\"deployment-configuration\" style=\"position:relative;\"><a href=\"#deployment-configuration\" aria-label=\"deployment configuration permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Deployment Configuration</h3>\n<p><strong>envoy-deployment.yaml</strong></p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"5\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">apiVersion: apps/v1</span>\n<span class=\"grvsc-line\">kind: Deployment</span>\n<span class=\"grvsc-line\">metadata:</span>\n<span class=\"grvsc-line\">  name: envoy</span>\n<span class=\"grvsc-line\">spec:</span>\n<span class=\"grvsc-line\">  replicas: 2</span>\n<span class=\"grvsc-line\">  selector:</span>\n<span class=\"grvsc-line\">    matchLabels:</span>\n<span class=\"grvsc-line\">      app: envoy</span>\n<span class=\"grvsc-line\">  template:</span>\n<span class=\"grvsc-line\">    metadata:</span>\n<span class=\"grvsc-line\">      labels:</span>\n<span class=\"grvsc-line\">        app: envoy</span>\n<span class=\"grvsc-line\">    spec:</span>\n<span class=\"grvsc-line\">      containers:</span>\n<span class=\"grvsc-line\">      - name: envoy</span>\n<span class=\"grvsc-line\">        image: envoyproxy/envoy:v1.9.1</span>\n<span class=\"grvsc-line\">        resources: {}</span>\n<span class=\"grvsc-line\">        ports:</span>\n<span class=\"grvsc-line\">        - name: https</span>\n<span class=\"grvsc-line\">          containerPort: 443</span>\n<span class=\"grvsc-line\">        volumeMounts:</span>\n<span class=\"grvsc-line\">        - name: config</span>\n<span class=\"grvsc-line\">          mountPath: /etc/envoy</span>\n<span class=\"grvsc-line\">        - name: certs</span>\n<span class=\"grvsc-line\">          mountPath: /etc/ssl/envoy</span>\n<span class=\"grvsc-line\">        readinessProbe:</span>\n<span class=\"grvsc-line\">          httpGet:</span>\n<span class=\"grvsc-line\">            scheme: HTTPS</span>\n<span class=\"grvsc-line\">            path: /healthz</span>\n<span class=\"grvsc-line\">            httpHeaders:</span>\n<span class=\"grvsc-line\">            - name: x-envoy-livenessprobe</span>\n<span class=\"grvsc-line\">              value: healthz</span>\n<span class=\"grvsc-line\">            port: 443</span>\n<span class=\"grvsc-line\">          initialDelaySeconds: 3</span>\n<span class=\"grvsc-line\">        livenessProbe:</span>\n<span class=\"grvsc-line\">          httpGet:</span>\n<span class=\"grvsc-line\">            scheme: HTTPS</span>\n<span class=\"grvsc-line\">            path: /healthz</span>\n<span class=\"grvsc-line\">            httpHeaders:</span>\n<span class=\"grvsc-line\">            - name: x-envoy-livenessprobe</span>\n<span class=\"grvsc-line\">              value: healthz</span>\n<span class=\"grvsc-line\">            port: 443</span>\n<span class=\"grvsc-line\">          initialDelaySeconds: 10</span>\n<span class=\"grvsc-line\">      volumes:</span>\n<span class=\"grvsc-line\">      - name: config</span>\n<span class=\"grvsc-line\">        configMap:</span>\n<span class=\"grvsc-line\">          name: envoy-conf</span>\n<span class=\"grvsc-line\">      - name: certs</span>\n<span class=\"grvsc-line\">        secret:</span>\n<span class=\"grvsc-line\">          secretName: envoy-certs</span></code></pre>\n<p>Run:\n<code>kubectl apply -f envoy-deployment.yaml -n envoy</code></p>\n<h1 id=\"testing\" style=\"position:relative;\"><a href=\"#testing\" aria-label=\"testing permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Testing</h1>\n<p>Proto file for the echo-grpc service:</p>\n<p><strong>ccho.proto:</strong></p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"6\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">syntax = &quot;proto3&quot;;</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">package api;</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">service Echo {</span>\n<span class=\"grvsc-line\">  rpc Echo (EchoRequest) returns (EchoResponse) {}</span>\n<span class=\"grvsc-line\">}</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">message EchoRequest {</span>\n<span class=\"grvsc-line\">  string content = 1;</span>\n<span class=\"grvsc-line\">}</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">message EchoResponse {</span>\n<span class=\"grvsc-line\">  string content = 1;</span>\n<span class=\"grvsc-line\">}</span></code></pre>\n<p>Run the following command to call the server:\n<code>grpcurl -d '{\"content\": \"echo\"}' -proto echo.proto -insecure -v &#x3C;load_balancer_or_external_ip>:443 api.Echo/Echo</code></p>\n<p>The output will be similar to something like this:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"7\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">Resolved method descriptor:</span>\n<span class=\"grvsc-line\">rpc Echo ( .api.EchoRequest ) returns ( .api.EchoResponse );</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">Request metadata to send:</span>\n<span class=\"grvsc-line\">(empty)</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">Response headers received:</span>\n<span class=\"grvsc-line\">content-type: application/grpc</span>\n<span class=\"grvsc-line\">date: Wed, 27 Feb 2019 04:40:19 GMT</span>\n<span class=\"grvsc-line\">hostname: echo-grpc-5c4f59c578-wcsvr</span>\n<span class=\"grvsc-line\">server: envoy</span>\n<span class=\"grvsc-line\">x-envoy-upstream-service-time: 0</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">Response contents:</span>\n<span class=\"grvsc-line\">{</span>\n<span class=\"grvsc-line\">  &quot;content&quot;: &quot;echo&quot;</span>\n<span class=\"grvsc-line\">}</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">Response trailers received:</span>\n<span class=\"grvsc-line\">(empty)</span>\n<span class=\"grvsc-line\">Sent 1 request and received 1 response</span></code></pre>\n<p>Run the above command multiple times and check the value of the hostname field every time which will contain the pod name of one of the 3 pods deployed. </p>\n<h1 id=\"references\" style=\"position:relative;\"><a href=\"#references\" aria-label=\"references permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>References</h1>\n<ul>\n<li>Article: <a href=\"https://cloud.google.com/solutions/exposing-grpc-services-on-gke-using-envoy-proxy\">Using Envoy Proxy to load-balance gRPC services on GKE</a></li>\n<li><a href=\"https://kubernetes.io/docs/concepts/services-networking/service/#headless-services\">Headless service</a></li>\n</ul>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n  }\n  \n  .grvsc-code {\n    display: inline-block;\n    min-width: 100%;\n  }\n  \n  .grvsc-line {\n    display: inline-block;\n    box-sizing: border-box;\n    width: 100%;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-line-highlighted {\n    background-color: var(--grvsc-line-highlighted-background-color, transparent);\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, transparent);\n  }\n  \n  .dark-default-dark {\n    background-color: #1E1E1E;\n    color: #D4D4D4;\n  }\n</style>","frontmatter":{"date":"July 06, 2020","updated_date":null,"title":"Service Mesh with Envoy","tags":["Service Mesh","Envoy","Microservices"],"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.834862385321101,"src":"/static/f5fbebaefd091eb3f33c225fa71b0814/14b42/front-image.jpg","srcSet":"/static/f5fbebaefd091eb3f33c225fa71b0814/f836f/front-image.jpg 200w,\n/static/f5fbebaefd091eb3f33c225fa71b0814/2244e/front-image.jpg 400w,\n/static/f5fbebaefd091eb3f33c225fa71b0814/14b42/front-image.jpg 800w,\n/static/f5fbebaefd091eb3f33c225fa71b0814/47498/front-image.jpg 1200w,\n/static/f5fbebaefd091eb3f33c225fa71b0814/0e329/front-image.jpg 1600w,\n/static/f5fbebaefd091eb3f33c225fa71b0814/6ed45/front-image.jpg 2100w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Piyush Kumar","github":"kpiyush17","avatar":null}}}}]}},"pageContext":{"tag":"Service Mesh"}},"staticQueryHashes":["1171199041","1384082988","2100481360","23180105","528864852"]}