<?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 Abeer Alotaibi on Medium]]></title>
        <description><![CDATA[Stories by Abeer Alotaibi on Medium]]></description>
        <link>https://medium.com/@abeerm171?source=rss-d75cd061a0d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*FkLqLO6zt_vRFk3iD57GUg@2x.jpeg</url>
            <title>Stories by Abeer Alotaibi on Medium</title>
            <link>https://medium.com/@abeerm171?source=rss-d75cd061a0d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 20:09:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@abeerm171/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[Introduce HashiCorp Vault secrets into Kubernetes via CSI secret store driver]]></title>
            <link>https://abeerm171.medium.com/hashicorp-vault-secrets-into-kubernetes-via-csi-secret-store-driver-e376a1587945?source=rss-d75cd061a0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e376a1587945</guid>
            <category><![CDATA[vault]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Abeer Alotaibi]]></dc:creator>
            <pubDate>Thu, 02 Jun 2022 19:51:39 GMT</pubDate>
            <atom:updated>2022-06-02T21:44:43.115Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, I’ll walk through <strong>Secrets Store CSI Driver</strong> to integrate an external <strong>HashiCorp</strong> <strong>Vault</strong> with kubernetes via a Container Storage Interface <strong>(CSI)</strong> and inject sensitive information that is needed by the application to pods.</p><h4><strong>Prerequisites:</strong></h4><ol><li>vault server<strong> ( v1.9)</strong></li><li>csi-secret-store driver <strong>(v1.1.2)</strong></li><li>vault-provider <strong>(v1.9)</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8iUYj2G5AoxDTaNx8FUk3Q.jpeg" /></figure><p>Let’s get into the practical part! we will use helm-chart for installing all prerequisites as it’s the recommended way by Hashicorp for Vault installation, it’s extremely easy and fast!</p><h3><strong>Run Vault Server:</strong></h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f364092088a72531d7a8924342bdfccc/href">https://medium.com/media/f364092088a72531d7a8924342bdfccc/href</a></iframe><p>The default installation , will install Vault in standalone mode, to make vault highly available you need to set <strong>ha.enabled</strong> to <strong>true</strong> in values.yaml or by passing <strong>-set “server.ha.enabled=true” </strong>to helm install command, and specify the desired number of replicas, default is 3. Please checkout the available configuration <a href="https://www.vaultproject.io/docs/platform/k8s/helm/configuration">here</a> for more.</p><h4><strong>Enable And Configure Kubernetes Authentication Method:</strong></h4><p>To allow Kubernetes cluster to authenticate with Vault , we need to enable auth/kubernetes access method on Vault (Authentication), then create a policy for specifying the access privileges (Authorization), lastly create Vault role to map Kubernetes service account to the access policy, we can consider the role as a bridge that links between the authentication and the authorization.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ca48f70759b03f83406945b5f4033f40/href">https://medium.com/media/ca48f70759b03f83406945b5f4033f40/href</a></iframe><p>By completing above, you have your Vault server ready! Let’s move to Kubernetes cluster side.</p><h3><strong>Deploy CSI Secret Store Driver:</strong></h3><p>As you might already know, there are multiple ways to retrieve and inject secrets from external vault server to kubernetes cluster including:</p><ol><li>Vault-injector.</li><li>Some open-source tools ( good referance: <a href="https://github.com/gites/awesome-vault-tools">GitHub</a>).</li><li>CSI secret store.</li></ol><p>I tried vault-injector at first to inject the secrets as environment variables, however, I found it a bit challenging when it came to exporting the secrets once the file retrieved from the vault. The <strong>Container Storage Interface (CSI) </strong>was the best option for my use case. Essentially, the <strong>CSI</strong> will attach vault secrets to your pod as ephemeral volumes. Once the volume is attached, the data in it is mounted into the container’s file system, and the application will use that data either directly or via Kubernetes secret resource, as I’ll describe in more detail below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1696004188e62b5f405074b058c41773/href">https://medium.com/media/1696004188e62b5f405074b058c41773/href</a></iframe><p>After confirming the csi driver is up and running and vault-provider as a daemonset on every node, You’ll get a new custom resource called <strong>SecretProviderClass</strong> which you’ll use to provide the vault configurations and secret details to the CSI driver.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d505501199a165811a5c321824ba3940/href">https://medium.com/media/d505501199a165811a5c321824ba3940/href</a></iframe><p>I used identical names in <strong>objectName</strong> and <strong>secretKey</strong> parameters for readability purpose on the SecretProviderClass manifest.</p><ul><li><strong>objectName</strong>: defines the secret alias name to be written in mounted secret on your pod.</li><li><strong>secretPath</strong>: The path in Vault server.</li><li><strong>secretKey</strong>: secret key to read from vault .data</li></ul><h3><strong>Inject secrets into your pod:</strong></h3><p>On Kubernetes side, create a ServiceAccount which will be used to authenticate with Vault.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b16b07f2fd01333cc6e5baf4aa3ead52/href">https://medium.com/media/b16b07f2fd01333cc6e5baf4aa3ead52/href</a></iframe><p>The Service Account need to have a permission to TokenReview resource to be used by vault to verify the token of the service account of pod that want to connect to Vault and get secrets. To grant Kubernetes ServiceAccount a permissions on TokenReview, you need to create system:auth-delegator ClusterRoleBinding</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f067ea8825b31eb7fb0d6a1c5f311551/href">https://medium.com/media/f067ea8825b31eb7fb0d6a1c5f311551/href</a></iframe><p>If the service account token of the pod is successfully authenticated, then Vault will generate vault token and return it to the pod.</p><p>Lastly, edit your pod manifist to attach a volume and volume mount to your pod definition and add a secretRef for the secret created by csi driver.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e9eec2ee65b424a75440b5bc70aaca15/href">https://medium.com/media/e9eec2ee65b424a75440b5bc70aaca15/href</a></iframe><p>The csi driver will communicate with vault provider using <a href="https://grpc.io/">gRPC</a> , secretProviderClass specified in the pod’s definition and the pod’s serviceaccount to retrieve the secrets from Vault and mount them into the pod’s CSI volume as well as build a Kubernetes Secret to mirror the mounted content at pod runtime!</p><p>Thanks for reading, I hope you enjoyed it :D</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e376a1587945" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Part 2: Applying Security List to subnets in Oracle Cloud using Terraform]]></title>
            <link>https://abeerm171.medium.com/part-2-applying-security-list-to-subnets-in-oracle-cloud-using-terraform-82bd0c087eac?source=rss-d75cd061a0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/82bd0c087eac</guid>
            <category><![CDATA[oracle-cloud]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[infrastructure-as-code]]></category>
            <dc:creator><![CDATA[Abeer Alotaibi]]></dc:creator>
            <pubDate>Mon, 28 Jun 2021 18:08:37 GMT</pubDate>
            <atom:updated>2025-07-18T06:40:04.712Z</atom:updated>
            <content:encoded><![CDATA[<p>The previous article (<a href="https://ibinsabbar.medium.com/part-1-building-simple-infra-in-oracle-cloud-using-terraform-4dd2dbb96229">Part 1</a>), explained how to build a simple infrastructure in Oracle Cloud using Terraform. In this part 2, I’ll show you how to apply a security lists with ingress and egress rules to specify the types of traffic allowed in and out to your previously created infrastructure.</p><blockquote><strong>Note:</strong> All used modules in this article and the upcoming parts can be found <a href="https://github.com/Binsabbar/oracle-cloud-terraform.">here</a></blockquote><p>As an outcomes of the previous article , you are supposed to have a <strong>VCN</strong> with <strong>2 subnets, </strong>by default each VCN comes with a default security list, So we need to specify a custom security list for our subnet. The full code used in this article can be found <a href="https://gist.github.com/octopus20/aa0d6e35e3888798c3a8420eea10e4a5">here</a></p><h3>Using the security list module</h3><p>Let’s add <strong>security-list</strong> module section to the same main.tf file used in part 1 as the below:</p><pre>module &quot;security_lists&quot; {<br>  source         = &quot;github.com/Binsabbar/oracle-cloud-terraform//modules/security-list?ref=v1.0&quot;<br>  vcn_id         = module.network.vcn.id<br>  compartment_id = var.tenancy_ocid<br>  security_lists = local.security_lists</pre><pre>}</pre><p>The module requires some variables declared in variables.tffile , the module expects below as inputs:</p><ul><li><strong>vcn_id: </strong>virtual cloud network ID.</li><li><strong>compartment_id: </strong>we will use the root compartement ID.</li><li><strong>security_lists: </strong>map of egress and ingress objects that contains rules.</li></ul><pre>variable &quot;vcn_id&quot; { type = string }<br>variable &quot;compartment_id&quot; { type = string }<br>variable &quot;security_lists&quot; {<br>  type = map(object({<br>    egress_rules = map(object({<br>      protocol    = number<br>      ports       = object({ min : number, max : number })<br>      destination = string<br>      optionals   = map(any)<br>    }))<br>    ingress_rules = map(object({<br>      protocol  = number<br>      ports     = object({ min : number, max : number })<br>      source    = string<br>      optionals   = map(any)<br>    }))<br>  }))<br>}</pre><p>using above variables we will create our security-lists and define the rules in security-list.tf</p><pre>locals {<br>  protocols = {<br>    icmp    = 1<br>    tcp     = 6<br>}<br>  security_lists = {<br>    //public subnet security rules<br>    &quot;public_subnets&quot; = {<br>      ingress_rules = {<br>        &quot;lb8081&quot; = {<br>          ports     = { min : 8081, max : 8081 }<br>          source    = &quot;0.0.0.0/0&quot;<br>          protocol  = local.protocols.tcp<br>          optionals = {}<br>        }<br>        &quot;lb8080&quot; = {<br>          ports     = { min : 8080, max : 8080 }<br>          source    = &quot;0.0.0.0/0&quot;<br>          protocol  = local.protocols.tcp<br>          optionals = {}<br>        }<br>      }<br>      egress_rules = {<br>        &quot;lb-http-port&quot; = {<br>          ports       = { min : 8082, max : 8082 }<br>          destination = &quot;192.168.1.0/24&quot;<br>          protocol    = local.protocols.tcp<br>          optionals   = {}<br>        }<br>        &quot;lb-http-redirector-port&quot; = {<br>          ports       = { min : 8083, max : 8083 }<br>          destination = &quot;192.168.1.0/24&quot;<br>          protocol    = local.protocols.tcp<br>          optionals   = {}<br>        }<br>      }<br>    }<br>    // Private Subnet security lists<br>    &quot;private_subnets&quot; = {<br>      ingress_rules = {<br>        &quot;http&quot; = {<br>          ports     = { min : 8082, max : 8082 }<br>          source    = &quot;0.0.0.0/0&quot;<br>          protocol  = local.protocols.tcp<br>          optionals = {}<br>        }<br>        &quot;https&quot; = {<br>          ports     = { min : 1443, max : 1443 }<br>          source    = &quot;0.0.0.0/0&quot;<br>          protocol  = local.protocols.tcp<br>          optionals = {}<br>        }<br>        &quot;http-redictor&quot; = {<br>          ports     = { min : 8083, max : 8083 }<br>          source    = &quot;0.0.0.0/0&quot;<br>          protocol  = local.protocols.tcp<br>          optionals = {}<br>        }<br>      }<br>      egress_rules = {}<br>    }<br>  }<br>}</pre><p>Runterraform init to download the module</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GVOwbnpK8-76bRPYfKBYZw.png" /><figcaption>Download security-list module</figcaption></figure><p>After downloading the module, let’s run terrafom plan to review the execution plan before we apply.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TBAhN2ll6CCYlN3CtaGOaw.png" /><figcaption>two security lists will be added.</figcaption></figure><p>Run terraform apply -auto-approve to apply your security lists to your subnets. Here is a snippet from the terminal output when apply is completed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*asIcDbu1XfGKJJmwXce64g.png" /><figcaption>security-lists applied</figcaption></figure><p>check the security lists from Oracle Cloud console, as you see there are two lists are created <strong>public_subnets</strong> and <strong>private_subnets</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IbNyRyopxtxIlPURQAJFXA.png" /><figcaption>Security lists</figcaption></figure><p>View the ingress/egress rules under the security lists.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tv5NHYLAF--NIel9lIOpYg.png" /><figcaption>ingress rules on private subnet</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j_JK30HACof0OfMQ5Gfenw.png" /><figcaption>egress rules on public subnet</figcaption></figure><p>Lastly, we need to assign the security lists to our previously created subnets, by adding security_list_ids</p><pre>private_subnets = {<br>    &quot;private1&quot; = {<br>      cidr_block        = &quot;192.168.1.0/24&quot;<br><strong>      security_list_ids =[module.security_lists.ids.private_subnets]<br></strong>      optionals         = {}<br>    }<br>  }</pre><pre>public_subnets = {<br>    &quot;public1&quot; = {<br>      cidr_block        = &quot;192.168.2.0/24&quot;<br><strong>      security_list_ids = [module.security_lists.ids.public_subnets]<br></strong>      optionals         = {}<br>    }<br>  }</pre><p>terraform apply -auto-approve will associate our subnets with the desired security lists.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q63ckIeu4xITC1r-wbOSvA.png" /></figure><p>By checking OCI dashbaord you can see that your subnets have security lists associated with it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rNXKNSlC6Lxh9KkfGsrlTg.png" /><figcaption>subnet1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*axpTo2viOoRNcsne9UlNwQ.png" /><figcaption>subnet2</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*3ZZ9EBvz_8Ms9Y30Er3xDA.gif" /></figure><p>ℹ️ Please, come back to check Part 3 of this series with <a href="https://medium.com/u/b564bc8140f4">Mohammed Binsabbar</a>.</p><p>Thank You! 🌸</p><p>Abeer Alotaibi</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82bd0c087eac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automating Cloudflare DNS management with Terraform]]></title>
            <link>https://abeerm171.medium.com/automating-cloudflare-dns-management-with-terraform-54713328b5e1?source=rss-d75cd061a0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/54713328b5e1</guid>
            <category><![CDATA[cloudflare]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[dns]]></category>
            <category><![CDATA[terraform]]></category>
            <dc:creator><![CDATA[Abeer Alotaibi]]></dc:creator>
            <pubDate>Fri, 23 Apr 2021 22:19:30 GMT</pubDate>
            <atom:updated>2025-07-18T06:37:20.733Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2dQ8sf27K01-s9dpt0XBzg.png" /></figure><p>This post is about managing Cloudflare zones and records in a declarative and version-controlled way, as a part of our journey to the infrastructure-as-code practices.</p><p>Terraform has published a verified <a href="https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs">Cloudflare provides</a> in Terraform registry that’s used to interact with most of the resources supported by Cloudflare. I used this provider to automate the process of creating DNS zones and controlling DNS records (create, update and delete).</p><p><strong>Requirements:</strong></p><p><a href="https://learn.hashicorp.com/tutorials/terraform/install-cli">Terraform </a>installed on your machine.</p><ul><li>Terraform module called: <strong>dns_management</strong> includes two Cloudflare resources (DNS zone and records).</li></ul><pre>resource &quot;cloudflare_zone&quot; &quot;dns_zones&quot; {<br>  for_each = var.dns_zones<br><br>  zone = each.key<br>  plan = each.value.plan<br>}<br><br><br>resource &quot;cloudflare_record&quot; &quot;dns_records&quot; {<br>  for_each = var.dns_records<br><br>  zone_id = each.value.zone_id<br>  name    = each.key<br>  value   = each.value.value<br>  type    = each.value.type<br>  ttl     = each.value.ttl<br>  proxied = each.value.proxied<br><br>}</pre><p>Above module requires some variables to be defined in <strong>variables.tf</strong> file as below.</p><pre>variable &quot;dns_records&quot; {<br>  type = map(object({<br>    zone_id = string<br>    value   = string<br>    type    = string<br>    ttl     = number<br>    proxied = string<br><br>  }))<br>  description = &quot;map of DNS records information&quot;<br>}<br><br>variable &quot;dns_zones&quot; {<br>  type = map(object({<br>    plan = string<br>  }))<br>  description = &quot;DNS zone information&quot;<br>}</pre><p>Although it’s simple, the benefit of defining Cloudflare resources as a module is to make is reusable and make the main file where we will add dns records more readable and avoid repating ourselves :D.</p><p>example use of the above module.</p><pre>module &quot;dns_zones&quot; {<br>  source = &quot;./dns_management&quot;<br><br>  dns_zones = {<br>    &quot;example.sa&quot; = {<br>      plan = &quot;free&quot;<br>    }<br>  }<br>  dns_records = {<br>    &quot;terraform.example.sa&quot; = {<br>      zone_id = local.zones_info.example_sa_id<br>      value   = &quot;193.192.70.30&quot;<br>      type    = &quot;A&quot;<br>      ttl     = 1<br>      proxied = false<br>    }</pre><p>by running terraform plan in the above example, it will show that there are 2 resources that will be added to your Cloudflare account .. Changes can be applied by terraform apply .</p><p>Module repo on <a href="https://github.com/octopus20/terraform-cloudflare.git">GitHub</a></p><p>For more details please refer to Cloudflare provider documentations in Terraform registry <a href="https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs">here</a>.</p><p>Cheers,<br>Abeer Alotaibi</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54713328b5e1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Database auto-failover with Heimdall proxy]]></title>
            <link>https://abeerm171.medium.com/database-auto-failover-with-heimdall-proxy-434571a5c68?source=rss-d75cd061a0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/434571a5c68</guid>
            <category><![CDATA[high-availability]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[postgresql]]></category>
            <dc:creator><![CDATA[Abeer Alotaibi]]></dc:creator>
            <pubDate>Sun, 20 Sep 2020 17:47:46 GMT</pubDate>
            <atom:updated>2020-10-14T08:30:56.280Z</atom:updated>
            <content:encoded><![CDATA[<p>We are using PostgreSQL for databases and we trying to design the architecture on high available mode with minimum changes on the application side and better performance on both the application and database sides. As a first step to design PostgreSQL on HA mode I have set up streaming replication (Master-Slaver), but this wasn’t enough, we should consider automating Failover in case of any failure is happened, a primary can become unavailable for a few reasons.</p><p>For example:</p><p>1- The operating system of the primary node can crash or become unresponsive.</p><p>2- The primary node can lose its network connectivity.</p><p>3- The PostgreSQL service in the primary node can crash, stop, or become unavailable unexpectedly.</p><p>4- The PostgreSQL service in the primary node can be stopped intentionally or accidentally.</p><p>Whenever a primary becomes unavailable, a standby does not automatically promote itself to the primary role. A standby continues to serve read-only queries, although the data will be current up to the last Log Sequence Number received from the primary. Any attempt for a write operation will fail. I started searching for Auto-Failover solutions, and I found a lot( PG-pool, pg_auto_failover extension, rempmgr, <strong>Heimdall Data proxy</strong>,<strong> </strong>and some third-party tools require to connect our local cloud to the provider’s cloud), the start was with pg_auto_failover, the flow of DB requests (shown on below diagram) The application runs SQL queries directly against the primary, with the slaver specified as a fallback connection in the application, this need to made some changes on the code level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xXSmZ_fshf8e2rQMyGPS8A.png" /><figcaption>PG_auto_failover</figcaption></figure><p>Therefore, I excluded pg_auto_failover and any tool that will require me to do any change on the application side as we were working on major big changes on our application and it wasn’t the right time to made any extra changes to the code but the DB auto-failover is a must at the same time.</p><p>The reasons why I wanted to avoid application side changes are:</p><p>1- I wanted to save our super developers&#39; efforts to focus on application functionalities refactoring without making any changes to the code related to adding fallback SQL instructions and so on.</p><p>2- After deploying our major change along with DB auto-failover solution the monitoring, troubleshooting, or rollback (either to rollback the application or DB changes)will be easier for us.</p><p>My superhero in this situation was <strong>Heimdall Data Proxy!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*28FsOsCz5VmZcXakxRBSBw.png" /></figure><p>Heimdall Data is a solution that automated database failover and provides the application resiliency necessary for maximum uptime. The key benefit of using Heimdall is NO application or database code changes, scaling out the database tier always requires rewriting the application, not anymore with Heimdall Data! Heimdall is easy to install &amp; configure, I installed it on Ubuntu18.04, and I found that many database types are supported: PostgreSQL, MySQL -Aurora, MariaDB, Greenplum- Oracle, and SQL server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b-OBBOnA8End-71kkx9K9Q.png" /><figcaption>Heimdall Dashboard</figcaption></figure><p>After configuring Heimdall proxy (all from the UI), Heimdall by creating its own scheme on your database will continuously monitor replication and take recovery action when the primary is unavailable. The failover logic can be done via <strong>state change scripting</strong>, in my case, I added a single line on Heimdall statechange-pg.sh scripts for promotion, simply I followed PostgreSQL slave promotion official instructions.</p><pre>promote_cmd = ‘ssh pg-slave &quot;touch /tmp/postgresql.trigger.5432; pg_ctl promote -D /var/lib/postgresql/10/main&quot; &gt; ‘ + logfile</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7Yo53moU7P6diMEmsIWYYw.png" /><figcaption>Heimdall Dashboard</figcaption></figure><p>To test the Auto-fallback with Heimdall , we causes a failure on primary database, after Heimdall detect the primary is not reachable anymore, the state change script is triggered and the slaver promotion is successfully done.</p><p><strong>Note</strong>: If the primary server fails and the standby server becomes the new primary, and then the old primary restarts Heimdall by default will think the old primary is back to serve as primary again, you must have a <strong>STONITH</strong> (Shoot The Other Node In The Head) mechanism for informing the old primary that it is no longer the primary, which is necessary to avoid situations where both systems think they are the primary, which will lead to confusion and ultimately data loss.</p><p>My focus was to find a solution to automate the process of failover on PostgreSQL, but I found that Heimdall could increase the overall performance of the application by providing:</p><ul><li>Automated caching.</li><li>Automated DB failover.</li><li>Read-Write split.</li><li>Connection pooling.</li><li>Query analysis.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=434571a5c68" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automate ELK installation and configuration with Ansible]]></title>
            <link>https://abeerm171.medium.com/automate-elk-installation-and-configuration-with-ansible-3e2cb785aef8?source=rss-d75cd061a0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e2cb785aef8</guid>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[ansible]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <dc:creator><![CDATA[Abeer Alotaibi]]></dc:creator>
            <pubDate>Tue, 19 May 2020 01:38:01 GMT</pubDate>
            <atom:updated>2021-04-23T22:42:51.742Z</atom:updated>
            <content:encoded><![CDATA[<p>Automate ELK installation and configuration with Ansible</p><p>This post describes how to use Ansible roles I put together to set up ELK (V. 7.x) on a remote server. It will take you through the steps for preparing all needed Ansible roles, playing the playbook, and extra JVM configuration that might be needed for your ELK.</p><p>Note: The installation and configuration of the stack are broken into multiple roles to simplify the steps and make it reusable. This is made for Ubuntu Server and executed on Ubuntu Server 18.04 with 4 CPU cores and 8GB of RAM — The specs of the machine are entirely up to the situation and the volume of data.</p><h3>Roles Overview</h3><p>The roles follow the classic Ansible structure:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*7dMGIiMU_pcSVmZ3Lm5v0g.png" /><figcaption>Ansible roles</figcaption></figure><p><strong>1- pre-requisites:</strong> For installing needed packages before installing elasticsearch.</p><pre>- name: Install Packages<br>  apt: name= state=latest update_cache=yes<br>  with_items:<br>    - apt-transport-https<br>    - openssl<br>    - default-jdk</pre><p><strong>2- configure-hosts-file:</strong> Update the /etc/hosts in your ELK nodes from ansible inventory. ( Because we will use names in elasticsearch.yml)</p><pre>---<br># group name es-cluster<br>- name: Update the /etc/hosts file with node name<br>  become: yes<br>  lineinfile:<br>    dest: &quot;/etc/hosts&quot;<br>    regexp: &#39;.*{{ item }}$&#39;<br>    line: &quot;{{ hostvars[item].ansible_host }} {{item}}&quot;<br>    state: present<br>  when: hostvars[item].ansible_host is defined<br>  with_items: &quot;{{groups[&#39;es-cluster&#39;]}}&quot;</pre><p><strong>3- install-elasticsearch:</strong></p><p>The install-elasticsearch role sets up the apt repo, installs elasticsearch. If you would like to change the version of ELK to install, edit the repo URL.</p><blockquote>repo: deb <a href="https://artifacts.elastic.co/packages/7.x/apt">https://artifacts.elastic.co/packages/7.x/apt</a> stable main</blockquote><pre>---<br>- name: Import the Elastic Key<br>  apt_key:<br>    url: <a href="https://artifacts.elastic.co/GPG-KEY-elasticsearch">https://artifacts.elastic.co/GPG-KEY-elasticsearch</a><br>    state: present</pre><pre>- name: Adding Elastic APT repository<br>  apt_repository:<br>    repo: deb <a href="https://artifacts.elastic.co/packages/7.x/apt">https://artifacts.elastic.co/packages/7.x/apt</a> stable main<br>    state: present<br>    filename: elastic-7.x.list<br>    update_cache: yes</pre><pre>- name: install elasticsearch<br>  apt:<br>    name: elasticsearch<br>    state: present<br>    update_cache: yes</pre><pre>- name: reload systemd config<br>  systemd: daemon_reload=yes</pre><pre>- name: enable service elasticsearch and ensure it is not masked<br>  systemd:<br>    name: elasticsearch<br>    enabled: yes<br>    masked: no</pre><pre>- name: ensure elasticsearch is running<br>  systemd: state=started name=elasticsearch</pre><p><strong>4- configure-elastic-file:</strong> In my case, I prepared an elasticsearch.yml file then copy it to all elastic nodes to have the same configuration in all.</p><pre>---<br>- name: Configure elasticsearch.yml File<br>  copy:<br>    src: &#39;{{item.src}}&#39;<br>    dest: /etc/elasticsearch/elasticsearch.yml<br>    owner: root<br>    group: elasticsearch<br>  with_items:                                                                                                                                                 <br>    - { src: &#39;path/to/your/conf/file.yml&#39;}</pre><p><strong>5- change-permissions:</strong> Set the ownership and permissions for elasticsearch.</p><pre>---<br>- name: set elasticsearch permissions<br>  file:<br>    path: /usr/share/elasticsearch<br>    state: directory<br>    recurse: yes<br>    owner: elasticsearch<br>    group: elasticsearch</pre><p><strong>6- systemd-conf: </strong>configure systems settings — Memory, files limit, and elasticsearch.service unit file.</p><pre>---<br>- name: Add or modify memlock, both soft and hard, limit for elasticsearch user.<br>  pam_limits:<br>    domain: elasticsearch<br>    limit_type: &#39;-&#39;<br>    limit_item: memlock<br>    value: unlimited<br>    comment: unlimited memory lock for elasticsearch</pre><pre>- name: set LimitMEMLOCK to infinity.<br>  lineinfile:<br>    path: /usr/lib/systemd/system/elasticsearch.service<br>    insertafter: &#39;LimitAS=infinity&#39;<br>    line: &#39;LimitMEMLOCK=infinity&#39;<br>    state: present</pre><pre>- name: set vm.max_map_count to 262144 in sysctl<br>  sysctl: name={{ item.key }} value={{ item.value }}<br>  with_items:<br>    - { key: &quot;vm.max_map_count&quot;, value: &quot;262144&quot; }</pre><pre>- name: For a permanent setting, update vm.max_map_count in /etc/sysctl.conf<br>  command: sysctl -p /etc/sysctl.conf</pre><p><strong>7- restart-elasticsearch: </strong>finally, restart elasticsearch to take effect of the above changes.</p><pre>---</pre><pre>- name: restart elasticsearch after change configuration by configure-elastic-file role<br>  systemd:<br>    state: restarted<br>    daemon_reload: yes<br>    name: elasticsearch</pre><pre>- name: ensure elasticsearch is running<br>  systemd:<br>    state=started<br>    name=elasticsearch</pre><p><strong>By the above 7 roles, you have your Elasticsearch well installed and configured.</strong></p><p><strong>8- jvm-options:</strong> This is an additional role if you need to reconfigure the jvm.options file for your elasticsearch. (Default is 1g)</p><pre>- name: Set min JVM Heap size.<br>  lineinfile:<br>    dest: /etc/elasticsearch/jvm.options<br>    regexp: &quot;^-Xms&quot;<br>    line: &quot;-Xms{{ elasticsearch_jvm_xms }}&quot;<br>  tags:<br>    - config</pre><pre>- name: Set max JVM Heap size.<br>  lineinfile:<br>    dest: /etc/elasticsearch/jvm.options<br>    regexp: &quot;^-Xmx&quot;<br>    line: &quot;-Xmx{{ elasticsearch_jvm_xmx }}&quot;</pre><blockquote>Variables can be passed by <em>--extra-vars</em> .</blockquote><p><strong>9- Kibana: </strong>Simply to install, enable, and configure kibana service.</p><pre>---</pre><pre># Important: If you plan to install Kibana on already installed elasticsearch node, you will start from the third task.<br># if not, and you will install Kibana on clean instance, please start from first and second tasks.</pre><pre>- name: Import the Elastic Key<br>  apt_key:<br>    url: <a href="https://artifacts.elastic.co/GPG-KEY-elasticsearch">https://artifacts.elastic.co/GPG-KEY-elasticsearch</a><br>    state: present</pre><pre>- name: Adding Kibana APT repository<br>  apt_repository:<br>    repo: deb <a href="https://artifacts.elastic.co/packages/7.x/apt">https://artifacts.elastic.co/packages/7.x/apt</a> stable main<br>    state: present<br>    filename: kibana-7.x.list<br>    update_cache: yes</pre><pre># Install Kibana<br>- name: Update repositories cache and install Kibana<br>  apt:<br>    name: kibana<br>    update_cache: yes</pre><pre># Configure kibana.yml<br>- name: Configure kibana.yml File<br>  copy:<br>    src: /path/to/your/conf/kibana.yml<br>    dest: /etc/kibana/kibana.yml</pre><pre># Enable Kibana service<br>- name: Enabling Kibana service<br>  systemd:<br>    name: kibana<br>    enabled: yes<br>    daemon_reload: yes</pre><pre># Start Kibana service<br>- name: Starting Kibana service<br>  systemd:<br>    name: kibana<br>    state: started</pre><pre>- name: Ensure Kibana is running<br>  systemd: state=started name=kibana</pre><p><strong>10- logstash:</strong> install, configure logstash.yml, and logstash pipeline.</p><pre>---<br># Important: If you plan to install logstash on already installed elasticsearch node, you will start from the second task. Add Logstash APT repository<br># if not, and you will install Logstash on clean instance, please start from first task.</pre><pre>- name: Adding APT repository<br> apt_repository:<br>   repo: deb  <a href="https://artifacts.elastic.co/packages/7.x/apt">https://artifacts.elastic.co/packages/7.x/apt</a>  stable main<br>   state: present</pre><pre># Installing Logstash<br>- name: Update repositories cache and install Logstash<br>  apt:<br>   name: logstash<br>   update_cache: yes</pre><pre>#--------------------------<br>## LOGSTASH CONFIGURATION--<br>#--------------------------</pre><pre># Configure logstash.yml, if you have specific confg to be used.<br>- name: Configure logstash.yml File<br>  copy:<br>    src: /path/to/your/logstash.yml<br>    dest: /etc/logstash/logstash.yml</pre><pre># Configure Logstash filter.conf config file<br>- name: Configure  Filter<br>  template:<br>    src=filter.conf.j2<br>    dest=/etc/logstash/conf.d/filter.conf<br>    owner=root<br>    group=root<br>    mode=0644</pre><pre># Configure Beats or any (input source) for logstash pipeline<br>- name: Configure input source<br>  template:<br>    src=input.conf.j2<br>    dest=/etc/logstash/conf.d/input.conf<br>    owner=root<br>    group=root<br>    mode=0644</pre><pre># Configure output source for logstash pipeline<br>- name: Configure output source<br>  template:<br>    src=output.conf.j2<br>    dest=/etc/logstash/conf.d/output.conf<br>    owner=root<br>    group=root<br>    mode=0644</pre><pre># Enable Logstash service<br>- name: Enable Logstash service<br>  systemd:<br>    name: logstash<br>    enabled: yes</pre><pre># Start Logstash service<br>- name: Start Logstash service<br>  systemd:<br>    name: logstash<br>    state: started<br>    daemon_reload: yes</pre><h3>ELK Playbook</h3><p>Below is the full Ansible playbook that uses all the above roles for setting up the stack.</p><pre>- name: setup prerequisites<br>  hosts: elk-hosts<br>  become: true<br>  roles:<br>    - pre-requisites<br>    - configure-hosts-file</pre><pre>- name: install elasticsearch<br>  hosts: elk-hosts<br>  serial: 1<br>  become: true<br>  roles:<br>    - install-elasticsearch<br>- name: configure elasticsearch<br>  hosts: elk-hosts<br>  serial: 1<br>  become: true<br>  roles:<br>    - configure-elastic-file<br>    - change-permissions<br>    - systemd-conf<br>    - restart-elasticsearch</pre><pre>- name: Install Kibana<br>  hosts: kibana-host<br>  become: true<br>  roles:<br>    - kibana</pre><pre>- name: Install logstash<br>  hosts: logstash-host<br>  become: true<br>  roles:<br>    - logstash</pre><h3>Verify the cluster status:</h3><pre>curl -XGET ‘http://localhost:9200/_cluster/state?pretty&#39;</pre><p>I use this playbook to keep up to date with and use, the newest features in Elasticsearch, Logstash, Kibana. you can have the stack installed and working in one command. Elasticsearch has many configuration options that weren’t covered here. It is recommended that you review your configuration later, along with the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html">official documentation</a>, to ensure that your cluster is configured to meet your needs.</p><p>Feedbacks are welcome!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e2cb785aef8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>