<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Souradeep Nanda on Medium]]></title>
        <description><![CDATA[Stories by Souradeep Nanda on Medium]]></description>
        <link>https://medium.com/@souradeepnanda?source=rss-4cd84a65549b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*4bcvfWLlB1auGfvW.</url>
            <title>Stories by Souradeep Nanda on Medium</title>
            <link>https://medium.com/@souradeepnanda?source=rss-4cd84a65549b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 10:15:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@souradeepnanda/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Unit Test Recorder: Automatically generate unit tests as you use your application]]></title>
            <link>https://medium.com/@souradeepnanda/unit-test-recorder-automatically-generate-unit-tests-as-you-use-your-application-eb500a312361?source=rss-4cd84a65549b------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb500a312361</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[software-testing]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[babeljs]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Souradeep Nanda]]></dc:creator>
            <pubDate>Thu, 25 Jun 2020 02:40:32 GMT</pubDate>
            <atom:updated>2020-06-25T02:40:32.147Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wAcjSb5AgU6qrsG-TUDgCw.png" /><figcaption>Input code on left and generated code on right.</figcaption></figure><p>This is a write up for the npm package <a href="https://www.npmjs.com/package/unit-test-recorder">unit-test-recorder</a> or UTR for short.</p><p>The package is a CLI tool, which enables the user to record the activities flowing through every function in the nodejs application. This can then be turned into working unit test cases by string interpolation.</p><p>This tool is meant to be used for <a href="https://en.wikipedia.org/wiki/Regression_testing">regression testing</a> using <a href="https://jestjs.io/docs/en/snapshot-testing">snapshots</a>.</p><p>The generated snapshots are human readable and editable code. The users are encouraged to take it forward and make changes to this code directly.</p><h3>Methodology</h3><p>In testing, we pass some arguments to the function under test and expect some result in return. If we are confident that the function in question is stable, then we can record the parameters and result as ground truth.</p><p>In order to record the parameters and results, we need to make some changes to the code itself. This process is called <em>instrumentation</em>. Instrumenters are used in many places including code coverage runners like <a href="https://github.com/istanbuljs/istanbuljs">istanbuljs</a> and monitoring services like <a href="https://github.com/newrelic/node-newrelic">new relic</a>.</p><p>UTR uses <a href="https://github.com/babel/babel">babeljs</a> for injecting the recorder in the code.</p><h3>Recording functions</h3><p>Lets take this function as an example</p><pre>const foo = (a, b) =&gt; a + b;</pre><p>UTR uses babel to explicitly instrument it to</p><pre>const foo = (...p) =&gt; recorderWrapper(<br>  { name: &#39;foo&#39;, fileName: &#39;bar&#39; },<br>  (a, b) =&gt; a + b,<br>  ...p,<br>);</pre><p>The recorderWrapper function is provided by UTR. The function below is a simplified version of its implementation.</p><pre>const recorderWrapper = (meta, fn, ...p) =&gt; {<br>  const result = fn(...p);<br>  Recorder.record({ meta, result, params: p });<br>  return result;<br>};</pre><p>The meta property stores additional information regarding the nature of the function. e.g. The file name where the function was located, whether it returns a promise, whether it is the default export or named export and alike.</p><p>This function records all calls to this function in a state. Here is a simplified representation of the state.</p><pre>{<br>  &quot;fileName&quot;:{<br>    &quot;functionName&quot;:{<br>      &quot;captures&quot;:[<br>        { &quot;params&quot;: [1, 2], &quot;result&quot;: 3 },<br>        { &quot;params&quot;: [2, 3], &quot;result&quot;: 5 },<br>      ]<br>    }<br>  }<br>}</pre><p>Now using string interpolation, we can generate test cases.</p><pre>describe(&#39;fileName&#39;, () =&gt; {<br>  describe(&#39;functionName&#39;, () =&gt; {<br>    it(&#39;test 1&#39;, () =&gt; {<br>      expect(foo(1, 2)).toEqual(3);<br>    });<br>    it(&#39;test 2&#39;, () =&gt; {<br>      expect(foo(2, 3)).toEqual(5);<br>    });<br>  });<br>});</pre><h3>Recording mocks</h3><p>For recording mocks, we need to record all invocations of the imported function and correlate it to the function we are currently recording.</p><pre>const fs = require(&#39;fs&#39;);</pre><pre>const foo = (fileName) =&gt; fs.readFileSync(fileName).toString().toUpperCase();</pre><pre>const bar = (fileName) =&gt; fs.readFileSync(fileName).toString().toLowerCase();</pre><pre>const baz = (f1, f2) =&gt; foo(f1) + bar(f2);</pre><p>The problem being, if we instrument the mocked function naively, we would have no way to know which function invoked the mocked function.</p><pre>fs.wrappedReadFileSync = (...p) =&gt; recorderWrapper(<br>  { name: &#39;fs.readFileSync&#39; },<br>  fs.readFileSync, // There is no way to know if foo invoked the function or bar or baz<br>  ...p,<br>);</pre><pre>const foo = (...p) =&gt; recorderWrapper(<br>  { name: &#39;foo&#39; },<br>  (fileName) =&gt; fs.wrappedReadFileSync(fileName).toString().toUpperCase(),<br>  ...p,<br>);</pre><pre>const bar = (...p) =&gt; recorderWrapper(<br>  { name: &#39;bar&#39; },<br>  (fileName) =&gt; fs.wrappedReadFileSync(fileName).toString().toUpperCase(),<br>  ...p,<br>);</pre><pre>const baz = (...p) =&gt; recorderWrapper(<br>  { name: &#39;baz&#39; },<br>  (f1, f2) =&gt; foo(f1) + bar(f2),<br>  ...p,<br>);</pre><p>Therefore the recorderWrapper for the fs.readFileSync must be aware of the JavaScript call stack or the <a href="https://jlongster.com/Whats-in-a-Continuation">continuation</a>. <a href="https://github.com/Jeff-Lewis/cls-hooked">Continuation local storage</a> is a popular JavaScript library built for this purpose. However in nodejs 13 and onward, native support exists in the form of <a href="https://nodejs.org/api/async_hooks.html#async_hooks_class_asynclocalstorage">AsyncLocalStorage</a>.</p><p>To illustrate we now use two separate wrappers mockRecorderWrapper and functionRecorderWrapper.</p><pre>const functionRecorderWrapper = (meta, fn, ...p) =&gt; {<br>  // Set the meta so that all invoked functions have access to it<br>  cls.set(&#39;meta&#39;, meta);<br>  return recorderWrapper(meta, fn, ...p);<br>};</pre><pre>const mockRecorderWrapper = (mockMeta, fn, ...p) =&gt; {<br>  // Get the meta of the function that invoked this mock<br>  const invokerMeta = cls.get(&#39;meta&#39;);<br>  // Use invoker meta to make sure the recordings are correlated correctly<br>  return recorderWrapper({ ...mockMeta, ...invokerMeta }, fn, ...p);<br>};</pre><p>Now, if the mocked function is invoked multiple times, we can save the sequence in an array</p><pre>{<br>  &quot;foo&quot;: [<br>    {&quot;moduleName&quot;: &quot;fs&quot;, &quot;functionName&quot;: &quot;readFileSync&quot;, &quot;params&quot;: [ &quot;file1&quot; ], &quot;result&quot;: &quot;file1_contents&quot; },<br>  ],<br>  &quot;bar&quot;: [<br>    {&quot;moduleName&quot;: &quot;fs&quot;, &quot;functionName&quot;: &quot;readFileSync&quot;, &quot;params&quot;: [ &quot;file1&quot; ], &quot;result&quot;: &quot;file1_contents&quot; },<br>  ],<br>  &quot;baz&quot;: [<br>    {&quot;moduleName&quot;: &quot;fs&quot;, &quot;functionName&quot;: &quot;readFileSync&quot;, &quot;params&quot;: [ &quot;file1&quot; ], &quot;result&quot;: &quot;file1_contents&quot; },<br>    {&quot;moduleName&quot;: &quot;fs&quot;, &quot;functionName&quot;: &quot;readFileSync&quot;, &quot;params&quot;: [ &quot;file2&quot; ], &quot;result&quot;: &quot;file2_contents&quot; },<br>  ]<br>}</pre><p>The generated tests look like so</p><pre>const fs = require(&#39;fs&#39;);</pre><pre>jest.mock(&#39;fs&#39;);</pre><pre>describe(&#39;fileName&#39;, () =&gt; {<br>  describe(&#39;baz&#39;, () =&gt; {<br>    it(&#39;test 1&#39;, () =&gt; {<br>      fs.readFileSync.mockImplementationOnce(&#39;file1_contents&#39;);<br>      fs.readFileSync.mockImplementationOnce(&#39;file2_contents&#39;);<br>      // baz is invoking foo and bar. They inturn are consuming the mocks<br>      expect(baz(&#39;file1&#39;, &#39;file2&#39;)).toEqual(&#39;FILE1_CONTENTSfile2_contents&#39;);<br>    });<br>  });<br>});</pre><h3>Dependency injections</h3><p>Another common programming pattern in JavaScript involves using dependency injections. Often database clients are passed to functions like the example below.</p><pre>const foo = async (dbClient) =&gt; {<br>  const rows = await dbClient.query(&#39;SELECT COUNT(*) as usercount FROM users;&#39;);<br>  return rows[0].usercount;<br>};</pre><p>In order to generate tests for the function foo, we need to record the query function of the dbClient argument. However, if we modify the dbClient.query function itself, it can lead to unintended side effects. Instead we create a new function at run time and use babel to modify the source code to make sure the new created function will be used.</p><pre>const foo = async (dbClient) =&gt; {<br>  const rows = await dbClient.wrappedQuery(&#39;SELECT COUNT(*) as usercount FROM users;&#39;);<br>  return rows[0].usercount;<br>};</pre><p>The code below is a simplified version of the actual implementation</p><pre>// Executed before the function is executed<br>const preExecutionHook = (wrappingMeta) =&gt; {<br>  // wrappingMeta looks similar to { objectName: &#39;dbClient&#39;, fnName: &#39;query&#39; };<br>  const { fnName } = wrappingMeta;<br>  const newFnName = generateNewFnName(wrappingMeta); // &quot;wrappedQuery&quot; in this case<br>  // dbClient.wrappedQuery created at runtime<br>  dbClient[newFnName] = (...p) =&gt; {<br>    const invokerMeta = cls.get(&#39;meta&#39;);<br>    const fn = dbClient[fnName];<br>    return recorderWrapper({ ...wrappingMeta, ...invokerMeta }, fn, ...p);<br>  };<br>};</pre><p>In the generated tests, we mock the methods of the injected object like so</p><pre>describe(&#39;fileName&#39;, () =&gt; {<br>  describe(&#39;foo&#39;, () =&gt; {<br>    it(&#39;test 1&#39;, () =&gt; {<br>      const dbClient = {};<br>      dbClient.query.mockImplementationOnce([{ usercount: 20 }]);<br>      expect(foo(dbClient)).toEqual(20);<br>    });<br>  });<br>});</pre><h3>Injection promotions</h3><p>To make the test generation process data efficient, we use injection promotions. In the example below, even if the function bar is never invoked separately, we can piggyback on the invocation of foo to generate tests for both foo and bar.</p><pre>const bar = (client, status) =&gt; client.query(&#39;SELECT COUNT(*) FROM users WHERE status=$1&#39;, status);</pre><pre>const foo = async (dbClient) =&gt; {<br>  const offlineUsers = await bar(dbClient, &#39;offline&#39;);<br>  const activeUsers = await dbClient.query(&#39;SELECT COUNT(*) FROM users WHERE status=$1&#39;, &#39;active&#39;);<br>  const awayUsers = await bar(dbClient, &#39;away&#39;);<br>  return { offlineUsers, activeUsers, awayUsers };<br>};</pre><p>Although testing foo also covers bar, the separate tests for bar act as scaffolding for any future modifications to the function bar. Hence, the design decision.</p><p>The generated tests look like so</p><pre>describe(&#39;fileName&#39;, () =&gt; {<br>  describe(&#39;bar&#39;, () =&gt; {<br>    it(&#39;test 1&#39;, () =&gt; {<br>      const dbClient = {};<br>      dbClient.query.mockImplementationOnce(10);<br>      expect(bar(dbClient, &#39;offline&#39;)).toEqual(10);<br>    });<br>    it(&#39;test 2&#39;, () =&gt; {<br>      const dbClient = {};<br>      dbClient.query.mockImplementationOnce(30);<br>      expect(bar(dbClient, &#39;away&#39;)).toEqual(30);<br>    });<br>  });<br>  describe(&#39;foo&#39;, () =&gt; {<br>    it(&#39;test 1&#39;, () =&gt; {<br>      const dbClient = {};<br>      dbClient.query.mockImplementationOnce(10); // Promoted from bar<br>      dbClient.query.mockImplementationOnce(20);<br>      dbClient.query.mockImplementationOnce(30); // Promoted from bar<br>      const expected = { offlineUsers: 10, activeUsers: 20, awayUsers: 30 };<br>      expect(foo(dbClient)).toEqual(expected);<br>    });<br>  });<br>});</pre><p>Promotions are handled internally by maintaining an implicit stack. When a function’s scope ends, all the recorded dependency injections are passed on to its parent.</p><p>We use uuidv4 to correctly identify injected functions for promotions as variable names need not be consistent between parent and child.</p><ul><li>1st invocation to dbClient.query</li></ul><pre>fooCaptures = {<br>  captures: [], // foo has not called dbClient.query yet<br>};<br>barCaptures = {<br>  captures: [<br>    {<br>      injectedFunctionUUid: &#39;uuid1&#39;,<br>      params: [<br>        &#39;SELECT COUNT(*) FROM users WHERE status=$1&#39;,<br>        &#39;offline&#39;,<br>      ],<br>      result: 10,<br>    },<br>  ],<br>};</pre><pre>// When bar finishes, the captures are promoted to its parent<br>fooCaptures = {<br>  captures: [<br>    {<br>      injectedFunctionUUid: &#39;uuid1&#39;,<br>      params: [<br>        &#39;SELECT COUNT(*) FROM users WHERE status=$1&#39;,<br>        &#39;offline&#39;,<br>      ],<br>      result: 10,<br>    },<br>  ],<br>};</pre><ul><li>2nd invocation to dbClient.query</li></ul><pre>// When foo invokes dbClient.query directly, it gets added to the captures array<br>fooCaptures = {<br>  captures: [<br>    {<br>      injectedFunctionUUid: &#39;uuid1&#39;,<br>      params: [<br>        &#39;SELECT COUNT(*) FROM users WHERE status=$1&#39;,<br>        &#39;offline&#39;,<br>      ],<br>      result: 10,<br>    },<br>    {<br>      injectedFunctionUUid: &#39;uuid1&#39;,<br>      params: [<br>        &#39;SELECT COUNT(*) FROM users WHERE status=$1&#39;,<br>        &#39;active&#39;,<br>      ],<br>      result: 20,<br>    },<br>  ],<br>};</pre><ul><li>3rd invocation to dbClient.query</li></ul><pre>// Foo stack so far<br>fooCaptures = {<br>  captures: [<br>    {<br>      injectedFunctionUUid: &#39;uuid1&#39;,<br>      params: [<br>        &#39;SELECT COUNT(*) FROM users WHERE status=$1&#39;,<br>        &#39;offline&#39;,<br>      ],<br>      result: 10,<br>    },<br>    {<br>      injectedFunctionUUid: &#39;uuid1&#39;,<br>      params: [<br>        &#39;SELECT COUNT(*) FROM users WHERE status=$1&#39;,<br>        &#39;active&#39;,<br>      ],<br>      result: 20,<br>    },<br>  ],<br>};</pre><pre>// When bar is invoked, the injections are captured for bar<br>barCaptures = {<br>  captures: [<br>    {<br>      injectedFunctionUUid: &#39;uuid1&#39;,<br>      params: [<br>        &#39;SELECT COUNT(*) FROM users WHERE status=$1&#39;,<br>        &#39;away&#39;,<br>      ],<br>      result: 30,<br>    },<br>  ],<br>};</pre><pre>// Finally, when scope of bar ends, injections are promoted<br>fooCaptures = {<br>  captures: [<br>    {<br>      injectedFunctionUUid: &#39;uuid1&#39;,<br>      params: [<br>        &#39;SELECT COUNT(*) FROM users WHERE status=$1&#39;,<br>        &#39;offline&#39;,<br>      ],<br>      result: 10,<br>    },<br>    {<br>      injectedFunctionUUid: &#39;uuid1&#39;,<br>      params: [<br>        &#39;SELECT COUNT(*) FROM users WHERE status=$1&#39;,<br>        &#39;active&#39;,<br>      ],<br>      result: 20,<br>    },<br>    {<br>      injectedFunctionUUid: &#39;uuid1&#39;,<br>      params: [<br>        &#39;SELECT COUNT(*) FROM users WHERE status=$1&#39;,<br>        &#39;away&#39;,<br>      ],<br>      result: 30,<br>    },<br>  ],<br>};</pre><h3>Conclusion</h3><p>Other than the usual benefits of software testing, this is also a quick and inexpensive way to generate a dataset of test code, corresponding to a corpora of existing code. This can be used by researchers working on deep learning based code generation tools.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb500a312361" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to migrate from vanilla Kubernetes to Istio service mesh?]]></title>
            <link>https://faun.pub/how-to-migrate-from-vanilla-kubernetes-to-istio-service-mesh-ac41b17ad724?source=rss-4cd84a65549b------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac41b17ad724</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[istio]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[istio-service-mesh]]></category>
            <category><![CDATA[service-mesh]]></category>
            <dc:creator><![CDATA[Souradeep Nanda]]></dc:creator>
            <pubDate>Mon, 14 Oct 2019 12:36:14 GMT</pubDate>
            <atom:updated>2019-10-18T09:44:45.667Z</atom:updated>
            <content:encoded><![CDATA[<p>The goal of this guide is to give the reader the most concise and non-intimidating introduction to istio while simultaneously providing further reading material if it piques his interest.</p><p>Before we start with the installation, let us compare it with vanilla Kubernetes.</p><h3>Template flow vanilla vs istio</h3><p>Instead of ingress, we have gateways which connect to virtual services. Everything else downstream remains the same.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CEsSeHK4UJMqSSfq.png" /></figure><h3>Why virtual services?</h3><p>Virtual services provide many features like <a href="https://istio.io/docs/tasks/traffic-management/traffic-shifting/">infra level AB testing</a>, <a href="https://istio.io/docs/tasks/traffic-management/fault-injection/">fault injection</a>, <a href="https://istio.io/docs/tasks/traffic-management/circuit-breaking/">circuit breaking</a> and a <a href="https://istio.io/docs/tasks/">lot more</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/0*4CsvtPCSS_HNcHoV.png" /></figure><h3>Packet flow</h3><h3>Out to in</h3><p>Whenever a new deployment is created in an <a href="https://istio.io/docs/setup/additional-setup/sidecar-injection/#automatic-sidecar-injection">istio-injected namespace</a> an <a href="https://www.envoyproxy.io/docs/envoy/latest/intro/what_is_envoy">envoy container</a> is inserted into the pod. It is widely referred to as <em>sidecar</em>. It automatically intercepts all incoming and outgoing requests. The application does not need to worry about this abstraction.</p><blockquote><strong><em>TIP:</em></strong><em> Reading the logs of the envoy is useful for debugging</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*v8eLD5tl-_gfXcp8.png" /></figure><h3>Intra cluster</h3><p>One of the benefits of having the envoy is that we can have <a href="https://istio.io/docs/tasks/security/mutual-tls/">mutual TLS</a> secured connections inside the cluster. It helps in the realization of <a href="https://blog.aquasec.com/istio-kubernetes-security-zero-trust-networking">zero-trust networks</a>.</p><p>One of the functions of the <a href="https://www.youtube.com/watch?v=fqour4ZBzHg">pilot</a> is being a <a href="https://www.youtube.com/watch?v=NrzrpyMLWes">service discovery service</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ptfOusoc2X-mzxyu.png" /></figure><h3>Installation</h3><blockquote><em>This guide was written during istio 1.3.x, if things have changed too much in the future, consider consulting the official documentation.</em></blockquote><p>We will be installing istio for Kubernetes cluster using helm charts.</p><p>You can find the detailed process in <a href="https://istio.io/docs/setup/install/helm/">istio official website</a>, but here is a quick version.</p><p>First, make sure helm and helm tiler is installed. For more details on helm, refer to the <a href="https://helm.sh/docs/using_helm/">official guide</a>.</p><pre>brew install helm<br>helm init</pre><p>In case you are unable to install helm tiler for some reason, you can just <a href="https://stackoverflow.com/questions/50584091/helm-export-yaml-files-locally-just-use-templating-engine-do-not-send-to-kuber">export the helm charts as k8s templates</a>.</p><p>Next, we install istio</p><pre># First we create the namespace for istio<br>kubectl create namespace istio-system</pre><pre># Add the helm repo<br>helm repo add istio.io https://storage.googleapis.com/istio-release/releases/1.3.1/charts/</pre><pre># Istio bootstrapper <br># (make sure this process finishes, the pods should be in &quot;finished&quot; state)<br>helm install istio.io/istio-init --name istio-init --namespace istio-system</pre><pre># Should be 23 (at time of writing this guide)<br># kubectl get crds | grep &#39;istio.io&#39; | wc -l</pre><pre># Actual istio<br># You can read about SDS over here (https://preliminary.istio.io/docs/tasks/traffic-management/ingress/secure-ingress-sds/)<br>helm install istio.io/istio --name istio --set gateways.istio-ingressgateway.sds.enabled=true --set sds.enabled=true --namespace istio-system</pre><pre># Verify the installation<br># kubectl get svc -n istio-system<br># kubectl get deployment -n istio-system</pre><p>In order for deployments in your namespace to use istio, we need to enable istio injection.</p><blockquote><strong><em>IMPORTANT:</em></strong><em> You have to delete and recreate your existing deployments.</em></blockquote><blockquote><strong><em>IMPORTANT:</em></strong><em> You don’t have to inject </em><em>istio-system.</em></blockquote><pre># The following command enables injection in the potato namespace<br>kubectl label namespace potato istio-injection=enabled</pre><pre># To verify<br>kubectl get namespace -L istio-injection</pre><p>Next, you need to create a gateway. Use this one as a sample.</p><pre>apiVersion: networking.istio.io/v1alpha3<br>kind: Gateway<br>metadata:<br>  name: my-gateway<br>  namespace: istio-system<br>spec:<br>  selector:<br>    istio: ingressgateway # use Istio default gateway implementation<br>  servers:<br>    - port:<br>        number: 80<br>        name: http<br>        protocol: HTTP<br>      hosts:<br>          # - yourdomain.com<br>          - &#39;*&#39; # Allow everything<br>      # Uncomment next two lines if you dont want any insecure connections<br>      # to your website<br>      # tls:<br>      #   httpsRedirect: true # sends 301 redirect for http requests</pre><pre>    # Uncomment next block if you want HTTPS<br>    # - port:<br>    #     number: 443<br>    #     name: https<br>    #     protocol: HTTPS<br>    #   hosts:<br>    #     - yourdomain.com<br>    #   tls:<br>    #     mode: SIMPLE<br>    #     credentialName: your.secret</pre><p>You would also need virtual services to bridge gateways to services. Use this one as a sample.</p><pre>apiVersion: networking.istio.io/v1alpha3<br>kind: VirtualService<br>metadata:<br>  name: tomato-virtual-service<br>  namespace: potato<br>spec:<br>  gateways:<br>    - istio-system/my-gateway # namespace-where-gateway-is/gateway-name<br>  hosts:<br>    # - mydomain.com<br>    - &#39;*&#39; # Allow everything<br>  http:<br>  - match:<br>    - uri:<br>        prefix: /tomato<br>    rewrite:<br>      uri: /<br>    route:<br>    - destination:<br>        # Name of the service we want to connect to<br>        host: tomato.potato.svc.cluster.local # service-name.namespace.svc.cluster.local<br>        port:<br>          number: 8080 # Port forwarded by the service<br>      weight: 100</pre><p>Everything from service and below is the same as vanilla Kubernetes.</p><blockquote><strong><em>TROUBLESHOOTING:</em></strong><em> The </em><em>ingress-gateway in </em><em>istio-system pod is the load balancer. If you are unable to find the external IP of the cluster, try the external IP of the node running this pod. You can read more </em><a href="https://istio.io/docs/tasks/traffic-management/ingress/ingress-control/#determining-the-ingress-ip-and-ports"><em>here</em></a><em>.</em></blockquote><h3>Installing istioctl (optional)</h3><pre>cd ~/<br>curl -L https://git.io/getLatestIstio<br>export PATH=&quot;$PATH:~/istio-1.3.0-rc.3/bin&quot; # Assuming the version is 1.3.0</pre><h3>Troubleshooting</h3><ol><li>Read the pod logs (Start with ingress-gateway, pilot, envoys). <a href="https://istio.io/docs/ops/troubleshooting/proxy-cmd/">Further reading</a>.</li><li>Kill all the pods in istio-system</li><li>Delete and create the gateway again</li><li>Install <a href="https://www.kiali.io/documentation/getting-started/#_installation">kiali</a> bash &lt;(curl -L https://git.io/getLatestKialiOperator) --accessible-namespaces &#39;**&#39;</li><li>Run <a href="https://stackoverflow.com/a/57920503/1217998">this</a> to get a dump of all routes connected to the gateway. (requires istioctl)</li><li>Watch these two videos. <a href="https://www.youtube.com/watch?v=FbYBO7Pi2d8">#1</a> <a href="https://www.youtube.com/watch?v=7cINRP0BFY8">#2</a></li></ol><p>If all fails you can <a href="https://stackoverflow.com/questions/51594064/what-is-ther-purpose-of-helm-delete-purge">helm delete — purge istio</a>, then kubectl delete namespace istio-system and start over again.</p><p>Good luck.</p><h3>Jargon</h3><ul><li>Envoy — Proxy inside your pods which intercepts all network traffic</li><li>Sidecar — The injected envoy container in your pods</li><li>Mixer — Collects telemetry and enforces usage policies.</li><li>Pilot — Service discovery service</li><li>Citadel — Key management service</li><li>Galley — Configuration validation</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/0*Piks8Tu6xUYpF4DU" /></figure><p><strong>Follow us on </strong><a href="https://twitter.com/joinfaun"><strong>Twitter</strong></a><strong> </strong>🐦<strong> and </strong><a href="https://www.facebook.com/faun.dev/"><strong>Facebook</strong></a><strong> </strong>👥<strong> and join our </strong><a href="https://www.facebook.com/groups/364904580892967/"><strong>Facebook Group</strong></a><strong> </strong>💬<strong>.</strong></p><p><strong>To join our community Slack </strong>🗣️ <strong>and read our weekly Faun topics </strong>🗞️,<strong> click here⬇</strong></p><figure><a href="https://www.faun.dev/join/?utm_source=medium.com%2Ffaun&amp;utm_medium=medium&amp;utm_campaign=faunmediumbanner"><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oSdFkACJxs5iy1oR" /></a></figure><h4>If this post was helpful, please click the clap 👏 button below a few times to show your support for the author! ⬇</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac41b17ad724" width="1" height="1" alt=""><hr><p><a href="https://faun.pub/how-to-migrate-from-vanilla-kubernetes-to-istio-service-mesh-ac41b17ad724">How to migrate from vanilla Kubernetes to Istio service mesh?</a> was originally published in <a href="https://faun.pub/">FAUN.dev() 🐾</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>