<?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 Subhash Chandra Budde on Medium]]></title>
        <description><![CDATA[Stories by Subhash Chandra Budde on Medium]]></description>
        <link>https://medium.com/@subhashchandra.b?source=rss-f122f3be6873------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*VHtrJiP1ZtgSWnRFx4E-Zw.jpeg</url>
            <title>Stories by Subhash Chandra Budde on Medium</title>
            <link>https://medium.com/@subhashchandra.b?source=rss-f122f3be6873------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 05:25:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@subhashchandra.b/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[Terraform execution using GitHub Actions with self-hosted runners on Oracle Cloud Infrastructure]]></title>
            <link>https://medium.com/@subhashchandra.b/terraform-execution-using-github-actions-with-self-hosted-runners-on-oracle-cloud-infrastructure-7bedfc31df20?source=rss-f122f3be6873------2</link>
            <guid isPermaLink="false">https://medium.com/p/7bedfc31df20</guid>
            <category><![CDATA[oracle-cloud]]></category>
            <category><![CDATA[github-workflow]]></category>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[self-hosted-runner]]></category>
            <dc:creator><![CDATA[Subhash Chandra Budde]]></dc:creator>
            <pubDate>Tue, 17 Jun 2025 12:30:46 GMT</pubDate>
            <atom:updated>2025-06-17T12:30:46.738Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://docs.github.com/en/actions">GitHub Actions</a> is a continuous integration and continuous delivery (CI/CD) platform that allows you to automate your build, test, and deployment pipeline.</p><p>A GitHub <a href="https://docs.github.com/en/actions/writing-workflows">Workflow</a> is a configurable, automated process defined by a YAML file within a GitHub repository, used to run tasks like building, testing, and deploying software. These workflows are executed by GitHub Actions, and can be triggered by various events, such as pushing code, opening pull requests, or a scheduled time.</p><p>A GitHub Actions runner is a machine that executes jobs within a GitHub Actions workflow. GitHub Actions offers two main types of runners: GitHub-hosted runners and self-hosted runners.</p><p>In this article, I’ll demonstrate how we can setup the self-hosted runners using a <a href="https://docs.oracle.com/en-us/iaas/Content/Compute/home.htm">VM on Oracle Cloud Infrastructure</a>. We will also use this self hosted runner to execute a sample terraform to create an Object Storage Bucket using Github actions. We will use the <a href="https://docs.oracle.com/en-us/iaas/Content/dev/terraform/configuring.htm#instance-principal-auth">Instance Principal Authorization</a> to execute the Terraform on Oracle Cloud Infrastructure.</p><p>Before running the steps in this article, you must have access to the valid OCI tenancy with full access to a specific compartment. This activity involves following set of operations.</p><ol><li>Create a dynamic group and setup the IAM policy</li><li>Create a bucket for storing the Terraform state</li><li>Create a registration token for GitHub organization</li><li>Setup a private Github repository with Terraform files</li><li>Setup the Github Actions to execute the terraform</li><li>Setup the self-hosted runner on OCI using Resource Manager Stack</li><li>Validate the Github Actions Workflow</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B7FxDVOF7sBocJNwmwxHnQ.jpeg" /><figcaption>Terraform execution using self-hosted runner on OCI</figcaption></figure><p><strong>1. Create a Dynamic Group and setup the IAM policy</strong></p><p>Create a <a href="https://docs.oracle.com/en-us/iaas/Content/Identity/Tasks/managingdynamicgroups.htm#Working">Dynamic Group</a> with the following matching rule. Make sure you update the OCID of the appropriate compartment. The self-hosted runner we will be creating in the next steps, will be part of this Dynamic Group and we will be using the <a href="https://docs.oracle.com/en-us/iaas/Content/dev/terraform/configuring.htm#instance-principal-auth">Instance Principal Authorization</a> for the terraform execution.</p><pre>ALL {instance.compartment.id = &#39;ocid1.compartment.oc1..aaaaaaaa23______smwa&#39;}</pre><p>Add the <a href="https://docs.oracle.com/en-us/iaas/Content/Identity/policieshow/Policy_Basics.htm">IAM policy</a> with following statements.</p><blockquote>Please note that these policies are required as we will be creating an object storage bucket through terraform in the current article. You need to add the relevant policies based on the type of resources you will be creating.</blockquote><pre>Allow dynamic-group &lt;dynamic-group-name&gt; to manage buckets in compartment &lt;compartment-name&gt;<br>Allow dynamic-group &lt;dynamic-group-name&gt; to manage objects in compartment &lt;compartment-name&gt;</pre><p><strong>2. Create a bucket for storing the Terraform state</strong></p><p>As the terraform execution is happening inside the self-hosted runner, it’s important to maintain the state file externally. We will be creating an <a href="https://docs.oracle.com/en-us/iaas/Content/Object/Tasks/managingbuckets_topic-To_create_a_bucket.htm#top">Object Storage Bucket</a> for this purpose. Create a bucket with the name github-actions-tfstate in the above compartment for which the dynamic group and IAM policy are already setup in step 1.</p><blockquote>Please enable the versioning on the bucket so that the terraform state for each run will be maintained in specific version of the state file inside this bucket which will help for state recovery in the case of accidental deletions and human error.</blockquote><p><strong>3.</strong> <strong>Create a registration token for GitHub organization</strong></p><p>For executing the actions in this step, it’s assumed you have a valid GitHub account and <a href="https://docs.github.com/en/organizations/collaborating-with-groups-in-organizations/about-organizations">organization</a> already setup. For the demonstration, I will be using my GitHub account where I have an organization called oci-demos.</p><p>Execute the following curl command to generate the registration token for this organization.</p><pre>curl -L \<br>  -X POST \<br>  -H &quot;Accept: application/vnd.github+json&quot; \<br>  -H &quot;Authorization: Bearer github_pat_******&quot; \<br>  -H &quot;X-GitHub-Api-Version: 2022-11-28&quot; \<br>  https://api.github.com/orgs/oci-demos/actions/runners/registration-token</pre><p>Ensure that you update the Bearer token and the organization name in the above curl command as per your environment. I used the fine grained personal access token in this command. If required, You can use other fine grained token types as explained <a href="https://docs.github.com/en/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-an-organization">here</a>.</p><blockquote>If you are creating a personal access token, ensure that you are selecting the corresponding organization as the resource owner. In my case, the resource owner will be oci-demos.</blockquote><p>Make a note of the token value from the output of the curl command, which will be required in the Step 5. Note that this token will be typically valid for 1 hours from the time of generation.</p><pre>{<br>  &quot;token&quot;: &quot;ABCD***********&quot;, <br>  &quot;expires_at&quot;: &quot;2025-06-17T12:51:41.161+05:30&quot;<br>}</pre><p><strong>4. Setup a private Github repository with Terraform files</strong></p><p>In this setup, we will setup a private GitHub repository under the same organization for which we created registration token in the previous step. This repository contains the terraform files to create an Object Storage Bucket in OCI. For this demonstration, I created a repository called github-actions-demo under the organization oci-demos. It contains 3 terraform files as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/308/1*HrP1LwYHcFq0ui31Mj-Wag.png" /><figcaption>Folder and files in the GitHub repository</figcaption></figure><ul><li>Create provider.tf file under oci-tf-oss with below content. Note that we have backend configuration here which will store the terraform state in the bucket which is created in step 2. Update the <a href="https://docs.oracle.com/en-us/iaas/Content/Object/Tasks/understandingnamespaces.htm">object storage namespace</a> and region values as per your environment.</li></ul><pre>terraform {<br>  required_version = &quot;&gt;=1.12.0&quot;<br>  required_providers {<br>    oci = {<br>      source  = &quot;oracle/oci&quot;<br>      version = &quot;7.4.0&quot;<br>      configuration_aliases = [oci.home]<br>    }<br>  }<br>  backend &quot;oci&quot; {<br>    bucket            = &quot;github-actions-tfstate&quot;<br>    namespace         = &quot;abcxyz***&quot; #Update Object storage namespace<br>    region            = &quot;eu-frankfurt-1&quot; #Update youre region<br>    auth              = &quot;InstancePrincipal&quot;<br>    key               = &quot;github-actions-demo/oci-tf-oss.tfstate&quot;<br>  } <br>}<br><br>provider &quot;oci&quot; {<br>  region = var.region<br>  auth = &quot;InstancePrincipal&quot;<br>}<br><br>provider &quot;oci&quot; {<br>  alias = &quot;home&quot;<br>  region = var.region<br>  auth = &quot;InstancePrincipal&quot;<br>}</pre><ul><li>Create bucket.tf file under oci-tf-oss with below content.</li></ul><pre>resource &quot;oci_objectstorage_bucket&quot; &quot;github_actions_bucket&quot; {<br>    #Required<br>    compartment_id = var.compartment_ocid<br>    name           = var.bucket_name<br>    namespace      = var.bucket_namespace<br>    # freeform_tags = {&quot;runner-type&quot;= &quot;self-hosted&quot;, &quot;devops-source&quot;=&quot;github&quot;}<br>}</pre><ul><li>Create variables.tf file under oci-tf-oss with below content.</li></ul><pre># Pass tenancy_ocid as var in the pipeline. This can be configured in variables/secrets in github environment.<br>variable &quot;tenancy_ocid&quot; {<br>   description = &quot;OCID of the tenancy&quot;<br>}<br><br># Pass compartment_ocid as var in the pipeline. This can be configured in variables/secrets in github environment.<br>variable &quot;compartment_ocid&quot; {<br>  description = &quot;OCID of the compartment where the bucket should be created&quot;<br>}<br><br># Override default region value if required.<br>variable &quot;region&quot; {<br>  default = &quot;eu-frankfurt-1&quot;<br>  description = &quot;Name of the region&quot;<br>}<br><br>variable &quot;bucket_name&quot; {<br>  description = &quot;Name of the bucket&quot;<br>}<br><br>variable &quot;bucket_namespace&quot; {<br>  description = &quot;Namespace to be used for the object storage service&quot;<br>}</pre><p><strong>5. Setup the Github Actions to execute the terraform</strong></p><p>. Navigate to the repository settings in GitHub and create new environment with a name like ocitest. <a href="https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-an-environment">Configure the environment</a> so that it includes the following secrets and variables. These values will be used against the required Terraform variables for running the terraform on your tenancy.</p><pre>Environment secrets:<br>    TENANCY_OCID     = The OCID of the Oracle Cloud tenancy<br><br>Environment variables:<br>    BUCKET_NAME      = &quot;github_actions_bucket&quot;<br>    BUCKET_NAMESPACE =  Object storage service namespace <br>    COMPARTMENT_OCID = The OCID of the compartment<br>    REGION           = &quot;eu-frankfurt-1&quot;</pre><ul><li>Navigate to the Actions tab on the github-actions-demo repository and click on New workflow. In the UI for Choose a workflow, click on the link <strong>set up a workflow yourself. </strong>Copy the below content into the workflow yaml file.</li></ul><pre>name: &#39;OCI Terraform&#39;<br><br>on:<br>  push:<br>    branches: [ &quot;main&quot; ]<br>    paths:<br>      - oci-tf-oss/**<br>  pull_request:<br><br>env:<br>  TF_VAR_tenancy_ocid: ${{ secrets.TENANCY_OCID }}<br>  TF_VAR_compartment_ocid: ${{ vars.COMPARTMENT_OCID }}<br>  TF_VAR_bucket_name: ${{ vars.BUCKET_NAME }}<br>  TF_VAR_bucket_namespace: ${{ vars.BUCKET_NAMESPACE }}<br>  TF_VAR_region: ${{ vars.REGION }}<br>  <br>permissions:<br>  contents: read<br><br>jobs:<br>  terraform:<br>    name: &#39;Terraform&#39;<br>    runs-on: self-hosted<br>    environment: ocitest # Update the name of the environment <br><br>    # Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest<br>    defaults:<br>      run:<br>        shell: bash<br><br>    steps:<br>    # Checkout the repository to the GitHub Actions runner<br>    - name: Checkout<br>      uses: actions/checkout@v4<br><br>    - uses: actions/setup-node@v4<br>      with:<br>        node-version: 20<br>        <br>    # Install the latest version of Terraform CLI and configure the Terraform CLI configuration file with a Terraform Cloud user API token<br>    - name: Setup Terraform<br>      uses: hashicorp/setup-terraform@v1<br>      with:<br>        terraform_version: 1.12<br>            <br>    # Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc.<br>    - name: Terraform Init<br>      run: terraform init<br>      working-directory: oci-tf-oss<br><br>    # Generates an execution plan for Terraform<br>    - name: Terraform Plan<br>      run: terraform plan <br>      working-directory: oci-tf-oss<br><br>      # On push to &quot;main&quot;, build or change infrastructure according to Terraform configuration files<br>      # Note: It is recommended to set up a required &quot;strict&quot; status check in your repository for &quot;Terraform Cloud&quot;. See the documentation on &quot;strict&quot; required status checks for more information: https://help.github.com/en/github/administering-a-repository/types-of-required-status-checks<br>    - name: Terraform Apply<br>      run: terraform apply -auto-approve <br>      working-directory: oci-tf-oss</pre><p>This workflow is setup such that it’s triggered whenever any changes committed to the oci-tf-oss folder of the repository.</p><p><strong>6. Setup the self-hosted runner on OCI using Resource Manager Stack</strong></p><p>We will use the <a href="https://docs.cloud.oracle.com/en-us/iaas/Content/ResourceManager/Concepts/resourcemanager.htm">OCI Resource Manager</a> stack from <a href="https://github.com/oracle-quickstart/oci-github-actions-runner">Oracle Quick Start</a> for provisioning the self-hosted GitHub runner on OCI.</p><ul><li>Download the <a href="https://github.com/oracle-quickstart/oci-github-actions-runner/releases/download/orm-deploy/orm.zip">orm.zip</a> from the <a href="https://github.com/oracle-quickstart/oci-github-actions-runner">Oracle Quick Start</a></li><li><a href="https://docs.oracle.com/en-us/iaas/Content/ResourceManager/Tasks/create-stack-local.htm">Create OCI Resource Manager stack using the zip file</a> downloaded above</li><li>In Configure variables section, make sure that you update the values for the following variables as per your environment. Remaining variables can be left intact with default values.</li></ul><pre>GitHub URL (Organization or Repository) : The GitHub organization URL which is used for the current setup<br>GitHub Actions Runner Registration Token : Registration token obtained in step 3. Regenrate the token if the token expired.<br>GitHub Actions Runner Version : 2.325.0<br>Availability Domain: Select one of the availability domains<br>Compute Shape: VM.Standard.E4.Flex<br>Operating System: Oracle Linux 8<br>Platform Image: Oracle-Linux-8.10-2025.03-18-0<br>Public SSH Key: Update the public ssh key if you need SSH connectivity to the runner instance</pre><ul><li>In the review page, Click on the checkbox <strong>Run apply</strong></li><li>Wait for the stack execution to be successful. It may take few minutes.</li><li>Navigate to the GitHub organization settings and expand the <strong>Actions</strong> section. Click on <strong>Runners</strong> and you should notice that there is a new runner with the name githubrunner-0 as shown below. If you don’t notice the runner instance within few minutes after the successful completion of Resource manager stack execution in the earlier step, you need to cross check variable values for the Stack. If required, Destroy and Apply the Stack after making necessary changes to the variable values.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*DQANNjE0IVw5nq5QIslQWQ.png" /></figure><p><strong>7. Validate the Github Actions Workflow</strong></p><ul><li>Navigate to the GitHub repository containing the terraform files created in step 4.</li><li>Update any terraform file and commit the change. For example, you can add some comments to any file.</li><li>As per our GitHub actions setup in step 5, the commit operation will trigger the workflow which will execute the terraform. You can verify whether the workflow execution is successful by navigating to the Actions tab of the GitHub repository.</li><li>You can also login to the Oracle Cloud console and verify that there is a new bucket created with the name you provided for the value of environment variable BUCKET_NAME in step 5.</li><li>To verify the terraform state persistence in the designated bucket which is created in step 2, you can navigate to the bucket github-actions-tfstate and confirm that there is a file called oci-tf-oss.tfstate under the folder github-actions-demo.</li><li>To further validate the terraform state persistence, you can uncomment the below line in the bucket.tf file and commit the change.</li></ul><pre> # freeform_tags = {&quot;runner-type&quot;= &quot;self-hosted&quot;, &quot;devops-source&quot;=&quot;github&quot;}</pre><ul><li>This should trigger the terraform workflow again. This time, the terraform execution will be based on the previous state persisted in the bucket github-actions-tfstate. As a result, the <a href="https://docs.oracle.com/en-us/iaas/Content/Tagging/Concepts/understandingfreeformtags.htm">freeform tags </a>will be applied on the bucket which was created in the previous run. You can validate the same from OCI console.</li><li>As we have enabled the versioning for the bucket github-actions-tfstate, you can see that a new version is created for the state file oci-tf-oss.tfstate. A new version will be created for the sate file for every terraform run triggered through the GitHub actions.</li></ul><p>This concludes the demonstration where we are able to setup a self-hosted GitHub runner on OCI and use the same to run a workflow which executes the terraform to create an object storage bucket. The same setup can be extended to create other types of OCI resources. Similarly, you can fine-tune the GitHub actions and workflow to add more control over the triggers.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7bedfc31df20" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setup Kubernetes Gateway API using Istio on OKE with TLS termination at LoadBalancer]]></title>
            <link>https://medium.com/@subhashchandra.b/setup-kubernetes-gateway-api-using-istio-on-oke-with-tls-termination-at-loadbalancer-0a1729f409d1?source=rss-f122f3be6873------2</link>
            <guid isPermaLink="false">https://medium.com/p/0a1729f409d1</guid>
            <category><![CDATA[oci]]></category>
            <category><![CDATA[oke]]></category>
            <category><![CDATA[api-gateway]]></category>
            <category><![CDATA[oraclecloudinfrastructure]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Subhash Chandra Budde]]></dc:creator>
            <pubDate>Fri, 23 May 2025 13:52:29 GMT</pubDate>
            <atom:updated>2025-05-23T13:52:29.730Z</atom:updated>
            <content:encoded><![CDATA[<p>Networking and traffic management are key requirements while deploying the cloud native applications. Kubernetes provides the following two ways to address these requirements.</p><ul><li><a href="https://kubernetes.io/docs/concepts/services-networking/ingress/">Ingress</a> : Ingress provides a centralized way to manage external access to the services running inside the kubernetes clusters. Ingress supports the HTTP/HTTPS traffic management at L7 layer.</li><li><a href="https://kubernetes.io/docs/concepts/services-networking/gateway/">Gateway API</a>: Gateway API consists a set of API kind objects which provide dynamic infrastructure provisioning and advanced traffic routing at L4 and L7 protocols including TCP, UDP, HTTP, gRPC.</li></ul><p>Gateway API project was created by Kubernetes to handle the limitations of Ingress (like multiple protocol support)and unify the capabilities across different ingress controllers thereby introducing portability which will enable the users to choose or switch between any Gateway API implementation either open-source or commercial. Currently the Ingress is frozen and any new features will be added to Gateway API going forward.</p><p>In this article, we will explore one of the popular open source implementation for Gateway API which is from <a href="https://istio.io/latest/docs/tasks/traffic-management/ingress/gateway-api/">Istio</a>. For this exercise, we are going to use the managed Kubernetes service of <a href="https://www.oracle.com/cloud/">Oracle Cloud Infrastructure</a> popularly known as <a href="https://www.oracle.com/cloud/cloud-native/kubernetes-engine/">OKE</a>. As the native Gateway API implementation is not yet available in OKE, Istio is one of the best possible options to setup the Gateway API in OKE clusters.</p><p>Before running the steps in this article, you must have a valid OKE cluster setup and running in OCI with appropriate permissions to create the required resources like Load Balancer. For creating the OKE cluster through console, you can refer the public documentation for <a href="https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengcreatingclusterusingoke_topic-Using_the_Console_to_create_a_Quick_Cluster_with_Default_Settings.htm#create-quick-cluster">Quick Create flow</a>. Alternatively, you can also refer the <a href="https://docs.oracle.com/en-us/iaas/developer-tutorials/tutorials/tf-cluster/01-summary.htm">terraform way</a> of creating the OKE cluster.</p><p>I’ll demonstrate the following operations.</p><ol><li>Install the Gateway API CRDs</li><li>Install Istio in OKE cluster</li><li>Setup the self-signed certificates to be used at LoadBalancer</li><li>Configure the Gateway and LoadBalancer service</li><li>Deploy sample applications and setup the corresponding HTTPRoutes</li><li>Test the sample applications</li><li><strong>Install the Gateway API CRDs</strong></li></ol><p>Gateway API CRDs will not be available in the OKE cluster by default. Execute the below command to setup the CRDs as explained in the official Istio <a href="http://Install the Gateway API CRDs">documentation</a>.</p><pre>kubectl get crd gateways.gateway.networking.k8s.io &amp;&gt; /dev/null || \<br> { kubectl kustomize &quot;github.com/kubernetes-sigs/gateway-api/config/crd?ref=v1.3.0-rc.1&quot; | kubectl apply -f -; }</pre><p>Verify the succesful creation of the CRDs as shown below</p><pre>customresourcedefinition.apiextensions.k8s.io/gatewayclasses.gateway.networking.k8s.io created<br>customresourcedefinition.apiextensions.k8s.io/gateways.gateway.networking.k8s.io created<br>customresourcedefinition.apiextensions.k8s.io/grpcroutes.gateway.networking.k8s.io created<br>customresourcedefinition.apiextensions.k8s.io/httproutes.gateway.networking.k8s.io created<br>customresourcedefinition.apiextensions.k8s.io/referencegrants.gateway.networking.k8s.io created</pre><p>2. <strong>Install Istio in OKE Cluster</strong></p><p>Istio can be setup in OKE Cluster either by enabling the add-on or by manually installing it as per the Istio documentation</p><p>Istio add-on can be enabled on OKE cluster either from the console or by using the following configuration in Terraform variables.</p><pre>cluster_addons = {<br>    &quot;Istio&quot; = {<br>      remove_addon_resources_on_delete = true<br>      override_existing                = true      <br>      configurations = [ ]<br>    }<br>}</pre><p>3. <strong>Setup the self-signed certificates</strong></p><p>Connect to any VM where you setup the access to the above OKE cluster and execute the below shell script. This script will setup the self signed wildcard certificates for a domain istioand also creates a TLS type secret for these certificates in istio-system namespace.</p><pre>#Create a root certificate and private key to sign the certificates for your services<br>mkdir example_certs1<br>cd example_certs1<br>openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -subj &#39;/O=example Inc./CN=example.com&#39; -keyout istio-ca.key -out istio-ca.crt<br><br>#Generate a wildcard certificate and a private key for *.istio-example.com<br>openssl req -out istio-example.com.csr -newkey rsa:2048 -nodes -keyout istio-example.com.key -subj &quot;/CN=istio-example.com/O=istio-example organization&quot; <br>&gt;&quot;istio-example.ext&quot; cat &lt;&lt;-EOF<br>authorityKeyIdentifier=keyid,issuer<br>basicConstraints=CA:FALSE<br>keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment<br>extendedKeyUsage = serverAuth, clientAuth<br>subjectAltName = @alt_names<br>[alt_names]<br>DNS.1 = istio-gatewayapi.com<br>DNS.2 = *.istio-gatewayapi.com<br>EOF<br><br>openssl x509 -req -sha256 -extfile istio-example.ext -days 365 -CA istio-ca.crt -CAkey istio-ca.key -set_serial 0 -in istio-example.com.csr -out istio-example.com.crt<br><br>#Create the k8s secret using the crt and key files from above step to be attached to the istio-gateway for ssl termination<br>kubectl create -n istio-system secret tls istio-example-credential --key=istio-example.com.key  --cert=istio-example.com.crt</pre><p>4. <strong>Configure the Gateway and LoadBalancer service</strong></p><p>Create the Gateway using the below yaml file. Please note the values provided in the annotations section. If you have created the OKE cluster using Terraform module, grab the OCID of the Network Security Group related to the public load balancer from the VCN. Generally, this NSG will be created with the prefix pub_lb. If you created the OKE cluster manually, create an NSG and add the required Ingress/Egress rules by referring OCI public <a href="https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengconfiguringloadbalancersnetworkloadbalancers-subtopic.htm#contengcreatingloadbalancer_topic_Specifying_Load_Balancer_Network_Security_Group">documentation</a>.</p><pre>apiVersion: gateway.networking.k8s.io/v1<br>kind: Gateway<br>metadata:<br>  name: tls-gateway<br>  namespace: istio-system<br>  annotations:<br>    service.beta.kubernetes.io/oci-load-balancer-shape: &quot;flexible&quot;<br>    service.beta.kubernetes.io/oci-load-balancer-shape-flex-min: &quot;10&quot;<br>    service.beta.kubernetes.io/oci-load-balancer-shape-flex-max: &quot;40&quot;<br>    service.beta.kubernetes.io/oci-load-balancer-ssl-ports: &quot;443&quot;<br>    service.beta.kubernetes.io/oci-load-balancer-tls-secret: &quot;istio-example-credential&quot;<br>    oci.oraclecloud.com/oci-network-security-groups: &quot;ocid1.networksecuritygroup.oc1.*******&quot;<br>    service.beta.kubernetes.io/oci-load-balancer-security-list-management-mode: &quot;None&quot;<br>    oci.oraclecloud.com/security-rule-management-mode: &quot;None&quot;<br>spec:<br>  gatewayClassName: istio<br>  listeners:<br>  - name: https<br>    hostname: &quot;*.istio-gatewayapi.com&quot;<br>    protocol: HTTPS<br>    port: 443<br>    allowedRoutes:<br>      namespaces:<br>        from: All<br>    tls:<br>      mode: Terminate<br>      certificateRefs:<br>      - kind: Secret<br>        name: istio-example-credential<br>        namespace: cert-manager<br>  - name: http<br>    hostname: &quot;*.istio-gatewayapi.com&quot;<br>    port: 80<br>    protocol: HTTP<br>    allowedRoutes:<br>      namespaces:<br>        from: All</pre><p>After applying the above yaml, ensure there is a public IP address is assigned to the service tls-gateway-istio which will be created in the istio-system namespace.</p><pre>$ k get svc -n istio-system<br>NAME                TYPE           CLUSTER-IP     EXTERNAL-IP      PORT(S)                                      AGE<br>istiod              ClusterIP      10.x.x.x       &lt;none&gt;           15010/TCP,15012/TCP,443/TCP,15014/TCP        128m<br>tls-gateway-istio   LoadBalancer   10.x.x.x       x.x.x.x          15021:32208/TCP,443:30481/TCP,80:31523/TCP   2m38s</pre><p>As we are using the TLS termination at LoadBalancer, we need to edit the LoadBalancer service yaml and update the targetport value to 80 from 443 in https port section as shown below. This is required, as the traffic from LoadBalancer to the Istio gateway will be plain http traffic due to the TLS termination is happening at the LoadBalancer.</p><pre>  - appProtocol: https<br>    name: https<br>    nodePort: 30481<br>    port: 443<br>    protocol: TCP<br>    targetPort: 80 #-&gt; This value will be 443 by default. Need to be updated to 80</pre><p>Grab the public IP of the load balancer created above and update it against the domains httpd.istio-gatewayapi.com and nginx.istio-gatewayapi.com in your /etc/hosts file. We will be using these domains in the next step when we deploy the sample applications and HTTPRoutes for httpd and nginx applications.</p><pre># Update the public load balancer IP here<br>xxx.xx.xx.xx   httpd.istio-gatewayapi.com<br>xxx.xx.xx.xx   nginx.istio-gatewayapi.com </pre><p>Optionally you can use the real DNS entries and domain names and external CA certificates if available for you.</p><p>5. <strong>Deploy Sample applications and setup the corresponding HTTPRoutes</strong></p><p>Apply the below yaml files in the cluster which will create the deployment and services for nginx and httpd applications.</p><pre> <br>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: httpd<br>spec:<br>  type: ClusterIP<br>  selector:<br>    app: httpd_app<br>  ports:<br>    - port: 8000<br>      targetPort: 80<br>---<br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: httpd-deployment-devops<br>  labels:<br>    app: httpd_app<br>spec:<br>  replicas: 1<br>  selector:<br>    matchLabels:<br>      app: httpd_app<br>  template:<br>    metadata:<br>      labels:<br>        app: httpd_app<br>    spec:<br>      containers:<br>        - name: httpd-container-devops<br>          image: httpd:latest<br>          ports:<br>            - containerPort: 80</pre><pre>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: nginx<br>spec:<br>  type: ClusterIP<br>  ports:<br>    - port: 8080<br>      targetPort: 80<br>  selector:<br>    app: nginx-project<br>---<br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: nginx-project<br>spec:<br>  replicas: 1<br>  selector:<br>    matchLabels:<br>      app: nginx-project<br>  template:<br>    metadata:<br>      labels:<br>        app: nginx-project<br>    spec:<br>      containers:<br>        - name: nginx<br>          image: nginx:latest<br>          ports:<br>            - containerPort: 80</pre><p>Check whether the deployment and services created properly and pods are in running state in the default namespace.</p><pre>$ k get all<br>NAME                                    READY   STATUS    RESTARTS   AGE<br>pod/httpd-deployment-7c6b7c85bf-v6kxj   1/1     Running   0          19s<br>pod/nginx-deployment-cbdc5f79f-drfk2    1/1     Running   0          19s<br><br>NAME                 TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)             AGE<br>service/httpd        ClusterIP   10.96.64.180   &lt;none&gt;        8000/TCP            19s<br>service/kubernetes   ClusterIP   10.96.0.1      &lt;none&gt;        443/TCP,12250/TCP   3h13m<br>service/nginx        ClusterIP   10.96.87.156   &lt;none&gt;        8080/TCP            19s<br><br>NAME                               READY   UP-TO-DATE   AVAILABLE   AGE<br>deployment.apps/httpd-deployment   1/1     1            1           19s<br>deployment.apps/nginx-deployment   1/1     1            1           19s<br><br>NAME                                          DESIRED   CURRENT   READY   AGE<br>replicaset.apps/httpd-deployment-7c6b7c85bf   1         1         1       19s<br>replicaset.apps/nginx-deployment-cbdc5f79f    1         1         1       19s</pre><p>Create the <a href="https://kubernetes.io/docs/concepts/services-networking/gateway/#api-kind-httproute">HTTPRoute</a> resources for the above deployments using the below yaml file</p><pre>apiVersion: gateway.networking.k8s.io/v1<br>kind: HTTPRoute<br>metadata:<br>  name: httpd-http-route<br>  namespace: default<br>spec:<br>  parentRefs:<br>  - name: tls-gateway<br>    namespace: istio-system<br>  hostnames: [&quot;httpd.istio-gatewayapi.com&quot;]<br>  rules:<br>  - matches:<br>    - path:<br>        type: PathPrefix<br>        value: /<br>    backendRefs:<br>    - name: httpd<br>      port: 8000<br>---<br>apiVersion: gateway.networking.k8s.io/v1<br>kind: HTTPRoute<br>metadata:<br>  name: nginx-http-route<br>  namespace: default<br>spec:<br>  parentRefs:<br>  - name: tls-gateway<br>    namespace: istio-system<br>  hostnames: [&quot;nginx.istio-gatewayapi.com&quot;]<br>  rules:<br>  - matches:<br>    - path:<br>        type: PathPrefix<br>        value: /<br>    backendRefs:<br>    - name: nginx<br>      port: 8080</pre><p>6. <strong>Test the sample applications</strong></p><p>From the same directory where the bash script from step 3 is executed, execute the below curl commands and verify that they are giving the proper response as shown below.</p><p>As we are using the self signed certificates, it’s required to pass the cacert parameter in the curl command.</p><pre>$ curl --cacert example_certs1/istio-ca.crt https://nginx.istio-gatewayapi.com/<br>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>&lt;title&gt;Welcome to nginx!&lt;/title&gt;<br>&lt;style&gt;<br>html { color-scheme: light dark; }<br>body { width: 35em; margin: 0 auto;<br>font-family: Tahoma, Verdana, Arial, sans-serif; }<br>&lt;/style&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>&lt;h1&gt;Welcome to nginx!&lt;/h1&gt;<br>&lt;p&gt;If you see this page, the nginx web server is successfully installed and<br>working. Further configuration is required.&lt;/p&gt;<br><br>&lt;p&gt;For online documentation and support please refer to<br>&lt;a href=&quot;http://nginx.org/&quot;&gt;nginx.org&lt;/a&gt;.&lt;br/&gt;<br>Commercial support is available at<br>&lt;a href=&quot;http://nginx.com/&quot;&gt;nginx.com&lt;/a&gt;.&lt;/p&gt;<br><br>&lt;p&gt;&lt;em&gt;Thank you for using nginx.&lt;/em&gt;&lt;/p&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><pre>$ curl --cacert example_certs1/istio-ca.crt https://httpd.istio-gatewayapi.com/<br>&lt;html&gt;&lt;body&gt;&lt;h1&gt;It works!&lt;/h1&gt;&lt;/body&gt;&lt;/html&gt;</pre><p>That concludes my demonstration where you are able to complete the following tasks.</p><ol><li>Install the Gateway API CRDs</li><li>Install Istio in OKE cluster</li><li>Setup the self-signed certificates to be used at LoadBalancer</li><li>Setup the Gateway</li><li>Configure the OCI LoadBalancer service with TLS termination</li><li>Deploy sample applications and setup the corresponding HTTPRoutes</li><li>Test the sample applications</li></ol><p>You can explore other capabilities of Gateway API like TCP/GRPC Routing using the same setup.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0a1729f409d1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cost Optimized Scaling in OKE using Preemptible Capacity and Priority Expander]]></title>
            <link>https://medium.com/@subhashchandra.b/cost-optimized-scaling-in-oke-using-preemptible-capacity-and-priority-expander-4a68c7990347?source=rss-f122f3be6873------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a68c7990347</guid>
            <category><![CDATA[oraclecloudinfrastructure]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[autoscaling]]></category>
            <category><![CDATA[oke]]></category>
            <category><![CDATA[preemptible-instance]]></category>
            <dc:creator><![CDATA[Subhash Chandra Budde]]></dc:creator>
            <pubDate>Fri, 27 Sep 2024 18:22:14 GMT</pubDate>
            <atom:updated>2024-09-27T18:22:14.734Z</atom:updated>
            <content:encoded><![CDATA[<p>Oracle Cloud Infrastructure offers <a href="https://docs.oracle.com/en-us/iaas/Content/Compute/Concepts/preemptible.htm#howitworks__support">Preemptible Instances</a> which will bring down the cost by 50%. Preemptible Instances can be used in the node pools of <a href="https://docs.oracle.com/en-us/iaas/Content/ContEng/Concepts/contengoverview.htm">Oracle Kubernetes Engine</a> for optimizing the cost when deploying the workloads which are fault-tolerant and can withstand interruptions. More details are available <a href="https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengusingpreemptiblecapacity.htm">here</a> in the official documentation and demo for the same can be found in this <a href="https://umashankar-s.medium.com/how-to-optimize-the-cost-on-oke-oci-container-engine-for-kubernetes-with-preemptible-node-pool-f60b6e2afdd5">blog</a>.</p><p><a href="https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler">Kubernetes Cluster Autoscaler</a> is a standalone program deployed in the cluster that adjusts the size of a Kubernetes cluster to meet the current needs. It offers different type of <a href="https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/FAQ.md#what-are-expanders">expanders</a> which will provide different strategies for selecting the node group to which new nodes will be added. In this article, we are going to explore the Priority Expander which selects the node group that has the highest priority assigned by the user. We will use the Priority Expander to prioritize the nodepools with preemptible capacity and falling back to on-demand nodepool to optimize the costs.</p><p>I will demonstrate the following operations.</p><ol><li>Create OKE cluster with different types of nodepools including the Preemptible Capacity type</li><li>Setup the Priority Expander Config Map for the node pools</li><li>Deploy the Cluster Autoscaler in OKE with required configurations</li><li>Deploy sample NGINX deployment with specific resource configurations</li><li>Observe and validate the scaling operation</li><li><strong>Create OKE Cluster and Nodepools</strong></li></ol><p>For creating the OKE cluster through console, you can refer the public documentation for <a href="https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengcreatingclusterusingoke_topic-Using_the_Console_to_create_a_Quick_Cluster_with_Default_Settings.htm#create-quick-cluster">Quick Create flow</a>. Alternatively, you can also refer the <a href="https://docs.oracle.com/en-us/iaas/developer-tutorials/tutorials/tf-cluster/01-summary.htm">terraform way</a> of creating the OKE cluster. Once you have created the cluster, make sure that you create the following 4 nodepools as per the properties given below. For more information on specifying the Capacity Type for nodepool, please refer the official <a href="https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengusingpreemptiblecapacity.htm#contengusingpreemptiblecapacity_topic-Using_the_Console">documentation</a>. Use the Kubernetes Labels section of the Nodepool UI to provide the custom kubernetes labels.</p><p>Nodepool-1</p><ul><li>Name: on-demand-corepool</li><li>Shape: VM.Standard.E3.Flex, 1 OCPU, 16 GB</li><li>Capacity Type: On-demand</li><li>Kubernetes Labels: Default</li><li>Size: 2</li></ul><p>Nodepool-2</p><ul><li>Name: on-demand-e3</li><li>Shape: VM.Standard.E3.Flex, 1 OCPU, 16GB</li><li>Capacity Type: On-demand</li><li>Kubernetes Labels: capacity: on-demand</li><li>Size: 0</li></ul><p>Nodepool-3</p><ul><li>Name: on-demand-e4</li><li>Shape: VM.Standard.E4.Flex, 1OCPU, 16GB</li><li>Capacity Type: On-demand</li><li>Kubernetes Labels: capacity: on-demand</li><li>Size: 0</li></ul><p>Nodepool-4</p><ul><li>Name: preemptible-e3</li><li>Shape: VM.Standard.E3.Flex, 1 OCPU, 16GB</li><li>Capacity Type: Preemptible</li><li>Kubernetes Labels: capacity: preemptible</li><li>Size: 0</li></ul><p><strong>2. Setup the Priority Expander Config Map for the node pools</strong></p><p>Priority based expander selects an expansion option based on priorities (positive numeric values) assigned by a user to scaling groups. The priority assignment is based on matching of the scaling group name to regular expressions. Please note that the scaling group name is equivalent the OCID of the Nodepool in OKE. This priority configuration is provided using a configmap.</p><p>For more information on this configuration, please refer the <a href="https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/expander/priority/readme.md">documentation</a>.</p><p>Create a ConfigMap named cluster-autoscaler-priority-expander in kube-system namespace by using the following yaml.</p><pre>apiVersion: v1<br>kind: ConfigMap<br>metadata:<br>  name: cluster-autoscaler-priority-expander<br>  namespace: kube-system  <br>data:<br># Use the regex patterns which match the Nodepool OCID<br>  priorities: |-<br>    40: <br>      - .*xyzabc* <br>    30: <br>      - .*zzzzz*<br>    20: <br>      - .*yyyyyy*<br><br></pre><p>Make sure that you update the regex patterns with OCID of the Nodepools created in section 1 which are Nodepool-2, Nodepool-3 and Nodepool-4. Please note that we are not going make the Nodepool-1 a part of the auto scaling group. So, we are omitting the entry for this Nodepool in the config map. The priority order we are going to use will be as mentioned below.</p><ul><li>preemptible-e3 — 40</li><li>on-demand-e3 — 30</li><li>on-demand-e4 — 20</li></ul><p>Based on the above order, the expander will try to pick the preemptible nodepool during the scaling operation and falling back to on-demand nodepools in case preemptible nodepool cannot be expanded.</p><p><strong>3. Deploy the Cluster Autoscaler in OKE with required configurations</strong></p><p>For deploying the Cluster Autoscaler in OKE, you have 2 options.</p><ul><li><a href="https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengusingclusterautoscaler_topic-Working_with_the_Cluster_Autoscaler.htm">Deploying as a standalone program using the yaml file</a></li><li><a href="https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengusingclusterautoscaler_topic-Working_with_Cluster_Autoscaler_as_Cluster_Add-on.htm">Enabling the Cluster Autoscaler add-on</a></li></ul><p>Either way, make sure the following arguments are passed for the Cluster Autoscaler deployment. Please note that certain timeout parameters are kept intentionally low for a quick validation of the scale up/scale down operations. Also make sure that you are updating the actual OCIDs of the 3 nodepools created in section 1.</p><pre>         command:<br>            - ./cluster-autoscaler<br>            - --v=4<br>            - --stderrthreshold=info<br>            - --cloud-provider=oci<br>            - --max-node-provision-time=25m<br>            - --nodes=0:2:ocid1.nodepool.oc1.xxxx<br>            - --nodes=0:2:ocid1.nodepool.oc1.xxxx<br>            - --nodes=0:2:ocid1.nodepool.oc1.xxxx<br>            - --scale-down-delay-after-add=1m<br>            - --scale-down-unneeded-time=1m<br>            - --unremovable-node-recheck-timeout=5m<br>            - --balance-similar-node-groups=false<br>            - --scale-down-enabled=true<br>            - --estimator=binpacking<br>            - --expander=priority            <br>            - --skip-nodes-with-custom-controller-pods=true            <br>            - --skip-nodes-with-system-pods=true <br>            - --skip-nodes-with-local-storage=true           <br>            - --enforce-node-group-min-size=false<br>            - --min-replica-count=0</pre><p>Also, add the below nodeSelector segment to the deployment.</p><pre>      nodeSelector:<br>        name: on-demand-corepool</pre><p>This is to make sure that the cluster autoscaler will always run in the nodepool <strong>on-demand-corepool </strong>which is not part of the autoscaling. It’s always recommended to keep the Cluster Autoscaler deployment in a nodepool which is not managed by the Autoscaler.</p><p>After the deployment, ensure that the Cluster Autoscaler pod is up and running.</p><pre>$ kubectl get po -n kube-system | grep cluster-autoscaler<br>cluster-autoscaler-6d58cd9c7-qf5gh    1/1     Running   0             29h</pre><p><strong>4. Deploy sample NGINX deployment</strong></p><p>Use the below yaml to deploy the NGINX into the current OKE cluster.</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: nginx-deployment<br>spec:<br>  selector:<br>    matchLabels:<br>      app: nginx<br>  replicas: 2<br>  template:<br>    metadata:<br>      labels:<br>        app: nginx<br>    spec:<br>      tolerations:<br>      - key: &quot;oci.oraclecloud.com/oke-is-preemptible&quot;<br>        operator: &quot;Exists&quot;<br>        effect: &quot;NoSchedule&quot;    <br>      affinity:<br>        nodeAffinity:<br>          requiredDuringSchedulingIgnoredDuringExecution:<br>            nodeSelectorTerms:<br>            - matchExpressions:<br>              - key: capacity<br>                operator: Exists<br>      containers:<br>      - name: nginx<br>        image: nginx:latest<br>        ports:<br>        - containerPort: 80<br>        resources:<br>          requests:<br>            memory: &quot;500Mi&quot;</pre><p>Please pay attention to the below configurations of the deployment</p><ul><li>To ensure that the deployment can be placed on the preemptible node, the below toleration is added</li></ul><pre>tolerations:<br>      - key: &quot;oci.oraclecloud.com/oke-is-preemptible&quot;<br>        operator: &quot;Exists&quot;<br>        effect: &quot;NoSchedule&quot;</pre><ul><li>To ensure that the deployment can be placed only on the nodepools which are part of the autoscaling group, the below nodeAffinity configuration is added</li></ul><pre>affinity:<br>        nodeAffinity:<br>          requiredDuringSchedulingIgnoredDuringExecution:<br>            nodeSelectorTerms:<br>            - matchExpressions:<br>              - key: capacity<br>                operator: Exists</pre><p>As you might have noticed, only <strong>on-demand-corepool </strong>has worker nodes available and remaining all the nodepools are empty. When we create the NGINX deployment using the above yaml, the pods will go into pending state as they can’t be scheduled on the available nodes due to the nodeAffinity configuration.</p><pre>$ kubectl get pods | grep nginx<br>nginx-deployment-768c576964-9zwfd   0/1     Pending   0          5s<br>nginx-deployment-768c576964-kmmdr   0/1     Pending   0          5s</pre><p><strong>5. Observe and validate the scaling operation</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ArPlbTiSaXPJ22EXkZ0mDw.jpeg" /></figure><p>As the nodeAffinity of NGINX deployment is only checking whether the label with a key <strong>size</strong> exists, all the 3 empty nodepools are eligible for scaling as all of them have this label <strong>capacity</strong> defined on them. In section 3, we passed the parameter <em>— expander=priority </em>during Cluster Autoscaler deployment along with the configmap containing the priorities for all the nodepools.</p><p>As per the configmap we defined, it’s expected that the nodepool <strong>preemptible-e3 </strong>will be selected for scale up operation. You can notice that the scale up operation getting triggered within a minute and the nginx-deployment pods will go to running state. You can validate that these pods are placed on the new node created in the <strong>preemptible-e3</strong> nodepool.</p><p>If you notice the logs of the cluster-autoscaler pod logs, you can notice some information about which nodepool being selected for the scale up operation. You can also confirm that the OCID printed in these log messages is of the preemptible-e3 nodepool.</p><pre>I0927 16:47:34.255023       1 priority.go:114] Successfully loaded priority configuration from configmap.<br>I0927 16:47:34.255138       1 priority.go:163] priority expander: ocid1.nodepool.oc1.xxxxxxxxx chosen as the highest available</pre><p>If the preemptible nodepool cannot be scaled up due to some technical constraints/capacity issues or it’s excluded from scale up operation because of k8s validation criteria, on-demand-small nodepool will be selected as the next option due to the priority order. We can simulate the k8s validation criteria scenario by updating the nodeAffinity as shown below as it’s not easy to simulate the capacity issues for preemptible nodepools.</p><pre>affinity:<br>        nodeAffinity:<br>          requiredDuringSchedulingIgnoredDuringExecution:<br>            nodeSelectorTerms:<br>            - matchExpressions:<br>              - key: capacity<br>                operator: In<br>                - on-demand</pre><p>With the above change, the Cluster Autoscaler will pick on-demand-e3 nodepool as preemptible-e3 will be excluded due to nodeAffinity criteria which is checking capacity label to be of the value <strong>on-demand.</strong></p><p>That concludes my demonstration where we are able to successfully use the preemptible nodes as the first option during our scale up operation. Hope this article proved helpful in understanding the Cluster Autoscaler expanders, Preemptible Instance Usage in OKE and cost optimization strategy by combining both these options.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a68c7990347" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Istio for handling HTTP & HTTP/2(GRPC) Traffic in OKE]]></title>
            <link>https://medium.com/@subhashchandra.b/using-istio-for-handling-http-http-2-grpc-traffic-in-oke-6999ca150853?source=rss-f122f3be6873------2</link>
            <guid isPermaLink="false">https://medium.com/p/6999ca150853</guid>
            <category><![CDATA[grpc]]></category>
            <category><![CDATA[http2]]></category>
            <category><![CDATA[oracle-cloud]]></category>
            <category><![CDATA[istio-ingress]]></category>
            <category><![CDATA[istio]]></category>
            <dc:creator><![CDATA[Subhash Chandra Budde]]></dc:creator>
            <pubDate>Wed, 11 Sep 2024 07:08:14 GMT</pubDate>
            <atom:updated>2024-09-11T09:20:09.491Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://istio.io/">Istio</a> 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. The Istio Ingress Gateway is a component of the Istio service mesh that provides ingress traffic management for applications.</p><p>Istio is capable of routing the HTTP and HTTP/2 traffic without any additional configurations specific to the protocol. This is what the <a href="https://istio.io/latest/docs/ops/configuration/traffic-management/protocol-selection/">Istio official documentation</a> mentions about the protocol handling during traffic management.</p><blockquote>Istio supports proxying any TCP traffic. This includes HTTP, HTTPS, gRPC, as well as raw TCP protocols. In order to provide additional capabilities, such as routing and rich metrics, the protocol must be determined. This can be done automatically or explicitly specified.</blockquote><p>In this article, I’ll demonstrate how we can use this capability of Istio to route the traffic to 2 different backend services out of which one is based on HTTP and the other one on HTTP/2. For this exercise, we are going to use the managed Kubernetes service of <a href="https://www.oracle.com/cloud/">Oracle Cloud Infrastructure</a> popularly known as <a href="https://www.oracle.com/cloud/cloud-native/kubernetes-engine/">OKE</a>.</p><p>Before running the steps in this article, you must have a valid OKE cluster setup and running in OCI with appropriate permissions to create the required resources like Load Balancer. For creating the OKE cluster through console, you can refer the public documentation for <a href="https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengcreatingclusterusingoke_topic-Using_the_Console_to_create_a_Quick_Cluster_with_Default_Settings.htm#create-quick-cluster">Quick Create flow</a>. Alternatively, you can also refer the <a href="https://docs.oracle.com/en-us/iaas/developer-tutorials/tutorials/tf-cluster/01-summary.htm">terraform way</a> of creating the OKE cluster.</p><p>I’ll demonstrate the following operations.</p><ol><li>Create the hello-world GRPC container</li><li>Enable and validate the Istio add-on on OKE cluster</li><li>Deploy the HTTP and HTTP/2 based micro services into OKE cluster</li><li>Invoke the services and validate the flow</li><li><strong>Create the hello-world GRPC container</strong></li></ol><p>The source code used in this demonstration is available at <a href="https://github.com/subhashchandrab/grpc-python-helloworld">Github</a> and we are going to start by cloning the same and doing the required modifications if any.</p><p>Login to the Oracle Cloud console and open the <a href="https://docs.oracle.com/en-us/iaas/Content/API/Concepts/cloudshellintro.htm">cloud shell</a>. Execute the below shell commands which will create the docker image for hello-world grpc service based in python.</p><pre>git clone https://github.com/subhashchandrab/grpc-python-helloworld<br>cd grpc-python-helloworld<br>docker build --platform=linux/amd64 -t grpc-helloworld-py .<br></pre><p>In the next step, we are going to push the above image into Oracle Cloud Infrastructure Registry also known <a href="https://docs.oracle.com/en-us/iaas/Content/Registry/Concepts/registryoverview.htm">OCIR</a>. The prerequisites for this step will be to create the repository and use the same here. You can follow the steps mentioned in <a href="https://docs.oracle.com/en-us/iaas/Content/Registry/Tasks/registrycreatingarepository.htm">documentation</a> for creating OCIR repository. More information on docker login credentials and the applying image tags can be referred <a href="https://docs.oracle.com/en-us/iaas/Content/Registry/Tasks/registrypushingimagesusingthedockercli.htm#Pushing_Images_Using_the_Docker_CLI">here</a>. Please make sure you replace the repository name, tenancy namespace and region code according to your environment in the below commands. Once you complete these steps succesfully, a new image for the helloworld-grpc service will be available in the respective OCIR repository. This image will be referred in the step 3 when we deploy the services to OKE.</p><pre>docker login &lt;region-code&gt;.ocir.io --username=&lt;oci-tenancy&gt;/&lt;oci-login&gt; --password=&lt;auth-token&gt;<br>docker tag grpc-helloworld-py &lt;region-code&gt;.ocir.io/&lt;tenancy-namespace&gt;/&lt;repo-name&gt;/grpc-helloworld-py:latest<br>docker push &lt;region-code&gt;.ocir.io/&lt;tenancy-namespace&gt;/&lt;repo-name&gt;/grpc-helloworld-py:latest</pre><p>2. <strong>Enable and validate the Istio add-on on OKE cluster</strong></p><p>Log in to the OCI cloud console and navigate to the homepage of the OKE cluster which you have created. Make sure you have created an enhanced OKE cluster to perform the steps related to add-on configuration here. Click on Add-ons link under resources page and click Manage add-ons button. This will open up a new dialog and you can select the Istio there which will show the configuration options related Istio add-on. Check the checkbox Enable Istio and configure the option enableIngressGateway as true as shown in the image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*jIcI4XFImCzo8kwjoEFHHA.png" /></figure><p>Once you click on Save Changes, Istio will be deployed in the OKE cluster along with a public load balancer. You can validate the same as mentioned below</p><p>There will be 2 deployments under istio-system name space named istiod and istio-ingressgateway. Similarly, there will be 2 services with the same name in istio-system namespace. Ensure that the EXTERNAL_IP is populated for the service istio-ingressgateway and all the pods are up and running under istio-system namespace.</p><p><strong>3. Deploy the HTTP and HTTP/2 based micro services into OKE cluster</strong></p><p>Grab the public IP of the load balancer created in step 2 and update it against the domain grpc-https.istio-example.com in your /etc/hosts file.</p><pre>##<br># Host Database<br>#<br># localhost is used to configure the loopback interface<br># when the system is booting.  Do not change this entry.<br>##<br>127.0.0.1 localhost<br>255.255.255.255 broadcasthost<br>::1             localhost<br># Update the public load balancer IP here<br>xxx.xx.xx.xx   grpc-https.istio-example.com </pre><p>Optionally you can use the real DNS entries and domain names and external CA certificates if available for you.</p><p>In the next step, we will create a self signed wild card certificate generated for the domain *.istio-example.com which will be used for SSL termination at the Istio ingress gateway. Ensure that you are under the top level directory of cloned repository as mentioned in step 1 and execute the below steps. Once you execute these steps, there will be a <a href="https://kubernetes.io/docs/reference/kubectl/generated/kubectl_create/kubectl_create_secret_tls/">tls</a> type of kubernetes secret created with a name istio-example-credential in the istio-system namespace.</p><pre>cd k8s<br>./wilcard-cert-setup.sh</pre><p>Now, we can deploy both HTTP and HTTP/2 based microservices into the cluster. For HTTP service, we are going to use the popular nginx docker image. For HTTP/2 service, we are going to use the GRPC hello-world image created in step 1. From k8s folder, execute the below command. This will create a Deployment, Service, <a href="https://istio.io/latest/docs/reference/config/networking/virtual-service/">VirtualService</a> for each micro-service. It will also create a <a href="https://istio.io/latest/docs/tasks/traffic-management/ingress/secure-ingress/">Istio Gateway along with TLS configuration</a>. Please refer to the respective yaml files in the folder k8s to check the details of each artifact.</p><pre>kubectl apply -f .</pre><p>4. <strong>Invoke the services and validate the flow</strong></p><p>Please pay attention to the Istio gateway definition present in https-gateway.yaml under k8s folder.</p><pre>apiVersion: networking.istio.io/v1alpha3<br>kind: Gateway<br>metadata:<br>  name: https-gateway<br>spec:<br>  selector:<br>    istio: ingressgateway # use istio default ingress gateway<br>  servers:<br>  - port:<br>      number: 8443<br>      name: https<br>      protocol: https<br>    tls:<br>      mode: SIMPLE<br>      credentialName: istio-example-credential # must be the same as secret<br>    hosts:<br>    - &quot;*&quot;</pre><p>The traffic from client application will be TLS over TCP and comes till the Istio ingress gateway in encrypted format. Istio Gateway will terminate the TLS and initiate the HTTP or HTTP/2 calls to the respective backend services based on the URI patterns defined in the corresponding VirtualService definitions.</p><p>As you can notice from the Gateway yaml above, we are mentioning the protocol as https in the gateway along with the secret created in the istio-system namespace. By using the tls.mode as SIMPLE, the Gateway will terminate the TLS at this level and the traffic towards the backend services from here will be unencrypted. Istio is capable of detecting the HTTP or HTTP/2 traffic automatically as explained in the beginning.</p><p>The virtual service definitions are based on the URI pattern matching. As you can notice from the corresponding yaml files, any URI having /Greeter/SayHello will be redirected to the GRPC backend(helloworld grpc based on python) and any URI having /nginx will be redirected to the the HTTP backend(nginx).</p><p>This flow is depicted in the diagram below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BNPGhmikf4eE_4kDBSjSqw.jpeg" /></figure><p>You need the <a href="https://github.com/fullstorydev/grpcurl">grpcurl</a> utility for invoking any GRPC endpoint. Alternatively, you can also test the same using the <a href="https://learning.postman.com/docs/sending-requests/grpc/grpc-request-interface/">Postman</a>. Either way, you need the hello_world.proto file present under protobufs folder of the cloned repository root directory to invoke the GRPC endpoints. You can use the below command from cloned repository root folder (grpc-python-helloworld) to invoke the GRPC backend. It will give the response which contains the name passed in the parameters of the request along with name of the pod as shown below.</p><pre>grpcurl --cacert k8s/example_certs1/istio-ca.crt -import-path protobufs/ -proto hello_world.proto  -d &#39;{&quot;name&quot;: &quot;Jack&quot;}&#39; grpc-https.istio-example.com:443 Greeter/SayHello<br>{<br>  &quot;message&quot;: &quot;Hello Jack from grpc pod grpc-helloworld-py-b6f9585f-njtks!&quot;<br>}</pre><p>Similarly, you can invoke the HTTP endpoint using curl as shown below. It will give the default html response of nginx pod.</p><pre>curl --cacert k8s/example_certs1/istio-ca.crt https://grpc-https.istio-example.com/nginx<br>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>&lt;title&gt;Welcome to nginx!&lt;/title&gt;<br>&lt;style&gt;<br>html { color-scheme: light dark; }<br>body { width: 35em; margin: 0 auto;<br>font-family: Tahoma, Verdana, Arial, sans-serif; }<br>&lt;/style&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>&lt;h1&gt;Welcome to nginx!&lt;/h1&gt;<br>&lt;p&gt;If you see this page, the nginx web server is successfully installed and<br>working. Further configuration is required.&lt;/p&gt;<br><br>&lt;p&gt;For online documentation and support please refer to<br>&lt;a href=&quot;http://nginx.org/&quot;&gt;nginx.org&lt;/a&gt;.&lt;br/&gt;<br>Commercial support is available at<br>&lt;a href=&quot;http://nginx.com/&quot;&gt;nginx.com&lt;/a&gt;.&lt;/p&gt;<br><br>&lt;p&gt;&lt;em&gt;Thank you for using nginx.&lt;/em&gt;&lt;/p&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>That concludes my demonstration where you are able to complete the following tasks.</p><ul><li>Create a hello-world grpc docker image and push it to OCIR</li><li>Enable the Istio add-on on OKE cluster</li><li>Created the self signed certificates and mapped the LB to the domain locally using /etc/hosts</li><li>Deploy 2 microservices for handling HTTP and HTTP/2 requests</li><li>Invoked the nginx endpoint using HTTP and grpc-helloworld endpoint using HTTP/2 successfully.</li></ul><p>I hope this article proved helpful in understanding the Istio gateway ingress concepts along with relevant services on OCI to handle the HTTP and HTTP/2 traffic. Thank you for your time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6999ca150853" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>