<?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 Ibrarullah on Medium]]></title>
        <description><![CDATA[Stories by Ibrarullah on Medium]]></description>
        <link>https://medium.com/@ibrarullah204?source=rss-98a324318d64------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*6er2VkgvyyASQNcW</url>
            <title>Stories by Ibrarullah on Medium</title>
            <link>https://medium.com/@ibrarullah204?source=rss-98a324318d64------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 14:01:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ibrarullah204/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[OpenBao in Production: How I Store, Sync and Rotate Kubernetes Secrets]]></title>
            <link>https://medium.com/@ibrarullah204/openbao-in-production-how-i-store-sync-and-rotate-kubernetes-secrets-734ee7346441?source=rss-98a324318d64------2</link>
            <guid isPermaLink="false">https://medium.com/p/734ee7346441</guid>
            <dc:creator><![CDATA[Ibrarullah]]></dc:creator>
            <pubDate>Thu, 03 Dec 2026 07:48:59 GMT</pubDate>
            <atom:updated>2026-12-03T07:48:59.223Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A practical walkthrough of OpenBao, External Secrets Operator and Argo CD, from the basics to the production lessons I learned the hard way.</em></p><p>Every team running on Kubernetes hits the same question sooner or later: <strong>where do the passwords go?</strong></p><p>Database credentials, registry tokens, DNS API keys and storage passwords all have to reach the cluster. With GitOps, everything that reaches the cluster comes from a Git repository. But a secret in Git, even in a private repo, stays in the history forever and is visible to everyone with read access.</p><p>Here’s how I solved this on our production platform with <strong>OpenBao</strong>, the <strong>External Secrets Operator (ESO)</strong> and <strong>Argo CD</strong>. The setup comes down to three jobs: <strong>store, sync and rotate.</strong></p><h3>The short version (for beginners)</h3><p>Think of <strong>OpenBao</strong> as a bank vault for passwords. It’s an open-source, community-driven fork of HashiCorp Vault, maintained under the Linux Foundation.</p><ul><li><strong>Store:</strong> the real secrets live <strong>only in OpenBao</strong>.</li><li><strong>Sync:</strong> Git holds only a <strong>reference</strong> to each secret, such as “the database password is at this path”. A controller in the cluster reads the reference, fetches the value and creates a normal Kubernetes Secret.</li><li><strong>Rotate:</strong> change a value in OpenBao once, and every cluster that uses it picks up the new value.</li></ul><p>Applications use ordinary Kubernetes Secrets and don’t need to know OpenBao exists. The Git repo can be shared, reviewed and audited without leaking a single credential.</p><h3>The architecture</h3><p>We run a <strong>hub and spoke</strong> model:</p><pre>          HUB CLUSTER                         SPOKE CLUSTER (production)<br>  ┌──────────────────────────┐        ┌────────────────────────────────────┐<br>  │  Argo CD  ── deploys ──────────▶  │  ExternalSecret manifests (in Git) │<br>  │                          │        │              │                     │<br>  │  OpenBao (KV v2 secrets) │ ◀────────  External Secrets Operator        │<br>  │                          │  auth  │              │ creates             │<br>  └──────────────────────────┘        │              ▼                     │<br>                                      │  Kubernetes Secret ──▶ Pods        │<br>                                      └────────────────────────────────────┘</pre><ul><li><strong>The hub</strong> runs Argo CD and OpenBao. It’s the single control plane.</li><li><strong>The spoke</strong> (production) runs only the workloads, with no Argo CD and no vault of its own. It runs just ESO.</li><li>Everything the spoke runs is declared in Git and deployed by the hub.</li></ul><p>One OpenBao serves several clusters, and each cluster gets its <strong>own authentication mount and role</strong>. If one cluster is compromised, it can only read its own secrets.</p><h3>1. Store: one place for every secret</h3><p>Secrets live in OpenBao’s <strong>KV v2</strong> engine, which keeps versions, so every change is recorded and can be rolled back. We use a simple path convention:</p><pre>&lt;project&gt;/&lt;scope&gt;/&lt;secret-name&gt;<br>e.g.  platform/prod/postgres-app-user<br>      platform/prod/registry-credentials<br>      platform/prod/dns-api-token</pre><p>The convention keeps policies short (“this cluster may read platform/prod/*&quot;) and makes any secret easy to find.</p><h3>2. Sync: getting secrets into the cluster safely</h3><p>The obvious question: if ESO fetches secrets from OpenBao, how does ESO log in? Did we just move the problem to a new “master password”?</p><p>No. We use <strong>OpenBao’s Kubernetes auth method</strong>:</p><ol><li>ESO presents its Kubernetes <strong>ServiceAccount token</strong> to OpenBao.</li><li>OpenBao checks that token against the cluster’s API server.</li><li>If the ServiceAccount, namespace and audience match a configured <strong>role</strong>, OpenBao returns a short-lived token with a read-only <strong>policy</strong> scoped to that cluster’s paths.</li></ol><p>There’s no static credential to store or leak. <strong>The cluster’s identity is the credential.</strong></p><p>The connection is one ClusterSecretStore:</p><pre>apiVersion: external-secrets.io/v1<br>kind: ClusterSecretStore<br>metadata:<br>  name: openbao-secret-store<br>spec:<br>  provider:<br>    vault:                       # OpenBao is API-compatible with Vault<br>      server: &quot;https://openbao.yourdomain.com&quot;<br>      path: &quot;secret&quot;<br>      version: &quot;v2&quot;<br>      auth:<br>        kubernetes:<br>          mountPath: &quot;kubernetes-prod&quot;   # one auth mount per cluster<br>          role: &quot;eso-role-prod&quot;<br>          serviceAccountRef:<br>            name: external-secrets<br>            namespace: external-secrets</pre><p>Each secret is then declared with an ExternalSecret that contains <strong>nothing sensitive</strong>:</p><pre>apiVersion: external-secrets.io/v1<br>kind: ExternalSecret<br>metadata:<br>  name: app-db-user<br>spec:<br>  refreshInterval: 1h<br>  secretStoreRef:<br>    name: openbao-secret-store<br>    kind: ClusterSecretStore<br>  target:<br>    name: app-db-user<br>    template:<br>      type: kubernetes.io/basic-auth<br>  data:<br>    - secretKey: password<br>      remoteRef:<br>        key: platform/prod/postgres-app-user<br>        property: password</pre><p>Anyone can review that in a pull request. Nobody learns the password.</p><p><strong>What we sync this way in production:</strong></p><ul><li><strong>Database credentials</strong> for our PostgreSQL cluster (CloudNativePG)</li><li><strong>Container registry pull secrets</strong>, created in every production namespace by one ClusterExternalSecret, with ESO templating building the dockerconfigjson from a plain username and password</li><li><strong>The DNS API token</strong> cert-manager uses to issue and renew TLS certificates automatically</li><li><strong>Credentials</strong> for the storage drivers and the observability agent</li></ul><h3>3. Rotate: change once, update everywhere</h3><p>Rotation is where this setup pays off:</p><ol><li>Update the value in OpenBao. KV v2 keeps the previous version.</li><li>ESO picks up the change on its next refresh (we use refreshInterval: 1h) and updates the Kubernetes Secret.</li><li>The workload picks up the new value.</li></ol><p>Step 3 is the one people forget. Some operators handle it for you. On our database secret, a single label tells CloudNativePG to re-apply the password automatically:</p><pre>metadata:<br>  labels:<br>    cnpg.io/reload: &quot;true&quot;</pre><p>Rotate in OpenBao, and the database password changes, with no manual step.</p><p><strong>Plain application pods are different.</strong> A pod that loads config through environment variables (envFrom) reads it <strong>only at startup</strong>. We saw this in production: the config in the cluster was correct, and the pods kept serving old values until we restarted them. For every workload, decide how it reloads:</p><ul><li>operator-native reload, where it exists</li><li>a reloader controller that restarts pods when their Secret changes</li><li>a hash annotation that forces a rollout on every change</li></ul><h3>Lessons from production (for the experts)</h3><p><strong>1. Use sync waves.</strong> The ClusterSecretStore must exist before any ExternalSecret uses it. We put the store in Argo CD sync wave 4 and the secrets in wave 5. Without that, the first sync fails noisily and then fixes itself, which is confusing at 2 a.m.</p><p><strong>2. Scope the blast radius.</strong> One auth mount, role and policy per cluster, with read-only paths under that cluster’s prefix. One hub can serve many clusters without any of them reading another’s secrets.</p><p><strong>3. A synced secret isn’t a reloaded app.</strong> Treat reload as part of every rotation plan, not something to sort out later.</p><p><strong>4. Migrate in stages.</strong> We moved the most sensitive infrastructure credentials first: database, registry, DNS and storage. Moving the remaining application configuration is the next step. Going gradually beat one big migration.</p><h3>Why OpenBao?</h3><ul><li><strong>Open source with community governance</strong> under the Linux Foundation.</li><li><strong>API-compatible with Vault</strong>, so ESO’s vault provider, the CLI habits and the policies carry straight over.</li><li><strong>The features we needed:</strong> KV v2 with versioning, Kubernetes auth, and fine-grained policies.</li></ul><h3>Takeaway</h3><p>GitOps and secrets aren’t at odds:</p><ul><li><strong>Store</strong> values in a vault, not in Git.</li><li><strong>Sync</strong> them using the cluster’s own identity, with no static credentials.</li><li><strong>Rotate</strong> in one place, and plan how each workload reloads.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=734ee7346441" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Recovering a Broken RKE2 Control-Plane Node: etcd Member Lost, Rebuilt and Rejoined]]></title>
            <link>https://medium.com/@ibrarullah204/recovering-a-broken-rke2-control-plane-node-etcd-member-lost-rebuilt-and-rejoined-557eac26ea5f?source=rss-98a324318d64------2</link>
            <guid isPermaLink="false">https://medium.com/p/557eac26ea5f</guid>
            <dc:creator><![CDATA[Ibrarullah]]></dc:creator>
            <pubDate>Thu, 03 Dec 2026 06:53:39 GMT</pubDate>
            <atom:updated>2026-12-03T06:53:39.221Z</atom:updated>
            <content:encoded><![CDATA[<p>One of my three RKE2 control-plane nodes was stuck in NotReady, and its etcd member had silently dropped out of the cluster. I rebuilt the node from scratch and rejoined it in under an hour, without downtime. Here is the exact process, with the commands, so you can do the same.</p><p>The setup: a 3-master RKE2 cluster (Kubernetes v1.35, etcd 3.6) with three workers and one GPU worker. Nothing was down for users, but the cluster was one failure away from losing its control plane. A 3-member etcd cluster that is really running on 2 members has no spare.</p><h3>Step 1: Spot the symptoms</h3><p>It started with a plain node listing:</p><pre>kubectl get nodes -o wide</pre><p>Five nodes were Ready. master3 showed NotReady,SchedulingDisabled. Two details mattered:</p><ul><li><strong>SchedulingDisabled</strong> means the node had been cordoned, so someone had touched it for maintenance.</li><li><strong>Kernel mismatch.</strong> master3 was still on kernel 6.8.0–124 while the other two masters ran 6.8.0–147, and the login banner said <em>System restart required</em>. It had missed a patch cycle.</li></ul><p>The rke2-server service on master3 was reported as active (running). That is the confusing part: the service was up, but the node was not working.</p><h3>Step 2: Read the evidence and find the root cause</h3><p>The node’s conditions came first:</p><pre>kubectl describe node master3 | sed -n &#39;/Conditions:/,/Addresses:/p&#39;</pre><p>Two lines told the story:</p><ul><li>Ready: Unknown, reason Kubelet stopped posting node status, unchanged since Nov 13.</li><li>EtcdIsVoter: False, reason NotAMember, Node is not a member of the etcd cluster.</li></ul><p>Then the service log on master3:</p><pre>sudo journalctl -u rke2-server --since &quot;-30min&quot; --no-pager | grep -Ei &quot;error|fail|kubelet|etcd&quot; | tail -40</pre><p>It was full of connection refused errors against 127.0.0.1:2379 (etcd) and 127.0.0.1:6443 (the API server), plus Failed to check local etcd status for learner management.</p><p><strong>Root cause:</strong> master3 was no longer a member of the etcd cluster. The RKE2 supervisor was running, but with no etcd there was nothing to start the control plane on, so the kubelet never registered and the node never became Ready. The most likely trigger was a member removal during an earlier master replacement. The node then restarted with a stale etcd data directory and could not rejoin.</p><p>This also changed the risk picture. The cluster was effectively a <strong>2-member etcd cluster</strong>, which needs both members for quorum. Losing either remaining master would have taken the control plane down.</p><h3>Step 3: Make it safe before you touch anything</h3><p>With only two healthy etcd members, the rule is simple: do not reboot, drain or patch the other masters until the third is back.</p><p>On a healthy master, take an etcd snapshot as a safety net and note what the new node will need:</p><pre># safety net<br>sudo rke2 etcd-snapshot save --name pre-master3-rebuild<br><br># join token for the new node<br>sudo cat /var/lib/rancher/rke2/server/node-token<br><br># settings to copy (tls-san, cni, and so on)<br>sudo cat /etc/rancher/rke2/config.yaml</pre><p>If the broken node still shows up in the etcd member list as stale or unstarted, remove it with etcdctl member remove &lt;ID&gt; before you continue. In my case it was already gone.</p><p>A tip I learned the hard way: RKE2 does not ship an etcdctl binary on the host. Run it inside the etcd static pod instead (see Step 6).</p><h3>Step 4: Remove the dead node and wipe RKE2</h3><p>From your admin machine, delete the stale node object and its node-password secret:</p><pre>kubectl delete node master3<br>kubectl -n kube-system delete secret master3.node-password.rke2 --ignore-not-found</pre><p>Then on the broken node, keep a copy of the old config and uninstall RKE2 completely:</p><pre>sudo cp -a /etc/rancher/rke2 /root/rke2-config.bak-$(date +%F)<br>sudo systemctl disable --now rke2-server<br>sudo rke2-killall.sh<br>sudo rke2-uninstall.sh<br>sudo rm -rf /etc/rancher /var/lib/rancher /var/lib/kubelet /etc/cni /opt/cni /var/lib/cni /run/k3s</pre><p>Check that no leftovers are running: ps aux | grep -E &#39;containerd|kube&#39; should come back empty. This wipes the stale etcd data directory, which was the real problem.</p><h3>Step 5: Patch, reinstall and configure</h3><p>The node is empty now, so this is the safest moment to patch and reboot it:</p><pre>sudo apt update &amp;&amp; sudo apt full-upgrade -y &amp;&amp; sudo reboot</pre><p>Install the <strong>same RKE2 version</strong> as the rest of the cluster:</p><pre>curl -sfL https://get.rke2.io | sudo INSTALL_RKE2_VERSION=v1.35.5+rke2r2 INSTALL_RKE2_TYPE=server sh -</pre><p>Then write the config. It must match the other masters, except for two lines: server: points at a <strong>healthy</strong> master (never at the node itself), and node-name is its own.</p><pre># /etc/rancher/rke2/config.yaml<br>server: https://&lt;healthy-master-ip&gt;:9345<br>token: &lt;token from the healthy master&gt;<br>node-name: master3<br>tls-san:<br>  - &lt;same SANs as the other masters&gt;<br># copy any other settings from a healthy master (cni, kubelet-arg, ingress, and so on)</pre><p>The most common mistake here is a config that drifts from the other masters. Diff it against a healthy one before you start the service.</p><h3>Step 6: Join the cluster and verify</h3><p>Start the service and watch it join:</p><pre>sudo systemctl enable --now rke2-server<br>sudo journalctl -u rke2-server -f</pre><p>The first start takes a few minutes while it joins etcd and pulls images. About two minutes after starting, kubectl get nodes -o wide showed master3 as Ready with the control-plane,etcd roles, on the newest kernel of the three masters. A single 502 ... connection refused line in the log was just a pod still starting.</p><p>Ready is not the same as healthy, so I checked etcd directly. Because RKE2 has no host etcdctl, I ran it inside an etcd pod:</p><pre>kubectl -n kube-system exec etcd-master1 -- etcdctl \<br>  --endpoints=https://127.0.0.1:2379 \<br>  --cacert=/var/lib/rancher/rke2/server/tls/etcd/server-ca.crt \<br>  --cert=/var/lib/rancher/rke2/server/tls/etcd/server-client.crt \<br>  --key=/var/lib/rancher/rke2/server/tls/etcd/server-client.key \<br>  endpoint status --cluster -w table</pre><p>What a healthy result looks like:</p><ul><li>Three endpoints, exactly one leader.</li><li>IS LEARNER is false for all three, so the new member is a full voter.</li><li>Identical raft term and applied index on all three, so the new member has fully caught up.</li><li>The ERRORS column is empty.</li></ul><p>One last check: the new node’s log showed it deleting the Traefik manifests. That is fine if your config disables the bundled ingress, but if the config differs from the other masters, it can remove ingress for the whole cluster. Compare the config and confirm your ingress pods are still running:</p><pre>kubectl get pods -A | grep -Ei &#39;traefik|ingress&#39;<br>kubectl get pods -A | grep -vE &#39;Running|Completed&#39;</pre><h3>Lessons learned</h3><ul><li><strong>A running service is not a healthy node.</strong> rke2-server said active (running) for days while the node was effectively dead. Check node conditions and etcd membership, not just systemd.</li><li><strong>Count your etcd voters, not your masters.</strong> Three control-plane nodes only gave me quorum protection while all three were etcd members.</li><li><strong>Snapshot before you rebuild.</strong> rke2 etcd-snapshot save takes seconds and is your way back.</li><li><strong>Rebuild beats repair</strong> when the etcd data directory is stale. Wiping and rejoining was faster and cleaner than debugging.</li><li><strong>Keep masters on the same version and config.</strong> The kernel and config drift made this harder to reason about.</li><li><strong>Patch one master at a time</strong>, and only after etcd shows three healthy voters.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=557eac26ea5f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Rebuilt a Failed HAProxy Node in My RKE2 HA Cluster with Zero Downtime]]></title>
            <link>https://medium.com/@ibrarullah204/how-i-rebuilt-a-failed-haproxy-node-in-my-rke2-ha-cluster-with-zero-downtime-8e95f5b6256b?source=rss-98a324318d64------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e95f5b6256b</guid>
            <dc:creator><![CDATA[Ibrarullah]]></dc:creator>
            <pubDate>Thu, 03 Dec 2026 05:28:12 GMT</pubDate>
            <atom:updated>2026-12-03T05:28:12.280Z</atom:updated>
            <content:encoded><![CDATA[<p><em>One of my two HAProxy load balancers died. Here is how I rebuilt it from a blank VM and put it back into the keepalived pair without a second of production downtime.</em></p><p>My production RKE2 cluster sits behind two HAProxy nodes that share a virtual IP (VIP) through keepalived. One morning, one of them was gone. The cluster kept running because the surviving node took over the VIP, exactly as designed. But I was now running on a single load balancer, with no failover left.</p><p>This article walks through the exact steps I used to rebuild the failed node from scratch and rejoin it to the pair, safely, while production traffic kept flowing. It also covers the two traps that almost bit me: a runbook that no longer matched reality, and the risk of split-brain when a new keepalived node comes online.</p><p>All IPs and secrets below are example values. Replace them with your own.</p><h3>The setup</h3><p>Every client, agent and kubectl session talks to one address: the VIP. Keepalived decides which HAProxy node owns that VIP at any moment, and HAProxy spreads the traffic across the three RKE2 server nodes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L0A8ahatgb382YJKBOzyrQ.png" /></figure><p>Two ports matter for RKE2:</p><ul><li><strong>6443</strong>: the Kubernetes API server</li><li><strong>9345</strong>: the RKE2 supervisor port that nodes use to register and join</li></ul><p>The example addresses used in this article:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/1*CtavZtDHtgM4bPduvXiRfg.png" /></figure><h3>Before you touch anything: trust the live node, not the runbook</h3><p>I had a runbook for building these load balancers. When I compared it with the surviving node, the IP addresses were completely different. The cluster had been moved to a new subnet, and the runbook was never updated. Following it blindly would have bound HAProxy to a VIP that didn’t exist and pointed it at masters that weren’t there.</p><p><strong>Lesson one: the surviving node is your source of truth.</strong> On it, collect three things:</p><pre># 1. The HAProxy config (both nodes run an identical copy)<br>sudo cat /etc/haproxy/haproxy.cfg<br><br># 2. The keepalived config: you need virtual_router_id, auth_pass,<br>#    the VIP and the peer IP the survivor expects<br>sudo cat /etc/keepalived/keepalived.conf<br><br># 3. The interface name, and confirmation that the survivor holds the VIP<br>ip -br a<br>ip a | grep 10.0.0.100</pre><p>Pay special attention to unicast_peer in the survivor&#39;s keepalived config. It tells you which IP the rebuilt node <strong>must</strong> have. If you give the new VM the same IP as the old one, nothing on the survivor needs to change.</p><p>In my case, the survivor was running as BACKUP with priority 110 but holding the VIP, because its MASTER peer was dead. That detail matters later.</p><h3>Rebuilding the HAProxy node</h3><p>Start with a fresh Ubuntu VM that has the old node’s IP (10.0.0.11 here). Confirm it can reach the survivor:</p><pre>ip -br a # should show 10.0.0.11 on your interface<br>ping -c 2 10.0.0.12</pre><p>Step 1: Install the packages</p><pre>sudo apt update<br>sudo apt install -y haproxy keepalived curl</pre><p>If apt reports a pending kernel upgrade, reboot now. Nothing is running on this node yet, so it is the cheapest moment to do it. It is also a good time to fix the hostname: sudo hostnamectl set-hostname ha1 and update /etc/hosts.</p><h3>Step 2: Allow binding to the VIP</h3><p>HAProxy binds directly to the VIP. The rebuilt node won’t own the VIP while it is the backup, and without this setting HAProxy refuses to start.</p><pre>sudo tee /etc/sysctl.d/99-lb-tuning.conf &lt;&lt; &#39;EOF&#39;<br>net.ipv4.ip_nonlocal_bind = 1<br>net.core.somaxconn = 65535<br>EOF<br>sudo sysctl --system</pre><h3>Step 3: Raise HAProxy’s file-descriptor limit</h3><pre>sudo mkdir -p /etc/systemd/system/haproxy.service.d<br>sudo tee /etc/systemd/system/haproxy.service.d/limits.conf &lt;&lt; &#39;EOF&#39;<br>[Service]<br>LimitNOFILE=100000<br>EOF<br>sudo systemctl daemon-reload</pre><h3>Step 4: Copy the HAProxy config from the survivor</h3><p>Both nodes must run an identical haproxy.cfg. Copy it over, or write it out:</p><pre>global<br>    log /dev/log local0<br>    log /dev/log local1 notice<br>    chroot /var/lib/haproxy<br>    user haproxy<br>    group haproxy<br>    daemon<br>    maxconn 30000<br><br>defaults<br>    log     global<br>    mode    tcp<br>    option  tcplog<br>    option  dontlognull<br>    option  tcpka<br>    timeout connect 5s<br>    timeout client  60s<br>    timeout server  60s<br>    retries 3<br><br>listen stats<br>    bind 127.0.0.1:8404<br>    mode http<br>    stats enable<br>    stats uri /stats<br>    stats refresh 10s<br><br>frontend rke2_registration_9345<br>    bind 10.0.0.100:9345<br>    maxconn 2500<br>    default_backend rke2_servers_9345<br><br>backend rke2_servers_9345<br>    balance roundrobin<br>    option tcp-check<br>    default-server inter 2s fall 2 rise 3 slowstart 10s maxconn 1000<br>    server master1 10.0.0.21:9345 check<br>    server master2 10.0.0.22:9345 check<br>    server master3 10.0.0.23:9345 check<br><br>frontend kubernetes_api_6443<br>    bind 10.0.0.100:6443<br>    maxconn 26000<br>    default_backend kube_apiservers_6443<br><br>backend kube_apiservers_6443<br>    balance roundrobin<br>    option tcp-check<br>    default-server inter 2s fall 2 rise 3 slowstart 15s maxconn 10000<br>    server master1 10.0.0.21:6443 check<br>    server master2 10.0.0.22:6443 check<br>    server master3 10.0.0.23:6443 check</pre><p>Validate the config, start HAProxy, and confirm all three ports are listening:</p><pre>sudo haproxy -c -f /etc/haproxy/haproxy.cfg     # &quot;Configuration file is valid&quot;<br>sudo systemctl enable --now haproxy<br>sudo ss -tlnp | grep -E &#39;6443|9345|8404&#39;</pre><p>This is safe while the survivor serves production. The rebuilt node listens on the VIP, but it doesn’t own the VIP, so no traffic reaches it yet.</p><h3>Step 5: Add the keepalived health check</h3><p>Keepalived runs this script every 2 seconds. If HAProxy is down, the node gives up the VIP, or never claims it.</p><pre>sudo tee /etc/keepalived/check_haproxy.sh &lt;&lt; &#39;SCRIPT&#39;<br>#!/bin/bash<br>systemctl is-active --quiet haproxy || exit 1<br>curl -sf http://127.0.0.1:8404/stats &gt;/dev/null || exit 1<br>exit 0<br>SCRIPT<br>sudo chmod 755 /etc/keepalived/check_haproxy.sh<br>sudo /etc/keepalived/check_haproxy.sh; echo $?   # must print 0</pre><h3>Joining keepalived without disturbing production</h3><p>This is the risky step. Get it wrong and the VIP moves, or two nodes claim it at once.</p><h3>Trap 1: The rebuilt node would grab the VIP back</h3><p>The node I was rebuilding used to be the MASTER with priority 120. The survivor runs at priority 110. If I had restored the original config, the rebuilt node would have taken the VIP the moment keepalived started. That means an API blip, and if anything on the new node were broken, a production outage.</p><p><strong>The fix: bring it back as BACKUP with a lower priority (100).</strong> Keepalived always gives the VIP to the highest-priority healthy node, so the survivor keeps it and the new node waits quietly.</p><h3>Trap 2: Split-brain</h3><p>If the new node can’t hear the survivor’s VRRP heartbeats, it assumes the survivor is dead and claims the VIP too. Two machines answering for the same IP means dropped connections. Check this <strong>before</strong> starting keepalived.</p><p>The survivor already sends unicast heartbeats to the rebuilt node’s IP, so you can watch for them:</p><pre>sudo ufw status          # if active: sudo ufw allow from 10.0.0.12 proto vrrp<br>sudo tcpdump -i ens18 -n vrrp -c 5</pre><p>You should see lines like 10.0.0.12 &gt; 10.0.0.11: VRRPv2, Advertisement, vrid 51, prio 110. If nothing arrives, stop and fix the network or firewall first.</p><h3>Step 6: Write the keepalived config</h3><p>Copy virtual_router_id, auth_pass and the VIP exactly from the survivor. Swap the unicast addresses, and set priority below the survivor&#39;s:</p><pre>global_defs {<br>    router_id HAPROXY_01<br>    enable_script_security<br>    script_user root<br>}<br><br>vrrp_script chk_haproxy {<br>    script &quot;/etc/keepalived/check_haproxy.sh&quot;<br>    interval 2<br>    fall 2<br>    rise 2<br>    timeout 2<br>}<br><br>vrrp_instance VI_RKE2 {<br>    state BACKUP<br>    interface ens18<br>    virtual_router_id 51            # must match the survivor<br>    priority 100                    # lower than the survivor&#39;s 110<br>    advert_int 1<br><br>    unicast_src_ip 10.0.0.11        # this node<br>    unicast_peer {<br>        10.0.0.12                   # the survivor<br>    }<br><br>    authentication {<br>        auth_type PASS<br>        auth_pass &lt;YOUR_VRRP_PASSWORD&gt;   # must match the survivor<br>    }<br><br>    virtual_ipaddress {<br>        10.0.0.100/24<br>    }<br><br>    track_script {<br>        chk_haproxy<br>    }<br>}</pre><p>Save it as /etc/keepalived/keepalived.conf, then start keepalived and read the log:</p><pre>sudo systemctl enable --now keepalived<br>sudo journalctl -u keepalived -n 20 --no-pager</pre><p>You want to see (VI_RKE2) Entering BACKUP STATE and nothing after it. A warning that says Truncating auth_pass to 8 characters is harmless: keepalived&#39;s PASS authentication only uses the first 8 characters, on both nodes.</p><p>Keep a safety net ready. If the new node ever logs Entering MASTER STATE while the survivor is still up, run sudo systemctl stop keepalived on the new node. The VIP is released immediately and the survivor keeps serving.</p><h3>Proving it works: the failover test</h3><p>A backup you haven’t tested isn’t a backup. First confirm the VIP lives only on the survivor:</p><pre>ip a | grep 10.0.0.100    # on ha1: no output<br>ip a | grep 10.0.0.100    # on ha2: shows the VIP</pre><p>Then force a failover. Each VIP move causes a 1 to 3 second blip on the API, so do this in a quiet window.</p><ol><li>On the survivor (ha2), stop keepalived: sudo systemctl stop keepalived</li><li>On the rebuilt node (ha1), the VIP should appear within about 3 seconds. The log shows Entering MASTER STATE.</li><li>From your jump host, run kubectl get nodes. Every node should report Ready, now served through the rebuilt node.</li><li>On the survivor, start keepalived again: sudo systemctl start keepalived</li></ol><p>In step 4, the survivor’s log told the whole story:</p><pre>(VI_RKE2) received lower priority (100) advert from 10.0.0.11 - discarding<br>(VI_RKE2) Entering MASTER STATE</pre><p>The survivor heard the rebuilt node’s lower priority, took the VIP back, and the rebuilt node stepped down to BACKUP. Failover now works in both directions.</p><pre>$ kubectl get nodes<br>NAME                STATUS   ROLES                AGE    VERSION<br>gpu-worker-node-3   Ready    &lt;none&gt;               173d   v1.35.5+rke2r2<br>master1             Ready    control-plane,etcd   27d    v1.35.5+rke2r2<br>master2             Ready    control-plane,etcd   173d   v1.35.5+rke2r2<br>master3             Ready    control-plane,etcd   13d    v1.35.5+rke2r2<br>worker-node-1       Ready    &lt;none&gt;               173d   v1.35.5+rke2r2<br>worker-node-2       Ready    &lt;none&gt;               173d   v1.35.5+rke2r2</pre><h3>What I learned</h3><p>The rebuild took under an hour, and production never noticed. Four things made that possible:</p><ol><li><strong>Trust the live system over the docs.</strong> My runbook had the wrong subnet. Copying configs from the surviving node avoided a broken rebuild.</li><li><strong>Rejoin as the lowest priority.</strong> A rebuilt node should earn the MASTER role after testing, not take it on first boot.</li><li><strong>Check for VRRP heartbeats before starting keepalived.</strong> One tcpdump command rules out split-brain before it can happen.</li><li><strong>Always run the failover test.</strong> “Entering BACKUP STATE” only proves the node is waiting. A real failover proves it can serve.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e95f5b6256b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Two tier go application project]]></title>
            <link>https://medium.com/@ibrarullah204/two-tier-go-application-project-4681cf382c42?source=rss-98a324318d64------2</link>
            <guid isPermaLink="false">https://medium.com/p/4681cf382c42</guid>
            <dc:creator><![CDATA[Ibrarullah]]></dc:creator>
            <pubDate>Wed, 13 Mar 2024 13:12:26 GMT</pubDate>
            <atom:updated>2024-03-13T13:12:26.778Z</atom:updated>
            <content:encoded><![CDATA[<p>This project divide in three steps. The first one is create dockerfile , second is create CICD by github action to push the image to docker hub and the third one is create a docker compose file.</p><p><strong>Docker file</strong></p><p>lets create the docker file of the go to-do application</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*m3Be2VBt0vNh60_vbA8VZw.png" /></figure><p>base image is golang and then create directory /app, copy .env file in it then copy the whole current directory in /app, Expose the 4040 port for the access of this application, then run the app.</p><p>CICD BY GIT-HUB ACTION:</p><p>I use the git-hub action for CICD,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_rRWF-jbKoLTrFHQiG5dZA.png" /></figure><p>In the above workflow i set the triger on push so run this workflow, workflow consist on one job and multiple steps in it like create a virtual machine to run a job and checkout the repo code, log in to docker hub using login action with the secrets of name and password of the docker hub, build the image and tag it give the label description of it.</p><p><strong>Docker-compose file:</strong></p><p>The docker compose consist multiple images and connect it by service to run a multi tier app easily.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*WwxM-mnnyIlaG6QHTZ7odQ.png" /></figure><p>the above is the docker compose file, consist on two images first one is web (which one i push to docker hub via git-hub action) and the second one is MySQL for to store the to-da pp data.</p><p>let expose the app :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S78QB21a5dEk32OCV-AiLQ.png" /></figure><p>application is expose on 4040.</p><p>thank you for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4681cf382c42" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ETCD WORKS WITH MINIKUBE]]></title>
            <link>https://medium.com/@ibrarullah204/etcd-works-with-minibike-b38a051f9ab5?source=rss-98a324318d64------2</link>
            <guid isPermaLink="false">https://medium.com/p/b38a051f9ab5</guid>
            <category><![CDATA[kubernetes-cluster]]></category>
            <dc:creator><![CDATA[Ibrarullah]]></dc:creator>
            <pubDate>Fri, 01 Mar 2024 10:55:44 GMT</pubDate>
            <atom:updated>2024-03-01T10:57:25.150Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>ETCD WORKS WITH MINIKUBE</strong></p><p>create a minikube cluster and check all the pod s via cmd like</p><p>kubectl get pods -A # show all the pods exist in this node</p><p>describe the minikube pod via cmd</p><p>kubectl describe pod etcd-minikube -n kube-system # describe minikube pod which exist in kube-system namespace</p><p>describe show all the metadata and configuration how the etcd stitch with k8’s, like the ca certificate key etc…</p><p>if you want to interact with etcd pod for check it its working or not soby cmd :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0XbnWJntJqGxEZHix3pV3g.png" /></figure><p>kubectl exec etcd-minikube -n kube-system — sh -c “ETCDCTL_API=3 etcdctl — endpoints <a href="https://192.168.59.101:2379/">https://192.168.59.101:2379</a> — cacert /var/lib/minikube/certs/etcd/ca.crt — key /var/lib/minikube/certs/etcd/server.key — cert /var/lib/minikube/certs/etcd/server.crt get / — prefix — keys-only” these four things very important — endpoint , — cacert , — key, — cert. you can find these file path in describe etcd-minikube metadata.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FgM3n4r92BcQN7aOr2hqvg.png" /></figure><p>you can put and get the data like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ydzQB_BPMnWz5U2FoJjx-A.png" /></figure><p>that enough for good understanding of etcd with minkube. keep learning..</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b38a051f9ab5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>