<?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 Gimhan Ranasinghe on Medium]]></title>
        <description><![CDATA[Stories by Gimhan Ranasinghe on Medium]]></description>
        <link>https://medium.com/@gimhanranasinghe?source=rss-34fdd42c10ed------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*rh2JIuXH7RjEBcT8-UuCXA.jpeg</url>
            <title>Stories by Gimhan Ranasinghe on Medium</title>
            <link>https://medium.com/@gimhanranasinghe?source=rss-34fdd42c10ed------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 17:18:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gimhanranasinghe/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[Connecting AWS Cloud9 to Bitbucket or Github]]></title>
            <link>https://medium.com/@gimhanranasinghe/connecting-aws-cloud9-to-bitbucket-or-github-025f1bc2f5df?source=rss-34fdd42c10ed------2</link>
            <guid isPermaLink="false">https://medium.com/p/025f1bc2f5df</guid>
            <dc:creator><![CDATA[Gimhan Ranasinghe]]></dc:creator>
            <pubDate>Tue, 19 Mar 2024 16:30:19 GMT</pubDate>
            <atom:updated>2024-03-19T16:30:19.456Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qJkGGb9ZPQslwG5fCPU2JA.png" /></figure><p>AWS Cloud9 is a cloud-based integrated development environment (IDE) that lets you write, run, and debug your code with just a browser. It includes a code editor, debugger, and terminal. It’s designed to be easy to use, allowing developers to start coding quickly, regardless of their experience level. In order to enable versioning we can connect Github or Bitbucket to cloud9. I will be discussing the steps which is related to Bitbucket, but you can use the same steps for Github as well.</p><h4><strong>Step 1 : Generate SSH Key in Cloud9</strong></h4><p>1. First you have to open your Cloud9 environment and open a terminal. Then generate a new SSH key by running the following command.</p><pre>ssh-keygen -t rsa -b 4096 -C &quot;&lt;your_email&gt;&quot;</pre><p><em>&lt;your_email&gt; should be replaced by your Bitbucket email address.</em></p><p>2. After running the above command, <strong>it will prompt to “Enter a file in which to save the key”. Press enter to accept the default location.</strong></p><p>3. Start the SSH agent in the background using following command.</p><pre>eval &quot;$(ssh-agent -s)&quot;</pre><p>4. For adding your SSH private key to the ssh-agent use following command.</p><pre>ssh-add ~/.ssh/id_rsa</pre><h4>Step 2: Add SSH Key to Bitbucket</h4><p>1. Copy your SSH public key to your clipboard. You can do this by running:</p><pre>cat ~/.ssh/id_rsa.pub</pre><p>2. Add copied SSH public key to Bitbucket/Github.</p><p>In Bitbucket, navigate to SSH keys under the “Security” section. Click on “Add key”, paste your public key into the “Key” field, give it a title, and click “Add key.” <em>In Github, go to setting and under Access, you can find SSH and GPG keys section.</em></p><h4>Step 3: Clone your Repository</h4><p>1. Find the SSH URL of your Bitbucket repository.</p><p>You can copy the SSH URL from the repository. After executing that command in the terminal of Cloud9, you will be able to clone the whole code from the repository.</p><h4>Step 4: Push and Pull Code</h4><p>1. Configure Git with Your Global Username and Email.</p><pre>git config - global user.email &quot;&lt;your_email&gt;&quot;<br>git config - global user.name &quot;&lt;user_name&gt;&quot;</pre><p>Now you can do push, pull and other operations to the code base through terminal or using git icon which is located in the side bar.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=025f1bc2f5df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Istio built-in Profiles & Customizing the configuration]]></title>
            <link>https://medium.com/@gimhanranasinghe/istio-built-in-profiles-customizing-the-configuration-ff49d0afa825?source=rss-34fdd42c10ed------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff49d0afa825</guid>
            <dc:creator><![CDATA[Gimhan Ranasinghe]]></dc:creator>
            <pubDate>Fri, 30 Jun 2023 04:04:19 GMT</pubDate>
            <atom:updated>2023-06-30T04:04:19.810Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vsg6mAXbDfKestcnlCs_UA.jpeg" /></figure><h3>Introduction</h3><p>Istio profiles offer a mechanism to set up and customize the Istio service mesh’s behavior. Istio is an open-source platform that offers capabilities like traffic management, observability, security, and policy enforcement to make managing microservices-based architectures easier. You can customize the behavior of the service mesh to meet your unique needs by defining sets of configuration settings that can be applied to your services using Istio profiles.</p><h3>Istio Different Profiles</h3><p>There are different built-in configuration profiles for Istio. The following built-in configuration profiles are currently available:</p><ol><li>Default<br>This enables components according to the default settings of the IstioOperator API. <strong><em>This profile is recommended for production deployments and for primary clusters in a multi-cluster mesh.</em></strong></li><li>Demo<br>This configuration designed to showcase Istio functionality with modest resource requirements. It is suitable to run the Bookinfo application ( Sample application Istio provides — <a href="https://medium.com/@gimhanranasinghe/the-istio-service-mesh-building-service-mesh-on-istio-part-1-8ca060bffc27">Build Istio service mesh with Bookinfo application</a> ) and associated tasks.<br><strong><em>This profile enables high levels of tracing and access logging so it is not suitable for performance tests.</em></strong></li><li>Minimal<br>This is same as the default profile, but only the control plane components are installed. This allows you to configure the control plane and data plane components (e.g., gateways) using separate profiles.</li><li>Remote<br>This is used for configuring a remote cluster that is managed by an external control plane or by a control plane in a primary cluster of a multi-cluster mesh.</li><li>Empty<br>This deploys nothing. This can be useful as a base profile for custom configuration.</li><li>Preview<br>The preview profile contains features that are experimental. This is intended to explore new features coming to Istio. Stability, security, and performance are not guaranteed — use at your own risk.</li></ol><p>Following table shows you a summery of different profiles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*I17BYyqNhi5s7Dr9kcV6Cg.png" /></figure><h3>“DEMO” Profile vs “DEFAULT” Profile</h3><p>You can display the profile settings by running the following command.</p><ul><li><em>For Demo Profile settings</em></li></ul><pre>istioctl profile dump demo</pre><ul><li><em>For Default Profile settings</em></li></ul><pre>istioctl profile dump defautl</pre><p>Here is the comparison of above two outputs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*arclqMB4M-YSGl1d3COVCg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NRXs6gMlk2ZF7KGNDx6dBg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9D2oA8F16oIruStEOkdwrg.jpeg" /></figure><h4>Example Scenario ( Demo Profile vs Default Profile )</h4><ul><li>According to the <strong>Demo Profile</strong> settings <strong>Istiod</strong> which is a control plane component of Istio service mesh requests <strong><em>100Mi of Memory</em></strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y2DZEMdGAl19wVbf_kUAPA.png" /><figcaption>Istiod in Demo Profile</figcaption></figure><ul><li>According to the <strong>Default Profile</strong> settings <strong>Istiod</strong> which is a control plane component of Istio service mesh requests <strong><em>2Gi of Memory.</em></strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*omEAZNA9_cb4T3Iw9cKWeA.png" /><figcaption>Istiod in Default Profile</figcaption></figure><blockquote>When we are testing our applications locally ( Like in Minikube ), we have limited resources.</blockquote><blockquote>Because of that, if we try to test locally with Istio Default profile, it will cause issues, due to lack of resources like memory.</blockquote><blockquote>For an example,</blockquote><blockquote>Some of the pods will not be scheduled and they will be in the PENDING STATE indefinitely.</blockquote><p>Following are the <strong>Minikube node status</strong> when my application is deployed with Demo and Default profiles of Istio. <strong><em>(Observe the percentage of request memory)</em></strong></p><ul><li><strong><em>Request memory percentage is 37%, when Demo Profile is used.</em></strong> <br><em>All my pods are up and running.</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*dUWyrzLXtW25X8wWPkPJuQ.png" /><figcaption>Demo Profile</figcaption></figure><ul><li><strong><em>Request memory percentage is 98%, when Default Profile is used.</em></strong><br><em>Two of my pods are in pending state as they are failed to schedule due to insufficient memory.</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*NbNMxVHGoDJOBr-Vpks8OA.png" /><figcaption>Default Profile</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*LMHp08B75umO5ODpo9mHPA.png" /><figcaption>Two pods are in PENDING STATE</figcaption></figure><p><strong><em>But if we still need to use default settings with some changes which we need, We can use it by Customizing the settings.</em></strong></p><h3>Customizing the Profile Configuration</h3><h4><strong>Using istioctl</strong></h4><p><strong><em>istioctl install</em></strong> provides a complete API for customizing the configuration.</p><ul><li><a href="https://istio.io/latest/docs/reference/config/istio.operator.v1alpha1/">The IstioOperator API</a></li></ul><p>The configuration parameters in this API can be set individually using --set options on the command line.</p><p><strong><em>According to the above Scenario, if we need to reduce the amount of memory to 150Mi which requests by the istiod component, we can configure it as follows:</em></strong></p><pre>istioctl install --set values.pilot.resources.requests.memory=150Mi</pre><p><strong><em>Alternatively, the IstioOperator configuration can be specified in a YAML file and passed to istioctl using the -f option:</em></strong></p><pre>istioctl install -f samples/operator/pilot-k8s.yaml</pre><h4>Using HELM</h4><p><a href="https://artifacthub.io/packages/helm/istio-official/istiod?modal=values">Click here to view HELM default values.</a></p><p><strong><em>As above let’s reduce the amount of memory to 150Mi which requests by the istiod component.</em></strong></p><pre>helm install istiod istio/istiod --set pilot.resources.requests.memory=150Mi -n istio-system --wait</pre><p>As above we can customize the configurations of the profile.</p><h3>Conclusion</h3><p>Thorough out this blog we have discussed about,</p><ul><li>The built-in profiles of Istioh and how they differ each other</li><li>How those profile configurations effect our application</li><li>How to customize configurations according to our need.</li></ul><p><strong><em>To optimize our application and to utilize the resources that we have, we need to select the correct profile or we need to customize the profile configuration as we need.</em></strong></p><blockquote>So make sure to get the correct decision in order to optimize your application and to utilize the resources that you have.</blockquote><p>Thank you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff49d0afa825" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Istio Service Mesh — Security (Part 3)]]></title>
            <link>https://medium.com/@gimhanranasinghe/the-istio-service-mesh-security-part-3-1d3d518e3997?source=rss-34fdd42c10ed------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d3d518e3997</guid>
            <dc:creator><![CDATA[Gimhan Ranasinghe]]></dc:creator>
            <pubDate>Thu, 30 Mar 2023 10:57:42 GMT</pubDate>
            <atom:updated>2023-03-30T10:57:42.898Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Istio Service Mesh — Security (Part 3)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fu9cpjnCCyRvKB2JAkTGkQ.jpeg" /></figure><h3>Introduction</h3><p>Welcome to the Part 3 of Istio Service mesh blog series where I will discuss security aspects of Istio. Here we will first get a brief introduction on security in Istio followed by the Istio security architecture, Authentication, Authorization, Mutual TLS and certificate management. Demonstrations are done with BookInfo application which we used in previous blogs.</p><p>Please find Part 1 :<br><a href="https://medium.com/@gimhanranasinghe/the-istio-service-mesh-building-service-mesh-on-istio-part-1-8ca060bffc27">The Istio Service Mesh — Building Service Mesh on Istio (Part 1)</a></p><p>Please find Part 2:<br><a href="https://medium.com/@gimhanranasinghe/the-istio-service-mesh-traffic-management-part-2-7da6a164b79c">The Istio Service Mesh — Traffic Management (Part 2)</a></p><h3>Security in Istio</h3><p>Micro-services have certain security requirements. When a service is communicating with another service, it is possible for an attacker to interrupt the request and modify it before it reaches its destination. This is called <strong>man in the middle attack</strong>. To prevent this, traffic between services need to be <strong>encrypted</strong>.</p><p>Not only that, but also certain services may need to implement <strong>access controller restrictions</strong>.</p><blockquote><strong>For an example from our BookInfo Application,<br>Only Product page service is allowed to access the review service. Other services should not be able to access review service.</strong></blockquote><p>To achieve this, we need access control. Istio allows this using <strong>Mutual TLS and fined grained access policies</strong>.</p><p>Another feature is<strong> Audit logs</strong> which provides information about who did what and at what time.</p><h3>Istio Security Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lzSgIr4uUbkwzOFPO-Icow.png" /></figure><p>In Istio there is a <strong>certification authority</strong> that manages keys and certificates. This is where the certificates are validated and certificate signing requests are approved. Every time a workload is started, the envoy Proxies requests the certificate and key from the istio agent and that that helps secure communication between services.</p><p>The <strong>configuration API server </strong>component distributes all the authentication authorization and secure naming policies to the Proxies. Sidecars and ingress egress proxies work as policy enforcement points. The certification keys, authentication authorization and secure naming policies are sent to these Proxies at all times. Therefore this means every point has security checks,not just the entry points to the network.</p><h3>Authentication</h3><blockquote><strong>When a service tries to communicate with another service, there should be a way to confirm they are really who they say they are. In order to ensure this, we need to make sure that communication between two services are authenticated.</strong></blockquote><p><strong>Mainly there are two parts of Authentication :</strong></p><blockquote>1. Peer Authentication</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bvzOCdpnGgNW5EvK5A5kVg.png" /></figure><p>Peer authentication in Istio is accomplished using mutual TLS authentication. This means that both the client and server present their certificates to each other to establish a secure, authenticated connection. Istio uses a sidecar proxy called Envoy to handle the mutual TLS authentication between services.</p><blockquote>For example,</blockquote><blockquote>When the product service tries to reach the review service, the review service needs to know that the request is actually coming from the product service and not from an external source who pretends to be the product service.</blockquote><p><strong>Authentication policies can be categorized based on what it targets :</strong></p><ol><li><strong>Workload-specific Policy</strong><br><em>Enabled authentication for workload.<br>Can achieve by using selectors</em></li><li><strong>Namespace-wide Policy<br></strong><em>Policy would be enabled for the entire namespace. Then the policy will be applied to all workloads within the namespace.<br>Can achieve by neglecting selectors</em></li><li><strong>Mesh-wide Policy<br></strong><em>Mesh wide policy that is applicable to the entire mesh.<br>Can achieve by setting the namespace to the root namespace</em></li></ol><blockquote>2. Request Authentication</blockquote><p>This means authenticating the end users access to services. Istio supports request authentication using Json webToken validation or open ID connect providers, some of them are Ori Hydra Keycloak, Firebase or Google.</p><p><strong>Let’s demonstrate now</strong></p><p>First let’s clear the default namespace and re-deploy the application. Use following commands. (Navigate to the Istio package directory)</p><pre>./samples/bookinfo/platform/kube/cleanup.sh</pre><p>Press enter again to verify the namespace as default.</p><pre>kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml</pre><p>For this example lets create a new namespace named “bar”.</p><pre>kubectl create ns bar</pre><p>Let’s create a sample application called “httpbin”. This will helps us to curl other services.</p><pre>kubectl apply -f &lt;(istioctl kube-inject -f samples/httpbin/httpbin.yaml) -n bar</pre><p>Check whether all the pods are up and running in both default and bar namespaces.</p><pre>kubectl get pods<br>kubectl get pods -n bar</pre><p><strong>Let’s curl from “httpbin” to product page.</strong></p><pre>kubectl exec -it &quot;$(kubectl get pod -l app=httpbin -n bar -o jsonpath={.items..metadata.name})&quot; -c istio-proxy -n bar -- curl &quot;http://productpage.default:9080&quot; -s -o /dev/null -w &quot;%{http_code}\n&quot;</pre><p>This command will output the status of our curl request. Output will be as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*Eswr6xudGV-a-d1RrNV2NQ.png" /><figcaption>Output : 200 status code</figcaption></figure><p>Here is http success 200 as output. This means we can curl from bar namespace to product page which is in default namespace.</p><p><strong>Let’s configure a peer authentication policy for default namespace.</strong></p><p><strong>Create auth-default.yaml</strong></p><pre>apiVersion: security.istio.io/v1beta1<br>kind: PeerAuthentication<br>metadata:<br>  name: &quot;default&quot;<br>spec:<br>  mtls:<br>    mode: STRICT</pre><p>This will enable mutual TLS for default namespace.</p><p><strong>Apply above configurations,</strong></p><pre>kubectl apply -f auth-default.yaml</pre><p><strong>Now let’s curl again, as above.</strong></p><p>Now it should be failed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*lSuMpmlvZhYDpa8dU8l63w.png" /><figcaption>Output : Failed</figcaption></figure><p><strong>As the result, we can see that request which is coming from non mutual TLS namespace is denied.</strong></p><h3>Authorization</h3><blockquote><strong>Access control for inbound traffic.</strong></blockquote><p>We can control which service can reach which service. For that we can use authentication policies.</p><blockquote>What about access control?</blockquote><p>For example, assume we would like to have following features in our application,</p><ul><li>Only allow the Product page service to access the review service and not the details or any other services.</li><li>The Product Page service is only supposed to run get calls to the review service and not post or update calls.</li><li>We do not want anyone gaining access to the productPage service to make post calls to the review service in an attempt to update or change reviews.</li></ul><p>For these purposes, Istio provides authorization mechanisms that allow us to define policies to allow or deny requests based on certain criteria.As discussed before, the services don’t require any changes to implement Authorization. This is implemented by envoy proxy’s Authorization engine in Runtime. When a request comes through the proxy,the Authorization engine evaluates the request context against the current Authorization policies and returns the Authorization result either allow or deny.</p><p><strong>There are three actions that Authorization policies support:</strong></p><ol><li><strong>Allow<br></strong><em>Allows a request to go through</em></li><li><strong>Deny</strong><br><em>Denies a request from going through</em></li><li><strong>Custom</strong><br><em>Allows an extension to handle the request</em></li></ol><p>Authorization policies can also be configured to audit requests. With this option, when a request hits the matching rule, it gets audited.</p><p>Here is an example,</p><pre>apiVersion: security.istio.io/v1beta1<br>kind: AuthorizationPolicy<br>metadata:<br>  name: authdenypolicy<br>  namespace: bookinfo<br>spec:<br>  action: DENY<br>  rules:<br>  - from:<br>    - source:<br>        namespaces: [&quot;bar&quot;]<br>    to:<br>    - operation: <br>        methods: [&quot;POST&quot;]</pre><p>Here the kind is set to Authorization policy. This policy sets the action to deny. This policy denies all post requests from the bar namespace to the book info namespace.</p><blockquote><strong>You may have to re-create bookinfo-gateway and virtual service for bookinfo as we have deleted it earlier. To create is use following command,</strong></blockquote><pre>kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml</pre><p>Check whether your application is accessible via browser. ( We have discussed how to access the application via browser in <a href="https://medium.com/@gimhanranasinghe/the-istio-service-mesh-building-service-mesh-on-istio-part-1-8ca060bffc27">The Istio Service Mesh — Building Service Mesh on Istio (Part 1) )</a></p><blockquote>Deny all workloads in the default namespace</blockquote><p><strong>Create allow-nothing.yaml</strong></p><pre>apiVersion: security.istio.io/v1beta1<br>kind: AuthorizationPolicy<br>metadata:<br>  name: allow-nothing<br>  namespace: default<br>spec:<br>  {}</pre><p>As selectors are not specified here, this authorization policy will applied to the whole default namespace. <br>As “spec” section has empty value, it will not permit any traffic. Therefore all requests will be denied.</p><p><strong>Apply above configurations,</strong></p><pre>kubectl apply -f allow-nothing.yaml</pre><p><strong>Refresh the browser to see the results.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/339/1*4g75syn6yMtzhrsDvcwUng.png" /></figure><p>Istio does not allow any workload in the “default” namespace.</p><p><strong>Let’s create a traffic into the mesh,<br>Add traffic to the application using following command with your own URL</strong></p><blockquote><strong>watch -n 0.5 ‘curl http://127.0.0.1:35427/productpage’</strong></blockquote><p><strong>Now you can view the Kiali dashboard to view the mesh graph.</strong></p><p>Use following command to access Kiali dashboard.</p><pre>istioctl dashboard kiali</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tussLZbnKYUpx0AbPBXWxA.png" /></figure><p>Now we are having issues with the whole traffic coming into the mesh.</p><blockquote>Create a viewer policy for Product page</blockquote><p><strong>Create productpage-view.yaml</strong></p><pre>apiVersion: security.istio.io/v1beta1<br>kind: AuthorizationPolicy<br>metadata:<br>  name: &quot;productpage-viewer&quot;<br>  namespace: default<br>spec:<br>  selector:<br>    matchLabels:<br>      app: productpage<br>  action: ALLOW<br>  rules:<br>  - to:<br>    - operation:<br>        methods: [&quot;GET&quot;]</pre><blockquote><strong>This will only allow GET requests which are coming to the product page service.</strong></blockquote><p><strong>Apply above configurations,</strong></p><pre>kubectl apply -f productpage-view.yaml</pre><p><strong>Refresh the browser to see the results.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7q_3-nEZwoHCLI9tdFJpsQ.png" /></figure><p>Only product page, but rest of the services are not available.</p><p><strong>View in Kiali dashboard (Refresh the graph. This may take some time to view. <br>Hint : Switch between tabs in Kiali dashboard)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*tuPAywDzcKwhlYlknkUP7Q.png" /></figure><p>Now we have some traffic passing through product page.</p><blockquote>Create a viewer policy for Details</blockquote><p><strong>Create details-view.yaml</strong></p><pre>apiVersion: security.istio.io/v1beta1<br>kind: AuthorizationPolicy<br>metadata:<br>  name: &quot;details-viewer&quot;<br>  namespace: default<br>spec:<br>  selector:<br>    matchLabels:<br>      app: details<br>  action: ALLOW<br>  rules:<br>  - from:<br>    - source:<br>        principals: [&quot;cluster.local/ns/default/sa/bookinfo-productpage&quot;]<br>  - to:<br>    - operation:<br>        methods: [&quot;GET&quot;]</pre><blockquote><strong>This will only allow GET requests which are coming from service account “bookinfo-productpage” to details service.</strong></blockquote><p><strong>Apply above configurations,</strong></p><pre>kubectl apply -f details-view.yaml</pre><p><strong>Refresh the browser to see the results.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KoWOfSIwtjwQMgJ6jMTqAQ.png" /></figure><p>Only product page and details services are available.</p><p><strong>View in Kiali dashboard (Refresh the graph. This may take some time to view. <br>Hint : Switch between tabs in Kiali dashboard)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*H_gj8cWSInBMYthc3gsCXw.png" /></figure><p>Now we have some traffic passing through product page and details page.</p><blockquote>Create a viewer policy for Reviews</blockquote><p>Similar as above, we can create Authorization policy for reviews</p><p><strong>Create review-view.yaml</strong></p><pre>apiVersion: security.istio.io/v1beta1<br>kind: AuthorizationPolicy<br>metadata:<br>  name: &quot;review-viewer&quot;<br>  namespace: default<br>spec:<br>  selector:<br>    matchLabels:<br>      app: reviews<br>  action: ALLOW<br>  rules:<br>  - from:<br>    - source:<br>        principals: [&quot;cluster.local/ns/default/sa/bookinfo-productpage&quot;]<br>  - to:<br>    - operation:<br>        methods: [&quot;GET&quot;]</pre><blockquote><strong>This will only allow GET requests which are coming from service account “bookinfo-productpage” to review service.</strong></blockquote><p><strong>Apply above configurations,</strong></p><pre>kubectl apply -f review-view.yaml</pre><p><strong>Refresh the browser to see the results.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*htJ4FPyQLTXRol8IwBI9-g.png" /></figure><p>Product page, details and reviews services are available. Only rating service is not available.</p><p><strong>View in Kiali dashboard (Refresh the graph. This may take some time to view. <br>Hint : Switch between tabs in Kiali dashboard)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DjyKUhqV4xYF3IgS7REtnw.png" /></figure><p>Now we have some traffic passing through product page, details page and reviews.</p><blockquote>Create a viewer policy for Ratings</blockquote><p>Same as above we can create a viewer for ratings.</p><p><strong>Create rating-view.yaml</strong></p><pre>apiVersion: security.istio.io/v1beta1<br>kind: AuthorizationPolicy<br>metadata:<br>  name: &quot;rating-viewer&quot;<br>  namespace: default<br>spec:<br>  selector:<br>    matchLabels:<br>      app: ratings<br>  action: ALLOW<br>  rules:<br>  - from:<br>    - source:<br>        principals: [&quot;cluster.local/ns/default/sa/bookinfo-productpage&quot;]<br>  - to:<br>    - operation:<br>        methods: [&quot;GET&quot;]</pre><p><strong>Apply above configurations,</strong></p><pre>kubectl apply -f rating-view.yaml</pre><p><strong>Let’s view the outputs in both browser and Kiali dashboard.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z3ZCfTLwaNCc3Neey1LQSA.png" /><figcaption>Browser output</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vihr9drt1IQ3xjhX5qq6nQ.png" /><figcaption>Kiali dashboard output</figcaption></figure><p><strong>We can veiw our Authorization Policies either in the Kiali dashboard or using kubectl command.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XbJK__Vl4HU1rJgbZz0VYQ.png" /><figcaption>In Kiali dashboard</figcaption></figure><p>Kubectl command,</p><pre>kubectl get AuthorizationPolicy</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*ycpyc3HmWGf0G40F3l0OQA.png" /></figure><blockquote><strong>We have created 5 authorization Policies to the mesh. It means any other traffic between our services like POST requests will not be allowed.</strong></blockquote><blockquote><strong>Depending on our authorization rules, we can have very well defined and strict rules to protect our services.</strong></blockquote><h3>Conclusion</h3><p>Through out this blog, we have discussed about Security in Istio service mesh. Mainly we have discussed about Authentication and authorization in Istio. Hope now you have an clear idea on those areas.</p><p>Please find Part 1 : <br><a href="https://medium.com/@gimhanranasinghe/the-istio-service-mesh-building-service-mesh-on-istio-part-1-8ca060bffc27">The Istio Service Mesh — Building Service Mesh on Istio (Part 1)</a></p><p>Please find Part 2:<br><a href="https://medium.com/@gimhanranasinghe/the-istio-service-mesh-traffic-management-part-2-7da6a164b79c">The Istio Service Mesh — Traffic Management (Part 2)</a></p><p>Have a wonderful day!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d3d518e3997" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Istio Service Mesh — Traffic Management (Part 2)]]></title>
            <link>https://medium.com/@gimhanranasinghe/the-istio-service-mesh-traffic-management-part-2-7da6a164b79c?source=rss-34fdd42c10ed------2</link>
            <guid isPermaLink="false">https://medium.com/p/7da6a164b79c</guid>
            <dc:creator><![CDATA[Gimhan Ranasinghe]]></dc:creator>
            <pubDate>Thu, 30 Mar 2023 10:45:29 GMT</pubDate>
            <atom:updated>2023-03-30T10:45:29.698Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Istio Service Mesh — Traffic Management (Part 2)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aqlqnD5pr_qOmsslullQhg.jpeg" /></figure><h3>Introduction</h3><p>In my previous blog, I have discussed how to build a service mesh on Istio using a sample BookInfo application.</p><p>Please find Part 1 :<br><a href="https://medium.com/@gimhanranasinghe/the-istio-service-mesh-building-service-mesh-on-istio-part-1-8ca060bffc27">The Istio Service Mesh — Building Service Mesh on Istio (Part 1)</a></p><p>Here I’m trying to explain traffic management in Istio which allows us to control how traffic flows between our microservices in a Kubernetes cluster while ensuring that requests are handled reliably and efficiently.</p><p>Mainly I will be discussing on gateways, virtual services, destination rules, fault injection, timeouts, retries and circuit breaking.</p><h3>Prerequisites</h3><p>In order to tryout the features that I’m going to discuss here, you need to have built service mesh on Istio with the sample BookInfo application. You can follow my previous blog from the following link in order to build your service mesh.</p><ul><li><a href="https://medium.com/@gimhanranasinghe/the-istio-service-mesh-building-service-mesh-on-istio-part-1-8ca060bffc27">The Istio Service Mesh — Building Service Mesh on Istio (Part 1)</a></li></ul><h3>Let’s start by exploring core components</h3><p>After deploying the application and setup the service mesh, we need to make accessible this application to the outside users. According to our application Product page of the BookInfo application should be accessible.</p><blockquote>How can we make the application accessible to the outside users ?</blockquote><h3>Gateways</h3><blockquote><strong>Istio Gateways are stand alone envoy proxies which acts as load balances that sit at the edge of the mesh.</strong></blockquote><p>In Kubernetes, Ingress controls the traffic coming into the Kubernetes cluster. It is achieved by deploying a ingress controller such as Nginx controller. With that we can define set of routing rules to route traffic to specific services.</p><p>While supporting Kubernetes ingress, Istio recommends <strong>Istio gateway</strong> which is capable enough to support more features in Istio.</p><p>In the previous blog, we saw that when we deployed Istio on our cluster, <strong>Istio ingress gateway</strong> and <strong>istio egress gateway</strong> was installed which managers<strong> inbound traffic</strong> and <strong>out bound traffic</strong> respectively.</p><p>If you have follow previous blog on <a href="https://medium.com/@gimhanranasinghe/the-istio-service-mesh-building-service-mesh-on-istio-part-1-8ca060bffc27">building service mesh on Istio</a> we have deployed a gateway object called <strong>bookinfo-gateway</strong> which uses to receive all traffic coming from Istio-ingress controller.</p><p><strong>List created gateways,</strong></p><pre>kubectl get gateway</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*tN4sNb46NEVq4NG46Z1gxw.png" /></figure><blockquote>Now we have gateway to capture traffic which is coming through istio-ingress gateway, but to where does it route to ?</blockquote><h3>Virtual Services</h3><blockquote><strong>Virtual service defines a set of routing rules for traffic coming from the ingress gateway into the service mesh.</strong></blockquote><p>A virtual service is a Kubernetes custom resource that defines how traffic should be routed to a set of services based on the request’s destination host or URI path. It provides a layer of abstraction between the service consumers and the underlying services, allowing for more flexible and dynamic traffic management. <strong>When a virtual service is created Istio control plane applies the new configuration to all the envoy sidecar proxies.</strong></p><p>If you have followed the previous blog, now you already created a virtual service for product page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XhdlXgtRnIZLDrhBCVr79g.png" /></figure><p><strong>You can view those configurations by using following command.</strong></p><pre>cat samples/bookinfo/networking/bookinfo-gateway.yaml</pre><pre>http:<br>  - match:<br>    - uri:<br>        exact: /productpage<br>    - uri:<br>        prefix: /static<br>    - uri:<br>        exact: /login<br>    - uri:<br>        exact: /logout<br>    - uri:<br>        prefix: /api/v1/products<br>    route:<br>    - destination:<br>        host: productpage<br>        port:<br>          number: 9080</pre><p>In <strong>uri section</strong>,</p><ul><li><strong>“exact”</strong> means the path should be exactly as provided</li><li><strong>“prefix”</strong> means all paths which begins with mentioned uri.</li></ul><p>All traffic which matches with above mentioned uri patterns are then routed to the destinations which are specified in the route section.</p><blockquote>How can we redirect perform canary deployments or blue-green deployments. ?</blockquote><p><strong>In our application review service has three versions.</strong></p><ul><li><strong>Version 1 — Without stars</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/198/1*1yWQL_OYVBT_7njRiA_pXQ.png" /></figure><ul><li><strong>Version 2 — With black stars</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/198/1*IatrA4uYibKSCm-JJT9WRQ.png" /></figure><ul><li><strong>Version 3 — With red stars</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/198/1*jz66gCOhVFOeyAoK6cxwhA.png" /></figure><p>In situations like this, we may need to route different portion of traffic into each versions. This may be because of developers need to try out new version with small portion of traffic without expose it to the whole traffic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*S2PWzITB7GwhTaXI6pl5vA.png" /></figure><p>To be successful in above mentioned scenario we need subsets as above. After that we can distribute traffic among those subsets through virtual service.</p><blockquote>How can we form subsets ?</blockquote><h3>Destination Rules</h3><blockquote><strong>The destination rule applies router policies after the traffic is routed to a specific service.</strong></blockquote><p>Destination Rule is a Kubernetes custom resource that defines policies for routing traffic to services based on the service’s version, subsets, and ports. Destination Rules are used in conjunction with Virtual Services to provide more advanced routing capabilities and service discovery in a micro-services architecture.</p><h4>Let’s create a destination rule for reviews.</h4><p><strong>Create dest-rule-reviews.yaml</strong></p><pre>apiVersion: networking.istio.io/v1alpha3<br>kind: DestinationRule<br>metadata:<br>  name: reviews<br>spec:<br>  host: reviews<br>  subsets:<br>  - name: v1<br>    labels:<br>      version: v1<br>  - name: v2<br>    labels:<br>      version: v2<br>  - name: v3<br>    labels:<br>      version: v3</pre><p>Pods are assigned to these subsets based on the labels provided in the pod.</p><blockquote><strong>For example:</strong></blockquote><blockquote>Pods which have label “version : v1” belongs to the subset named “v1”</blockquote><p><strong>To apply the destination rule, use</strong></p><pre>kubectl apply -f dest-rule-reviews.yaml</pre><p><strong>Now you can view created destination rule by either using following command</strong></p><pre>kubectl get destinationrule</pre><p><strong>or via Kiali dashboard.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0PFXDAoxvP7qre1FttpxOg.png" /></figure><h4>Now we can create a virtual service for reviews.</h4><p><strong>Create vs-reviews.yaml</strong></p><pre>apiVersion: networking.istio.io/v1alpha3<br>kind: VirtualService<br>metadata:<br>  name: reviews<br>spec:<br>  hosts:<br>    - reviews<br>  http:<br>    - route:<br>      - destination:<br>         host: reviews<br>         subset: v1<br>        weight: 70<br>      - destination:<br>         host: reviews<br>         subset: v2<br>        weight: 25<br>      - destination:<br>         host: reviews<br>         subset: v3<br>        weight: 5</pre><p>Here we are using subsets and weights to route portions of traffic to services.</p><blockquote><strong>For example,</strong></blockquote><blockquote><strong>70% of the traffic is routed to subset v1.</strong></blockquote><blockquote><strong>25% of the traffic is routed to subset v2.</strong></blockquote><blockquote><strong>5% of the traffic is routed to subset v3.</strong></blockquote><p><strong>To apply this, use</strong></p><pre>kubectl apply -f vs-reviews.yaml</pre><p><strong>Now you can check this out, in various ways</strong></p><ol><li>By refreshing the application browser.<br>- You will see version 1 most of the time and version 3 rarely.</li><li>Through via Kiali dashboard<br>- Add traffic to the application using following command with your own URL</li></ol><blockquote><strong>watch -n 0.5 ‘curl http://127.0.0.1:34887/productpage’</strong></blockquote><p>In the Graph tab of KIali dashboard, there is a dropdown named <strong>“display”</strong>. There you can enable <strong>traffic rate</strong> to see the distribution of traffic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/1*bmRVnQWq_i2QnEaStU4-1w.png" /></figure><p>Here you can see, for v1 traffic rate is very high compared to other two and for v3 traffic rate is very low. <br><strong><em>If you enable Traffic Animation from the drop down as we did earlier, you can see how traffic is distributed among three version clearly.(If you increase the requests per second, you can visualize it more clearly.)</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EHvoI9LhVveJq7bjQg6XKA.png" /><figcaption>Traffic animation when -n 0.2, in the command</figcaption></figure><blockquote>How to set up load balancing algorithms ?</blockquote><p>This can be done using destination rules. By default envoy load balances use <strong>ROUND_ROBIN</strong> algorithm but this can be customized through destination rules by specifying a traffic Policy of loadBalancer. Other simple algorithms are <strong>PASSTHROUGH, LEAST_CONN, and RANDOM.</strong></p><p>We can specify traffic policy either for all the subset or only for specify subsets. This can be specified under the <strong>spec</strong> section of the destination rule.</p><pre>apiVersion: networking.istio.io/v1alpha3<br>kind: DestinationRule<br>metadata:<br>  name: reviews<br>spec:<br>  host: reviews<br>  trafficPolicy:<br>    loadBalancer:<br>      simple: PASSTHROUGH<br>  subsets:<br>  - name: v1<br>    labels:<br>      version: v1<br>  - name: v2<br>    labels:<br>      version: v2<br>  - name: v3<br>    labels:<br>      version: v3<br>    trafficPolicy:<br>      loadBalancer:<br>        simple: RANDOM</pre><p>This destination rule sets <strong>PASSTHROUGH</strong> load balancing policy for all the sub sets, but in subset version 3, it overrides to <strong>RANDOM. </strong>According to above we can set load balancing policies through destination rules.</p><blockquote>How can we direct specific uses to specific version of our application ?</blockquote><p>In certain applications <strong>we need to show some specific features only to set of peoples</strong>. It may be based on location, age, gender or any other criteria. For achieving this, we can use virtual services.</p><p>To demonstrate this, let’s assume only <strong>“super”</strong> users can see <strong>red colored stars (version 3) </strong>in review section and <strong>all others</strong> should see <strong>black star version (version 2)</strong>. To configure this, we can use the same virtual service which we configured earlier for reviews.</p><p><strong>Edit previous vs-reviews.yaml</strong></p><pre>apiVersion: networking.istio.io/v1alpha3<br>kind: VirtualService<br>metadata:<br>  name: reviews<br>spec:<br>  hosts:<br>    - reviews<br>  http:<br>    - match:<br>        - headers:<br>            end-user:<br>              exact: super<br>      route:<br>        - destination:<br>           host: reviews<br>           subset: v3<br>    - route:<br>      - destination:<br>         host: reviews<br>         subset: v2</pre><p>According to the above file, if a super user signs in, application shows the version 2 of reviews. It is done by checking the value of “end-user” attribute. If it is super, traffic is directed to version 2 of reviews.</p><p>You can test this out by sign in to the application via browser. BookInfo application is built in a way that, when user signs in, user name is set to the “end-user” attribute which is in the header.</p><p><strong>Use “super” as the user name and enter any password.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/1*64AjgX46V4XDbXxP0JllBA.png" /><figcaption>Signs in as super</figcaption></figure><p><strong>Use any other value to username to see black stars (version 2). For the example I used username as “jimmy”.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/1*WYCHgFPZaUUZaBLEEqFJTA.png" /><figcaption>Signs in as jimmy</figcaption></figure><p><strong>This is what we have done so far.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lo4JV99ibE-AjLKT8JwFgg.png" /></figure><blockquote><em>How can we check error-handling mechanisms?</em></blockquote><h3>Fault Injection</h3><blockquote><strong>Fault injection is a technique used to intentionally inject failures into a system to test its resilience and identify potential points of failure.</strong></blockquote><p>In the context of Istio, a popular service mesh for managing and securing microservices-based applications, fault injection can be performed to test the resilience of the application and identify any weaknesses or vulnerabilities.</p><p>Fault injection can be done via virtual service.</p><p><strong>Manly there are two types of errors which can be injected,</strong></p><p><strong>1. Delay — Timing failures</strong></p><pre>- fault:<br>    delay:<br>      percentage:<br>        value: 10<br>      fixedDelay: 5s</pre><p>This will add 5 seconds delay for 10% of the requests.</p><p><strong>2. Abort- Crash failures</strong></p><pre>- fault:<br>    abort:<br>      percentage:<br>        value: 50<br>      httpStatus: 400</pre><p>This will abort 50% of the requests while returning status code of 400.</p><h4>Let’s introduce a delay to our details service.</h4><p>Before creating the fault injection rule, we need to create a destination rule, so that we can have a subset for this rule to work.</p><p><strong>Create dest-rule-details.yaml</strong></p><pre>apiVersion: networking.istio.io/v1alpha3<br>kind: DestinationRule<br>metadata:<br>  name: details<br>spec:<br>  host: details<br>  subsets:<br>  - name: v1<br>    labels:<br>      version: v1<br>  - name: v2<br>    labels:<br>      version: v2</pre><p><strong>Apply using following command,</strong></p><pre>kubectl apply -f dest-rule-details.yaml </pre><p>Then we can introduce delay for the subset v1 through Vertual service.</p><p><strong>Create vs-details.yaml</strong></p><pre>apiVersion: networking.istio.io/v1alpha3<br>kind: VirtualService<br>metadata:<br>  name: details<br>spec:<br>  hosts:<br>  - details<br>  http:<br>  - fault:<br>      delay:<br>        percentage:<br>          value: 70.0<br>        fixedDelay: 7s<br>    route:<br>    - destination:<br>        host: details<br>        subset: v1</pre><p><strong>Apply using following command,</strong></p><pre>kubectl apply -f vs-details.yaml</pre><p>According to above configuration 70% of traffic will be delayed extra 7 seconds.</p><p><strong>Navigate to Kiali dashboard after applying continuous traffic to the application as previous.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3qr5VnWfExAs6_-8kh1Pxw.png" /><figcaption>Delay Fault Injection</figcaption></figure><p>Now you can see details service is having an issue which is indicated by the red arrow. At the same time, there is a green arrow to the details service which indicates that there are some requests which are getting the correct response. This is because we delayed only 70% of the traffic, 30% of the traffic is still working fine.</p><p><strong>If you navigate to the BookInfo application on browser, you may see an error message in the details section as follows.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/903/1*zr0_Y71d0AJggBWX6Hqrcw.png" /></figure><p>But if you refresh the browser multiple time, you may see details without errors. It is because only 70% traffic is delayed.</p><blockquote>How can we stop queuing up requests under one service, due to the slowness of another service?</blockquote><h3>Timeouts</h3><blockquote>Timeouts can be used to limit the amount of time a service waits for a response from another service.</blockquote><p>This can be useful in scenarios where a service is waiting for a response from another service that may be unavailable or slow, to prevent the request from hanging indefinitely and causing a cascading failure.</p><p>The <strong>default timeout value in Istio is 15 seconds</strong>, but you can configure it to any value that suits your application’s requirements.<br>For this demonstration, let’s add a timeout for product page with which it can reject when any service takes more time to response.</p><p><strong>Add timeout as follows, for bookinfo virtual service which is already created.</strong></p><pre>apiVersion: networking.istio.io/v1alpha3<br>kind: VirtualService<br>metadata:<br>  name: bookinfo<br>spec:<br>  hosts:<br>  - &quot;*&quot;<br>  gateways:<br>  - bookinfo-gateway<br>  http:<br>  - match:<br>    - uri:<br>        exact: /productpage<br>    - uri:<br>        prefix: /static<br>    - uri:<br>        exact: /login<br>    - uri:<br>        exact: /logout<br>    - uri:<br>        prefix: /api/v1/products<br>    route:<br>    - destination:<br>        host: productpage<br>        port:<br>          number: 9080<br>    timeout: 3s</pre><blockquote>You can either edit those files via Kiali dashboard or apply edited files using kubectl as earlier.</blockquote><p>Generally, theses requests won’t take 3 seconds to response. In order to test this out we need to slow down some of our services. We can do it by using delays which we discussed earlier.</p><p><strong>Let’s add a delay for details service.</strong></p><pre>apiVersion: networking.istio.io/v1alpha3<br>kind: VirtualService<br>metadata:<br>  name: details<br>spec:<br>  hosts:<br>  - details<br>  http:<br>  - fault:<br>      delay:<br>        percentage:<br>          value: 100<br>        fixedDelay: 5s<br>    route:<br>    - destination:<br>        host: details<br>        subset: v1</pre><p>After applying the changes, navigate to the product page in the browser where you can see, that the configured timeout has occurred.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/376/1*u5FuN0Rj3a6XQOG_WR-lGQ.png" /><figcaption>Timeout has occurred</figcaption></figure><h3>Retries</h3><p>Retries can be used to automatically retry failed requests to a service, helping to improve the resiliency of your application. By default, Istio allows up to 2 retries for failed requests with 25ms interval.</p><p>Retries are specified in virtual service level.</p><pre>retries:<br>  attempts: 3<br>  perTryTimeout: 5s</pre><p>Above configuration is used to specify how many times a request will be retried if it fails, and how long to wait for each retry attempt. In this case, if a request fails, it will be retried up to 3 times, with each retry attempt waiting for up to 5 seconds.</p><h3>Circuit Breaking</h3><p>The basic idea behind circuit breaking is to proactively monitor the health of a service, and if the service becomes unavailable or unresponsive, to prevent further requests from being sent to the service until it recovers. The circuit breaking mechanism works by monitoring the success and failure rates of requests to a service over a period of time. If the failure rate exceeds a certain threshold, the circuit is “tripped”, preventing additional requests from being sent to the service for a specified period of time.</p><blockquote>Circuit breaking can help to prevent cascading failures in a distributed system, where a failure in one service can cause additional failures in other services that depend on it.</blockquote><p><strong>Create dest-rule-product-page.yaml</strong></p><pre>apiVersion: networking.istio.io/v1alpha3<br>kind: DestinationRule<br>metadata:<br>  name: productpage<br>spec:<br>  host: productpage<br>  trafficPolicy:<br>    connectionPool:<br>      tcp:<br>        maxConnections: 1<br>      http:<br>        maxRequestsPerConnection: 1<br>        http1MaxPendingRequests: 1</pre><ul><li><strong>maxConnections</strong> - <br>Only one TCP connection will be allowed to be established to the “productpage” service at any given time.</li><li><strong>http1MaxPendingRequests - <br></strong>Only one HTTP request will be allowed to be pending at any given time before additional requests are blocked.</li><li><strong>maxRequestsPerConnection</strong> - <br>Each TCP connection to the productPage service will only be able to make one HTTP request before the connection is closed.</li></ul><p><strong>Let’s tryout this by creating concurrent calls,</strong></p><p>Remove timeouts and delays which we configured earlier, by applying configurations , after deleting those relevant code blocks which we added earlier to virtual service files.</p><pre>h2load -n1000 -c1 &#39;http://127.0.0.1:46565/productpage&#39;</pre><p>n — Number of requests<br>c — Number of concurrent clients</p><blockquote><strong>1 concurrent client</strong></blockquote><pre>h2load -n1000 -c1 &#39;http://127.0.0.1:46565/productpage&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*7u_gLUxXRw2Pa34Sz2xMYA.png" /><figcaption>1 concurrent client</figcaption></figure><blockquote><strong>2 concurrent clients</strong></blockquote><pre>h2load -n1000 -c2 &#39;http://127.0.0.1:46565/productpage&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*zQTAQpxUSnCotfQGy3v9UA.png" /><figcaption>2 concurrent clients</figcaption></figure><blockquote><strong>4 concurrent clients</strong></blockquote><pre>h2load -n1000 -c4 &#39;http://127.0.0.1:46565/productpage&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*pNYrIszjKx1fJM5LbZRalg.png" /><figcaption>4 concurrent clients</figcaption></figure><p>Let’s examine the summary of above tests,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/328/1*K_DS5_52fq6Vvy3-jiDYGQ.png" /><figcaption>Summary of tests</figcaption></figure><p>According to above summary, we can see that <strong>when concurrent clients are increasing, more of our requests are denied </strong>as it can handle only one pending request. Other requests are denied.</p><p><strong>At the same time we can see our product page is having some issue though kiali dashboard. This is due to our very strict circuit breaker.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*da3ag4i_rTtcH-JXECZ09Q.png" /><figcaption>Product page is failing due to very strict circuit breaker</figcaption></figure><h3>Conclusion</h3><p>Through out this blog, we have discussed about traffic management in Istio service mesh. We were able to cover gateways, virtual services, destination rules, fault injection, timeouts, retries and circuit breaking with demonstrations. Hope now you are clear on those areas.</p><p>I will be discussing Security, and Observability in my upcoming blogs.</p><p>Please find Part 1 : <br><a href="https://medium.com/@gimhanranasinghe/the-istio-service-mesh-building-service-mesh-on-istio-part-1-8ca060bffc27">The Istio Service Mesh — Building Service Mesh on Istio (Part 1)</a></p><p>Have a wonderful day!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7da6a164b79c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Istio Service Mesh — Building Service Mesh on Istio (Part 1)]]></title>
            <link>https://medium.com/@gimhanranasinghe/the-istio-service-mesh-building-service-mesh-on-istio-part-1-8ca060bffc27?source=rss-34fdd42c10ed------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ca060bffc27</guid>
            <dc:creator><![CDATA[Gimhan Ranasinghe]]></dc:creator>
            <pubDate>Thu, 30 Mar 2023 10:37:08 GMT</pubDate>
            <atom:updated>2023-03-30T10:37:08.370Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Istio Service Mesh — Building Service Mesh on Istio (Part 1)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9d7eFGhSh7DnXBorK0SuAg.jpeg" /></figure><h3>Introduction</h3><p>This is a series of blogs which explains about building a service mesh on istio, Traffic Management, Security, and Observability. In this blog I’m trying to explain about service meshes and I will lead you on how to build a service mesh on Istio using a sample BookInfo application.</p><h4>Why we need Service Mesh?</h4><p>In the past developers developed their software as Monolithic applications where all the application components, such as the user interface, business logic, and data access layer, are tightly coupled and run within a single process or container. This means that any changes or updates to the application require the entire application to be redeployed. When the applications are getting more complex and larger, this can be time-consuming, may require significant downtime and become difficult to maintain, scale, and update. To solve this issue Micro-services architecture was introduced where the monolithic applications are broken into smaller, more manageable services which allows us to update and scale each service independently, leading to increased agility and reduced downtime.</p><p>However, Micro-service architecture is also having its disadvantages. We need to define authentication, authorization, networking, logging, monitoring and tracing for each micro-service separately and if there is an update in any of these sections we need to update it in every micro-service.This opens the path to have a Service Meshes.</p><h4>What is a Service Mesh?</h4><p>A service mesh is a dedicated infrastructure layer for managing service-to-service communication within a distributed system. For micro-services based applications, it provides a way of managing service discovery, load balancing, security, observability, and other communication-related issues.</p><p>The data plane that intercepts and routes traffic between the services is often formed by a group of network proxies that are deployed alongside the application containers as the service mesh. A centralized control plane, which controls the configuration and mesh policies, is in communication with these proxies.</p><p>Features including traffic routing, service discovery, load balancing, circuit breaker, fault tolerance, tracing, and security are frequently offered by service mesh solutions. Service meshes allow developers to concentrate on creating business logic while offering a consistent set of network policies and observability across the whole application stack by abstracting these communication concerns away from the application code.</p><h4>What is Istio?</h4><p>Istio is an open source service mesh that layers transparently onto existing distributed applications. Istio’s powerful features provide a uniform and more efficient way to secure, connect, and monitor services.</p><p>Two main components of Istio are,</p><ul><li>Data plane</li><li>Control plane</li></ul><p>The data plane is the communication between services. Service mesh employs a proxy to intercept all your network traffic, offering a comprehensive set of application-aware functionality dependent on configuration we provide. An Envoy proxy is deployed along with each service that we start in your cluster</p><p>The control plane programs the proxy servers dynamically, updating them as the rules or the environment change, using our chosen configuration and its perspective of the services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*BZFuYZzV0e8GgQ3GZuCJHA.png" /></figure><h3>Prerequisites</h3><ul><li><a href="https://www.docker.com/">Docker</a></li><li><a href="https://minikube.sigs.k8s.io/docs/start/">Minikub</a>e</li><li><a href="https://kubernetes.io/docs/tasks/tools/">Kubectl</a></li></ul><p>Start minikube using following command</p><pre>minikube start --driver=docker</pre><p>To enable ingress add on use following command.</p><pre>minikube addons enable ingress</pre><h3>Installing Istio</h3><p>There are three ways of installing istio.</p><ul><li>Install with Istioctl</li><li>Install with Helm</li><li>Istio Operator Install</li></ul><p>Here we are using the method of “Install with Istioctl”</p><h4><strong>Install istioctl</strong></h4><p><strong>From the following command you can download and extract the latest release from the Istio release page.</strong></p><pre>curl -L https://istio.io/downloadIstio | sh -</pre><p>Navigate to the Istio package directory. (Directory name may vary depending on your downloaded version)</p><p>As my package is istio 1.17.0</p><pre>cd istio-1.17.0</pre><p>Let’s add the istioctl client to your path.</p><pre>export PATH=$PWD/bin:$PATH</pre><p>The directory named “samples” contains sample application which we are going to use.</p><h4>Install Istio</h4><p>For this installation, we will use a demo configuration profile. There are different profiles for production and performance testing.</p><pre>istioctl install --set profile=demo -y</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*IYsnXMjOHcLqN0tMwpMJ9g.png" /></figure><p>After executing above command Istio is deployed in your cluster in a form of a deployment name “istiod” in a new name-space called “istio-system”.</p><p>Istiod contains following components:</p><ul><li>Pilot — for service discovery</li><li>Galley — for validating configuration files</li><li>Citadel — for managed certificate generation</li></ul><p>Along with istiod it deployed two other services istio-ingressgateway and istio-egressgateway.</p><p>You can check the newly created pods in istio-system namespace as follows.</p><pre>kubectl get pods -n istio-system</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*U5fX0piR7m05RhnNsmZvNg.png" /></figure><p>You can verify the installation using following command</p><pre>istioctl verify-install</pre><p>If your installation is successful following line will show up at the end.</p><pre>✔ Istio is installed and verified successfully</pre><h3>Let’s deploy our “Book Info” application</h3><p>As we are going to deploy our application into default namespace we need to enable Istio injection for the namespace. Then only new pods get side cars automatically.</p><p>To enable Istio injection for the default namespace use following command.</p><pre>kubectl label namespace default istio-injection=enabled</pre><p>In the sample directory you can find the Book Info application.</p><p>To deploy the application use following command. (Now you are in the Istio package directory. In my case I’m in the directory called “istio-1.17.0”)</p><pre>kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml</pre><p>You can check created pods using following command.</p><pre>kubectl get pods</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*OBVvJ7ze6QwNnaU2STjwKQ.png" /></figure><p>We can find out we have pods for product page, details, ratings, and three versions of review micro-services and envoy sidecar proxies for each and every pod. That is why it shows for every pod has two containers (2/2). One of them is envoy sidecar proxy.</p><h3>Now we need to open the application to outside traffic</h3><p>Although we have deployed the BookInfo application, it is not accessible from the outside. For that we need to implement an Istio Ingress Gateway, which maps a path to a route at the edge of your mesh.</p><h4>So what is a gateway?</h4><p>Istio Ingress Gateway is a component of the Istio service mesh that provides an entry point for external traffic to enter the service mesh. It acts as a gateway for all incoming traffic from outside of the mesh, and routes that traffic to the appropriate destination service within the mesh.</p><p>To create istio gateway for BookInfo application we can use following command,</p><pre>kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml</pre><p>To check the status of mesh you can use following command.</p><pre>istioctl analyze</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*iecbUEPZz-M8MUUeYx62nw.png" /></figure><p>To get the application URL, you can use following command.</p><pre>minikube service istio-ingressgateway -n istio-system</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*OWjAmWfk8lPBtYvK4fpZKA.png" /></figure><p>You can grab the URL which is infront of the target port http2/80 to access the application. According to above it is <strong><em>http://192.168.49.2:30748</em></strong></p><p>If your host machine is creating a tunnel to access the application as follows, you need to grab the correct URL which is mapping to the target port http2/80 in the tannel URL table. In this case it is <strong><em>http://127.0.0.1:34887</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*Imi9F88XYs56DF5hvrWYhw.png" /></figure><p>To check whether, the deployed application is working, you can use following command with your URL which you grab in the previous step. For this example I will use URL as <strong><em>http://127.0.0.1:34887</em></strong></p><pre>http://127.0.0.1:34887/productpage</pre><p>This will show you the HTML code of product page of your application as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*-agI5Jc41M4jmZk_pzIKNg.png" /></figure><p>Using above complete URL you can access the BookInfo application through the browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mlb-Fms9x_W9OwsExJTjnQ.png" /><figcaption>BookInfo Application</figcaption></figure><h3>Visualizing service Mesh with Kiali</h3><p>Kiali provides real-time visibility into the service mesh, giving users a graphical view of the components, traffic flow, and performance metrics of the Istio service mesh. It allows users to visualize the service topology, understand traffic flow, and monitor service health and performance.</p><p>Use following command to install Kiali on our cluster with other addons such as prometheus, Grafana, and Jaeger<em> </em>provided in the samples folder. Then we can check the status of kiali deployment using next command.</p><pre>kubectl apply -f samples/addons<br>kubectl rollout status deployment/kiali -n istio-system</pre><p>If Kilai successfully rolled out following line will be showed up.</p><pre>deployment &quot;kiali&quot; successfully rolled out</pre><p>Use following command to access Kiali dashboard.</p><pre>istioctl dashboard kiali</pre><p>You can use the localhost link to access kiali dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y9HN4w8mWltQhaR1g68PNg.png" /></figure><p>If you need see the graph of your service mesh, you can send a continuous traffic to user application using following command. (Use your own URL)</p><blockquote>watch -n 0.5 ‘curl http://127.0.0.1:34887/productpage’</blockquote><p>Now you can view the full graph of your application on the Graph tab of Kiali dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gxEzIUKvuBNGGD4eav2-MA.png" /></figure><h3>Conclusion</h3><p>Now you have successfully build your service mesh on Istio. I will be explaining Traffic Management, Security, and Observability in my upcoming blogs.</p><p>Have a wonderful day!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ca060bffc27" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WSO2 Identity Server deployment in Kubernetes using HELM]]></title>
            <link>https://medium.com/@gimhanranasinghe/wso2-identity-server-deployment-in-kubernetes-using-helm-7cfcc5258140?source=rss-34fdd42c10ed------2</link>
            <guid isPermaLink="false">https://medium.com/p/7cfcc5258140</guid>
            <dc:creator><![CDATA[Gimhan Ranasinghe]]></dc:creator>
            <pubDate>Tue, 07 Mar 2023 04:15:54 GMT</pubDate>
            <atom:updated>2023-03-07T04:15:54.121Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C2aCM3d5RI_2oJWO49pMVA.jpeg" /></figure><h3>Introduction</h3><h4>WSO2 Identity Server</h4><p>WSO2 Identity Server is an open-source identity and access management (IAM) product that simplifies the creation of customer identity and access management (CIAM) solutions. It provides a centralized platform for controlling and protecting access to resources, streamlines authentication, authorization, and identity management procedures and offers identity governance capabilities such as role-based access control, password policy management, and user account management.</p><h4>Kubernetes</h4><p>Kubernetes is an open-source platform for automating deployment, scaling, and management of containerized applications. It allows you to manage the scaling of containers and their deployment across multiple machines in a cluster and provides features for managing network and storage resources, rolling updates, and automatic failover. This helps to ensure high availability and reliability of applications running in the cluster.</p><h4>HELM</h4><p>Helm is a package manager for Kubernetes that simplifies the deployment and management of applications in a Kubernetes cluster. It allows you to define and package your applications as charts, which can be easily installed and managed. Helm provides features for managing the lifecycle of your applications, including upgrades, rollbacks, and removal. By using Helm, you can automate the deployment and management of your applications in a Kubernetes cluster, making it easier to share and manage complex applications.</p><p>Here I am trying to explain the process of deploying WSO2 identity server in Kubernetes using HELM and background concepts related to them.</p><h3>Prerequisites</h3><ul><li>Clone the repository : <a href="https://github.com/GimhanRanasinghe/wso2is-helm.git">https://github.com/GimhanRanasinghe/wso2is-helm.git</a></li><li><a href="https://www.docker.com/">Docker</a></li><li><a href="https://minikube.sigs.k8s.io/docs/start/">Minikub</a>e</li><li><a href="https://kubernetes.io/docs/tasks/tools/">Kubectl</a></li><li><a href="https://helm.sh/docs/intro/install/">HELM</a></li></ul><h3>Let’s get started</h3><p><strong>To start the minikube cluster execute following command</strong></p><pre>minikube start --driver=docker</pre><p><strong>You can check the status of minikube using following command</strong></p><pre>minikube status</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G2T8Qyzmeq6BewYzgLyeYQ.png" /><figcaption>Output of “minikube status”</figcaption></figure><p><strong>To enable the NGINX Ingress controller,</strong></p><pre>minikube addons enable ingress</pre><p><strong><em>Continue from the section “Create HELM charts” if you wish to make your own HELM chart. If you want to just deploy WSO2 identity server into Kubernetes using HELM charts, you can continue it from the section “Explore HELM chart”.</em></strong></p><h3>Create HELM charts</h3><p><strong>To initialize a chart use following command</strong></p><pre>helm create helm-is</pre><ul><li>“helm-is” is my HELM chart name. Above command will create a new HELM chart named helm-is with a directory with the same name.</li></ul><p>Newly created folder contains files and folders as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8aHmm6muy8fFReFEjySKfw.png" /><figcaption>Files and folders of “helm-is” folder</figcaption></figure><ul><li><em>Chart.yaml — This file defines the chart’s metadata, such as the chart name, version, and description.</em></li><li><em>templates — All the templates are stored here. The chart’s templates define the Kubernetes manifests that will be deployed when the chart is installed.</em></li><li><em>values.yaml — This file that contains a mapping of keys to values. The keys and values in the file represent the configuration for your application, such as the image name for a container, the number of replicas for a deployment, or the port to expose for a service.</em></li><li><em>charts — This folder is used to store the chart dependencies of a Helm chart. A chart can depend on one or more other charts. Those dependencies are stored here.</em></li></ul><p>Now you can create/update these files to deploy your application. (Delete files in test folder as we are not going to implement test files in this project)</p><p>From now onwards, I will continue with the files which you have clone from the repository. <em>(You can either replace templated folder and values.yaml file with the respective folders and files in the cloned folder from the git repository or you can straight away use the cloned folder from the git repository.)</em></p><h3>Explore HELM chart</h3><p>Now you have created your HELM chart. Let’s explore some of the key features of HELM and the HELM chart we generated.</p><p><strong>Main advantage of HELM is it provides a convenient way to manage the installation, upgrade, and rollback of your applications and services, making it easier to manage and maintain your cluster.</strong></p><p>According to our HELM chart, there are following files in helm-is folder.</p><ul><li>Chart.yaml</li><li>values.ymal</li></ul><p>In templates folder,</p><ul><li>_helpers.tpl</li><li>deployment.yaml</li><li>service.yaml</li><li>ingress.yaml</li></ul><p>Let’s explore them,</p><p><strong>Chart.yaml file is used to define the chart’s metadata, such as the chart name, version, and description.</strong></p><h4>Why do we need values.yaml file ?</h4><p><strong>The main advantage of using the values.yaml file to store configuration values, instead of hard-coding them in the chart files, is increased flexibility and reusability of your charts.</strong></p><p>Some of the specific benifits are as follows,</p><ul><li>Parametrization — We can define a set of parameters that can be passed in during installation. This allows users to customize the configuration of the chart components and resources for specific use cases, making our charts more flexible and reusable.</li><li>Easy Configuration Management — This provides a centralized location to store configuration values, making it easier to manage and maintain your charts. If we need to update any configuration on files, we need not to go through chart files. Instead of that we can change those configuration values in values.yaml file which is act as a centralized location.</li><li>Separation of Concerns — We can keep the chart files clean and focused on the components and resources being deployed. It helps us to understand the chart very easily and reduces the risk of introducing errors or bugs during development.</li><li>Improved Security — We store sensitive information, such as passwords or encryption keys, and pass them to the chart as encrypted values during installation.</li></ul><p><strong>Let’s take an example from our HELM chart.</strong></p><p><strong><em>values.yaml file</em></strong></p><pre>deployment :  <br>  replicas : 1<br>  mainContainer :<br>    name : wso2is<br>    image : gimhanwso2/wso2is:latest<br>    port : 9443<br><br>service :<br>  type : NodePort<br>  port : 9443<br>  portName: https</pre><p><strong><em>deployment.yaml file</em></strong></p><pre>spec:<br>  containers:<br>  - name: {{ .Values.deployment.mainContainer.name }}<br>    image: {{ .Values.deployment.mainContainer.image }}<br>    ports:<br>    - containerPort: {{ .Values.deployment.mainContainer.port }} </pre><p><strong><em>service.yaml file</em></strong></p><pre>ports:<br>- protocol: TCP<br>  port: {{ .Values.service.port }}<br>  name: {{ .Values.service.portName }}</pre><p>As above code segments shows, values of the values.yaml file are set to chart files like deployment.yaml, service.yaml and ingress.yaml. If we need to change any of these values, we need not to work on every chart file, we just need to change the value in the values.yaml file. It will be automatically applied.</p><h4>What is _helper.tpl file ?</h4><p>The .tpl files are templates that are used to generate resource manifests, such as Kubernetes manifests, that define the components and resources of your application or service. The .tpl files use the Go template language to define variables and control structures that can be dynamically populated with values during chart installation.</p><p><strong><em>_helper.tpl file</em></strong></p><pre>{{- define &quot;livenessProbe&quot;}}<br>livenessProbe:<br>  httpGet:<br>    path: /health<br>    port: 8010<br>  initialDelaySeconds: 30<br>  timeoutSeconds: 1<br>{{- end}}</pre><p><strong><em>deployment.yaml file</em></strong></p><pre>{{- if .Values.checkHealth}}{{- include &quot;livenessProbe&quot; . | indent 8}}{{ end }}</pre><p>According to the above code sample, if .Values.checkHealth becomes true, “livenessProbe” named template will be included.</p><p>In summary, the .tpl files provide a way to dynamically generate resource manifests based on values passed in during installation, while the values.yaml file provides a centralized and manageable way to store and manage configuration values for your chart.</p><h3>Start deploying</h3><p><strong>Navigate to the folder which contains helm-is folder.</strong> <em>(Folder with the chart name)</em></p><p><strong>You can view whole deployment code using following command.</strong></p><pre>helm template helm-is</pre><p>This command is used to generate the manifests for a Helm chart. This command takes a chart and processes it through its templates, producing a set of Kubernetes manifests. All values of values.yaml , named templates are applied to the output. However it will not deployed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HxsV3-qlKNzuIeJYIXUoyQ.png" /><figcaption>Output of “helm template helm-is”</figcaption></figure><p><strong>You can install the Helm chart into a Kubernetes cluster using following commands.</strong></p><pre>helm install helm-is --name-template isrelease</pre><p><strong>Note :</strong><br><strong>We can specify values directly on the command line. </strong><br><em>For example in our code, we are maintaining a value called “checkHealth” which is false by default in values.yaml file. According to the implementation, id checkHealth value is true, it will add a liveness probes to containers. As checkHealth is false by default, it will not add liveness probes to containers, but we can override those values through command line as follows.</em></p><pre>helm install helm-is --name-template isrelease --set checkHealth=true</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aWKhzKuoMJjd8C8fyYX8Iw.png" /></figure><ul><li><em>“helm-is” — HELM chart name</em></li><li><em>“isrelease” — Release name</em></li></ul><p>Now you can check newly created deployments, service and ingress as follows,</p><pre>kubectl get deployments</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-sTqmBmypRn756EIRf5N6w.png" /><figcaption>Deployments</figcaption></figure><pre>kubectl get services</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pRVD_R5oqWKcnTHpomr0Iw.png" /><figcaption>Services</figcaption></figure><pre>kubectl get ingress</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vzhBSPt6hZaz4bJhhMq9Ww.png" /><figcaption>Ingress</figcaption></figure><p><strong>You can modify the configuration of an existing release and apply the changes to the running deployment as follows.</strong></p><pre>helm upgrade isrelease helm-is</pre><ul><li><em>“isrelease” — Release name</em></li><li><em>“helm-is” — HELM chart name</em></li></ul><p><em>Note:<br>As previously mentioned, you can set values using “set” flag.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4yeAzFBhbObohu9a7K78cQ.png" /><figcaption>Output of upgrade command</figcaption></figure><p><strong>Now we need to add the hostname specified in the Ingress resource to the /etc/hosts file of the machines that will access the Ingress.</strong></p><p>As it is a simple text file you can add host name and IP address of the Ingress resource as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lzaUAon3QEJgccSxifOsgA.png" /></figure><ul><li><em>IP address of the Ingress resource can be found in the output of “kubectl get ingress” command which we executed previously.</em></li><li><em>Host name is specified in ingress.yaml file</em></li></ul><p>By adding the host name and IP address of the Ingress resource, you are able to access the services exposed by the Ingress using the host name, even if the DNS server is not configured correctly. This allows you to test your application or service before deploying it to a production environment.</p><p><strong>Now all set to access our newly deployed WSO2 Identity Server via browser.</strong></p><blockquote><strong>You can access </strong><a href="https://wso2/carbon/admin/login.jsp"><strong>https://wso2/carbon/admin/login.jsp</strong></a></blockquote><h3>Conclusion</h3><p>I hope you’re now able to use WSO2 Identity Server which we just deployed using HELM. I didn’t try to go deep on any of these concepts. I only attempted to describe, fundamental background ideas and the process, what we need know in order to deploy the identity server.</p><p>As I’m new to Kubernetes and HELM, there are many things that I need to learn. Therefore, please kindly let me know if there’s anything to be adjusted or improved!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7cfcc5258140" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WSO2 Identity Server deployment using Docker]]></title>
            <link>https://medium.com/@gimhanranasinghe/wso2-identity-server-deployment-using-docker-7fcceda6e142?source=rss-34fdd42c10ed------2</link>
            <guid isPermaLink="false">https://medium.com/p/7fcceda6e142</guid>
            <dc:creator><![CDATA[Gimhan Ranasinghe]]></dc:creator>
            <pubDate>Thu, 02 Mar 2023 09:09:10 GMT</pubDate>
            <atom:updated>2023-03-02T09:09:10.933Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qEj5ZdL0ft6YmFCzx-Ejrw.jpeg" /></figure><h3>Introduction</h3><p><strong>Docker — </strong>Docker is a platform that enables developers to build, package, and run applications in containers. Containers are lightweight and isolated software packages that provide consistency and compatibility across different environments. By using Docker, developers can reduce the time and effort required to manage applications and ensure that they run consistently and efficiently</p><p><strong>WSO2 Identity Server</strong> — WSO2 Identity Server is an open-source identity and access management (IAM) product that simplifies the creation of customer identity and access management (CIAM) solutions. It provides a centralized platform for controlling and protecting access to resources, streamlines authentication, authorization, and identity management procedures and offers identity governance capabilities such as role-based access control, password policy management, and user account management.</p><p>Here we are going discuss how to deploy WSO2 identity server using Docker and basic concepts of docker that we need to know when deploying the WSO2 identity server.</p><h3>Prerequisites</h3><ol><li>Clone the repository : <a href="https://github.com/wso2/docker-is.git">https://github.com/wso2/docker-is.git</a></li><li><a href="https://www.docker.com/">Docker</a> — v17.09.0 or above</li><li>Download <a href="https://wso2.com/identity-server">WSO2 Identity Server — version 6.1.0</a></li></ol><h3>Let’s begin the deployment</h3><h4><strong>As the first step, let’s build docker image</strong></h4><p>Copy the wso2is-6.1.0.zip <em>(Downloaded WSO2 Identity Server)</em> to docker-is/dockerfiles/ubuntu/is directory (cloned repository) which contains the Dockerfile.</p><p><strong><em>What is docker image?<br></em></strong><em>Docker image is a pre-built and ready-to-run software package that includes all the necessary components and dependencies to run a particular application. It acts as a blueprint for creating containers, which are isolated and self-contained environments that run the application. They can be easily reused and shared with others, making it easier to distribute and run applications consistently across different environments. It is build using a file called Dockerfile, which contains set of instruction, which specify how the image should be assembled.</em></p><p><strong>Navigate to the folder which contains the dockerfile and execute <em>docker build</em> command to build the image.</strong></p><pre>docker build -t wso2is:6.1.0 .</pre><ul><li><em>“docker build” is the command to build docker images.</em></li><li><em>“-t” specifies the name and tag of the image. According to the above command image name is “wso2is” and tag is “6.1.0” .</em></li><li><em>The final argument “.” specifies the build context which is the current directory in our example.</em></li></ul><p><strong>After executing above command you can view the built images using following command.</strong></p><pre>docker images</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4BfzlWIlsJivQ5A3FLEKAA.png" /><figcaption>Output of command “docker images”</figcaption></figure><h4>Next, we can run a container using the docker image</h4><p><strong>To run a container you can execute the following command</strong></p><pre>docker run -it -p 9443:9443 wso2is:6.1.0</pre><ul><li><em>“docker run” is the command to run a container using a docker image</em></li><li><em>“-it” option specifies that you want to run the container in interactive mode which allows you to interact with the application inside the container.</em></li><li><em>“-p 9443:9443” option is used to map the host port 9443 to the container port 9443. First “9443” represent the host port and second “9443” represent the container port. Then we can access the the application which is running in the container, from the host.</em></li><li><em>“wso2is:6.1.0” is the image we are using to launch the new container.</em></li></ul><p><strong>Now you can view newly created container by executing the following command. (Use a new terminal tab as WSO2 identity server is running on interactive mode in previous tab)</strong></p><pre>docker ps</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gJGf2jV-iPu4RMjNDvvrCA.png" /><figcaption>Output of command “docker ps”</figcaption></figure><p><strong>Now we have successfully deployed WSO2 identity server using docker. You should be able to access following links through your browser.</strong></p><blockquote><strong>Management Console : </strong><a href="https://localhost:9443/carbon/admin/login.jsp"><strong>https://localhost:9443/carbon/admin/login.jsp</strong></a><strong><br>User Portal : </strong><a href="https://localhost:9443/myaccount"><strong>https://localhost:9443/myaccount</strong></a></blockquote><p><strong>Use “admin” as both username and password to login.</strong></p><h3>Additional</h3><p>You can push docker images to Docker Hub which is a centralized repository for storing and distributing Docker images. When you push the build images to the Docker Hub, that image will be accessible to others and it will be securely stored there. When you need that image again you can pull it very easily.</p><h4><strong>Follow these steps to push your image to your Docker Hub through terminal.</strong></h4><p><strong>Login to Docker Hub (Register in Docker Hub before trying to login)</strong></p><pre>docker login</pre><p><em>You need to enter your username and password of your Docker Hub account.</em></p><p><strong>Tag the image</strong></p><pre>docker tag wso2is:6.1.0 &lt;username&gt;/&lt;repository&gt;</pre><p><em>&lt;username&gt; — Username of your Docker Hub<br>&lt;repository&gt; — Image name</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pRE8cvIX_pBAZrrcYw9t7A.png" /></figure><p><strong>Push the image</strong></p><pre>docker push &lt;username&gt;/&lt;repository&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZJh59ItJy8tykpJO0w1xqQ.png" /></figure><p>You can verify that it has been uploaded to Docker Hub by logging in to your Docker Hub account and checking the repository.</p><p><strong>Logout from Docker Hub</strong></p><pre>docker logout</pre><h3>Conclusion</h3><p>I hope you’re now able to use WSO2 Identity Server which we just deployed using Docker. I didn’t try to go deep on any of these concepts. I just try to explain what we should do in order to deploy the identity server and basic concepts about docker.</p><p>Please kindly let me know if there’s anything to be adjusted or improved!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7fcceda6e142" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>