<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: S M Jamal Uddin AL Gilani</title>
    <description>The latest articles on DEV Community by S M Jamal Uddin AL Gilani (@jamal-gilani).</description>
    <link>https://dev.to/jamal-gilani</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4102771%2F956191da-3e62-4459-bfc3-5ff1632048d2.jpeg</url>
      <title>DEV Community: S M Jamal Uddin AL Gilani</title>
      <link>https://dev.to/jamal-gilani</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jamal-gilani"/>
    <language>en</language>
    <item>
      <title>One Hub to Watch Them All: Multi-Tenant Monitoring for 4 Clusters and 400+ Edge Machines with Grafana, Mimir, Loki and Alloy</title>
      <dc:creator>S M Jamal Uddin AL Gilani</dc:creator>
      <pubDate>Fri, 13 Nov 2026 10:18:24 +0000</pubDate>
      <link>https://dev.to/jamal-gilani/one-hub-to-watch-them-all-multi-tenant-monitoring-for-4-clusters-and-400-edge-machines-with-33gk</link>
      <guid>https://dev.to/jamal-gilani/one-hub-to-watch-them-all-multi-tenant-monitoring-for-4-clusters-and-400-edge-machines-with-33gk</guid>
      <description>&lt;p&gt;"How I built a self-hosted, GitOps-managed observability hub on Kubernetes: Mimir for metrics, Loki for logs, Alloy as the only agent, tenants enforced at the gateway, and S3 as the real database."&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;Our monitoring was spread across too many places. We run a handful of on-prem Kubernetes clusters (one "hub" plus several "spoke" clusters) and &lt;strong&gt;more than 400 edge machines&lt;/strong&gt; at remote sites. Each place had its own partial monitoring. The rest had none.&lt;/p&gt;

&lt;p&gt;That caused the usual pain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No single place to look.&lt;/strong&gt; When something broke at an edge site, we SSH'd in and grepped logs. Live, if the machine was still reachable.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No history.&lt;/strong&gt; Local Prometheus instances kept a few days of data on whatever disk they had. Questions like "when did this start?" had no answer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No separation.&lt;/strong&gt; If several teams shared one Prometheus, they all saw each other's data, and one noisy sender could hurt everyone.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hand-made config.&lt;/strong&gt; Nobody could say exactly what was deployed or why.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I wanted &lt;strong&gt;one central place&lt;/strong&gt; for the metrics and logs of every cluster and every machine. It had to be self-hosted, multi-tenant, cheap on disk, and fully described in Git.&lt;/p&gt;

&lt;p&gt;This post covers what I built, how it works, and the mistakes I made along the way.&lt;/p&gt;

&lt;h2&gt;
  
  
  The stack at a glance
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Concern&lt;/th&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Collection (metrics + logs)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Grafana Alloy&lt;/strong&gt;, the only agent everywhere&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Metrics storage&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Grafana Mimir&lt;/strong&gt; (distributed, classic architecture)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Log storage&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Grafana Loki&lt;/strong&gt; (distributed / microservices mode)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;UI + alerting&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Grafana&lt;/strong&gt; (HA, Grafana-managed alert rules)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Object storage&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;S3-compatible MinIO&lt;/strong&gt; on a NAS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Block storage&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Longhorn&lt;/strong&gt; on SSD&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Delivery&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Argo CD&lt;/strong&gt; (app-of-apps, Helm multi-source)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Secrets&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;OpenBao&lt;/strong&gt; + &lt;strong&gt;External Secrets Operator&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ingress&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;NGINX Gateway Fabric&lt;/strong&gt; (Gateway API, wildcard TLS)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Right-sizing&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;VPA&lt;/strong&gt; in recommend-only mode&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3j8xe3v64foqgiesvq3o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3j8xe3v64foqgiesvq3o.png" alt="x" width="800" height="591"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The design rests on four ideas:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Hub and spoke.&lt;/strong&gt; Mimir, Loki and Grafana run only on the hub. Every cluster and machine runs Alloy and &lt;em&gt;pushes&lt;/em&gt; to the hub over HTTPS. The hub never has to reach into a site.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Object storage is the real database.&lt;/strong&gt; Mimir and Loki keep only recent data on local disks. Everything else goes to S3. Retention is 15 days for metrics and 30 days for logs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The gateway decides the tenant, never the sender.&lt;/strong&gt; Each sender authenticates with its own login, and the gateway maps that login to a tenant.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Everything is Git.&lt;/strong&gt; Nothing is applied by hand. Secrets come from a vault, so Git holds no credentials.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  1. Collection: Alloy everywhere
&lt;/h2&gt;

&lt;p&gt;I used &lt;strong&gt;Grafana Alloy&lt;/strong&gt; as the single agent. A single Alloy DaemonSet per cluster collects:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;pod logs (Kubernetes API discovery),&lt;/li&gt;
&lt;li&gt;node / systemd journal logs,&lt;/li&gt;
&lt;li&gt;node metrics (built-in node_exporter),&lt;/li&gt;
&lt;li&gt;kubelet and cAdvisor metrics,&lt;/li&gt;
&lt;li&gt;kube-state-metrics.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The edge machines run the same Alloy binary as a systemd service, with a smaller config that ships host logs and host metrics.&lt;/p&gt;

&lt;p&gt;Every series and log stream gets a &lt;code&gt;cluster&lt;/code&gt; label, so one set of dashboards works for every cluster:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;prometheus.remote_write "default" {
  endpoint {
    url = "https://metrics.example.com/api/v1/push"
    basic_auth {
      username = sys.env("PUSH_USER")
      password = sys.env("PUSH_PASSWORD")
    }
    // Informational only: the gateway overrides it from the login
    headers = { "X-Scope-OrgID" = "spoke-a" }
  }
  external_labels = { cluster = "spoke-a" }
}

loki.write "default" {
  endpoint {
    url       = "https://logs.example.com/loki/api/v1/push"
    tenant_id = "spoke-a"
    basic_auth {
      username = sys.env("PUSH_USER")
      password = sys.env("PUSH_PASSWORD")
    }
  }
  external_labels = { cluster = "spoke-a" }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Small gotcha:&lt;/strong&gt; &lt;code&gt;loki.write&lt;/code&gt; has a &lt;code&gt;tenant_id&lt;/code&gt; field. &lt;code&gt;prometheus.remote_write&lt;/code&gt; does not, so you set the &lt;code&gt;X-Scope-OrgID&lt;/code&gt; header yourself.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;"Why still run kube-state-metrics if Alloy collects metrics?"&lt;/strong&gt; My team lead asked exactly that. Alloy &lt;em&gt;scrapes&lt;/em&gt;. kube-state-metrics &lt;em&gt;produces&lt;/em&gt; metrics about Kubernetes objects: desired vs. available replicas, pod phase, restarts, PVC status, and so on. Nothing else exposes those, and every "is my deployment healthy?" panel needs them. I run one replica per cluster, with no autoscaling, because two replicas would just double every series. Plain-host edge machines don't need it.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Metrics: Mimir in classic mode
&lt;/h2&gt;

&lt;p&gt;Mimir runs in distributed mode on the hub:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gateway → distributor → ingester ×3 (RF 3, WAL on SSD) → blocks to S3
                                         ↑
query-frontend → query-scheduler → querier → store-gateway ×3 (reads S3)
compactor: merges blocks, enforces 15-day retention
memcached: chunks, index, metadata and results caches
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What I configured, and why:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Classic architecture (no Kafka).&lt;/strong&gt; Recent chart versions default to the Kafka-based "ingest storage" architecture. That's a lot of extra machinery for our scale, so I switched it off with &lt;code&gt;ingest_storage.enabled: false&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Replication factor 3&lt;/strong&gt; on ingesters and store-gateways.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Per-tenant limits sized for reality.&lt;/strong&gt; The defaults (10k samples/s, 150k series) are far too low for hundreds of senders.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;out_of_order_time_window: 10m&lt;/code&gt;.&lt;/strong&gt; Edge sites sit on flaky links and sometimes deliver late samples.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stateless parts autoscale&lt;/strong&gt; with HPAs: distributor 3–6, querier 3–8, query-frontend 2–3, gateway 2–4. Stateful parts are scaled by hand.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;mimir&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;structuredConfig&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;multitenancy_enabled&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="na"&gt;tenant_federation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;enabled&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;        &lt;span class="c1"&gt;# lets Grafana query "tenant-a|tenant-b"
&lt;/span&gt;    &lt;span class="na"&gt;ingest_storage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;enabled&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;       &lt;span class="c1"&gt;# classic: distributor → ingester over gRPC
&lt;/span&gt;    &lt;span class="na"&gt;ingester&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;ring&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;replication_factor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
    &lt;span class="na"&gt;limits&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;compactor_blocks_retention_period&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;15d&lt;/span&gt;
      &lt;span class="na"&gt;ingestion_rate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;200000&lt;/span&gt;
      &lt;span class="na"&gt;max_global_series_per_user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5000000&lt;/span&gt;
      &lt;span class="na"&gt;out_of_order_time_window&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;10m&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;A chart quirk worth knowing:&lt;/strong&gt; the &lt;code&gt;mimir-distributed&lt;/code&gt; chart only has a native HPA for the &lt;strong&gt;gateway&lt;/strong&gt;. For distributor, querier and query-frontend it offers only KEDA-based autoscaling, which is marked experimental and needs the KEDA operator. I didn't want another operator just for CPU/memory scaling, so I defined plain &lt;code&gt;autoscaling/v2&lt;/code&gt; HPAs as extra objects and set &lt;code&gt;replicas: null&lt;/code&gt; on those Deployments. That way Argo CD and the HPA never fight over the replica count.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Logs: Loki in distributed mode
&lt;/h2&gt;

&lt;p&gt;Loki looks almost the same: gateway → distributor → 3 ingesters → chunks and TSDB index in S3, with index-gateways, a compactor for retention, and a pattern-ingester for Grafana's &lt;em&gt;Logs Drilldown&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The settings that matter:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;TSDB schema v13&lt;/strong&gt; with a 24h index period.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;30-day retention&lt;/strong&gt;, enforced by the compactor (&lt;code&gt;retention_enabled: true&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Per-tenant rate limits&lt;/strong&gt; on ingestion and on streams.&lt;/li&gt;
&lt;li&gt;Chunks flush after 30 minutes idle or 2 hours max age.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. Multi-tenancy: the gateway decides
&lt;/h2&gt;

&lt;p&gt;This is the part I'm happiest with.&lt;/p&gt;

&lt;p&gt;Mimir and Loki are multi-tenant through the &lt;code&gt;X-Scope-OrgID&lt;/code&gt; header. The catch: &lt;strong&gt;whoever sets the header picks the tenant.&lt;/strong&gt; If senders set it themselves, a compromised or misconfigured edge machine could write into another tenant's data, or read it.&lt;/p&gt;

&lt;p&gt;So the senders' header doesn't count. Both gateways (nginx) require basic auth, then &lt;strong&gt;derive the tenant from the login&lt;/strong&gt;. Any header the client sent is overwritten:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight nginx"&gt;&lt;code&gt;&lt;span class="k"&gt;map&lt;/span&gt; $&lt;span class="n"&gt;remote_user&lt;/span&gt; $&lt;span class="n"&gt;tenant&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;hub&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;push&lt;/span&gt;      &lt;span class="n"&gt;hub&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                    &lt;span class="c1"&gt;# the hub cluster's own Alloy&lt;/span&gt;
  &lt;span class="n"&gt;grafana&lt;/span&gt;       $&lt;span class="n"&gt;http_x_scope_orgid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;    &lt;span class="c1"&gt;# only Grafana may choose tenants&lt;/span&gt;
  &lt;span class="o"&gt;~^&lt;/span&gt;&lt;span class="n"&gt;edge&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;sites&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;edge&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;sites&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;             &lt;span class="c1"&gt;# every edge machine: edge-sites-&amp;lt;site-id&amp;gt;&lt;/span&gt;
  &lt;span class="na"&gt;default       $remote_user;           # spoke clusters: login&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tenant&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;# in every proxied location
&lt;/span&gt;&lt;span class="n"&gt;proxy_set_header&lt;/span&gt; &lt;span class="no"&gt;X&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Scope&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;OrgID&lt;/span&gt; $&lt;span class="n"&gt;tenant&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What this gives us:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Spoke clusters&lt;/strong&gt; log in as their own cluster name and land in their own tenant.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Each of the 400+ edge machines has its own login&lt;/strong&gt; (&lt;code&gt;edge-sites-&amp;lt;site-id&amp;gt;&lt;/code&gt;). They all land in one shared tenant, &lt;code&gt;edge-sites&lt;/code&gt;. One machine's credentials can be revoked without touching the others. A regex in the map does it, so adding a site needs no config change.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Only Grafana&lt;/strong&gt; may pick tenants itself. Its datasource sends &lt;code&gt;hub|spoke-a|edge-sites&lt;/code&gt; and Mimir's tenant federation merges them in a query.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I tested this with a throwaway nginx container before rolling it out:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a forged &lt;code&gt;X-Scope-OrgID&lt;/code&gt; gets overwritten;&lt;/li&gt;
&lt;li&gt;edge logins map to the edge tenant;&lt;/li&gt;
&lt;li&gt;a wrong password returns 401.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That test was worth it. My first version was wrong: &lt;code&gt;return 200&lt;/code&gt; in a test location skips &lt;code&gt;auth_basic&lt;/code&gt; entirely, so the test passed for the wrong reason. Test with a real &lt;code&gt;proxy_pass&lt;/code&gt; backend.&lt;/p&gt;

&lt;h3&gt;
  
  
  Where the credentials live
&lt;/h3&gt;

&lt;p&gt;Nothing secret is in Git. OpenBao holds the values, and External Secrets Operator turns them into Kubernetes Secrets. I keep &lt;strong&gt;two kinds of credentials at separate paths&lt;/strong&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;OpenBao path&lt;/th&gt;
&lt;th&gt;Contents&lt;/th&gt;
&lt;th&gt;Read by&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;…/mimir-push-credentials&lt;/code&gt;, &lt;code&gt;…/loki-push-credentials&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;plain username + password&lt;/td&gt;
&lt;td&gt;the sender (Alloy)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;…/mimir-gateway-basic-auth&lt;/code&gt;, &lt;code&gt;…/loki-gateway-basic-auth&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;htpasswd for hub logins&lt;/td&gt;
&lt;td&gt;the gateway&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;…/edge-sites-htpasswd&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;htpasswd, one line per edge machine&lt;/td&gt;
&lt;td&gt;the gateway&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The sender needs the &lt;em&gt;plain&lt;/em&gt; password to log in. The gateway needs only the &lt;em&gt;bcrypt hash&lt;/em&gt;. Keeping them apart means each consumer gets only what it needs.&lt;/p&gt;

&lt;p&gt;The edge team hands over their htpasswd lines. I store them at a separate path, and an ExternalSecret template joins both lists into the single &lt;code&gt;.htpasswd&lt;/code&gt; the gateway mounts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;external-secrets.io/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ExternalSecret&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;loki-gateway-basic-auth&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;secretStoreRef&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ClusterSecretStore&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;vault-store&lt;/span&gt;
  &lt;span class="na"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;loki-gateway-basic-auth&lt;/span&gt;
    &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;engineVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v2&lt;/span&gt;
      &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="c1"&gt;# strip Windows line endings in case the list was edited there
&lt;/span&gt;        &lt;span class="na"&gt;.htpasswd&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt;
          &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;.hub&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="s"&gt;replace&lt;/span&gt; &lt;span class="s2"&gt;"\r"&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="s"&gt;trim&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
          &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;.edge&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="s"&gt;replace&lt;/span&gt; &lt;span class="s2"&gt;"\r"&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="s"&gt;trim&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;secretKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;hub&lt;/span&gt;
      &lt;span class="na"&gt;remoteRef&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;key:&lt;/span&gt; &lt;span class="s"&gt;monitoring/loki-gateway-basic-auth&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;property:&lt;/span&gt; &lt;span class="s"&gt;htpasswd&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;secretKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;edge&lt;/span&gt;
      &lt;span class="na"&gt;remoteRef&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;key:&lt;/span&gt; &lt;span class="s"&gt;monitoring/edge-sites-htpasswd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;property:&lt;/span&gt; &lt;span class="s"&gt;htpasswd&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two details:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;bcrypt cost 5&lt;/strong&gt; (&lt;code&gt;htpasswd -nbB -C 5 &amp;lt;user&amp;gt; &amp;lt;password&amp;gt;&lt;/code&gt;). The gateway checks the hash on every push request. The default cost burns CPU for no real gain on long random machine passwords.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;nginx ignores &lt;code&gt;#&lt;/code&gt; lines in htpasswd.&lt;/strong&gt; So a &lt;code&gt;# edge logins&lt;/code&gt; placeholder keeps the path valid before the first real login exists.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. Grafana: stateless and HA
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;2–4 replicas&lt;/strong&gt; behind an HPA.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;State in PostgreSQL&lt;/strong&gt; (CloudNativePG): users, dashboards and alert rules. Grafana needs no PVC, and any replica can serve any request.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;HA alerting.&lt;/strong&gt; The replicas gossip over a headless service, so each alert notification goes out once.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Grafana-managed alert rules.&lt;/strong&gt; Mimir's ruler and Alertmanager and Loki's ruler are switched off. Everything lives in one place, and one rule can query both metrics and logs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dashboards from Git.&lt;/strong&gt; Community dashboards (Kubernetes Views, Node Exporter Full) are stored as JSON in the repo. Kustomize turns them into ConfigMaps, and the dashboard sidecar loads them into folders.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# kustomization.yaml
&lt;/span&gt;&lt;span class="na"&gt;generatorOptions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;disableNameSuffixHash&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;grafana_dashboard&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"1"&lt;/span&gt;
  &lt;span class="na"&gt;annotations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# dashboard JSON exceeds the 256 KB last-applied annotation limit
&lt;/span&gt;    &lt;span class="na"&gt;argocd.argoproj.io/sync-options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ServerSideApply=true&lt;/span&gt;
&lt;span class="na"&gt;configMapGenerator&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;grafana-dashboards-kubernetes&lt;/span&gt;
    &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;monitoring&lt;/span&gt;
    &lt;span class="na"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;annotations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;grafana_folder&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Kubernetes&lt;/span&gt;
    &lt;span class="na"&gt;files&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;dashboards/kubernetes/k8s-views-global.json&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;dashboards/kubernetes/k8s-views-pods.json&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  6. Storage: S3 for history, SSD for the hot path
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;S3 (MinIO on a NAS)&lt;/strong&gt; holds every Mimir block and every Loki chunk. It's cheap, large, and the compactors enforce retention on it. Each component has its own bucket and its own access key, scoped to that bucket.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Longhorn SSD volumes&lt;/strong&gt; hold only ingester WALs, recent data and index caches.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I started on iSCSI HDD and it was too slow for ingester WALs.&lt;/p&gt;

&lt;p&gt;Longhorn keeps &lt;strong&gt;one replica&lt;/strong&gt; per volume, because Mimir and Loki already replicate data 3× at the application level. Another 3× underneath would just be 9 copies.&lt;/p&gt;

&lt;p&gt;If a volume is lost, at most the last ~2 hours that weren't uploaded yet are at risk, and the other two ingester replicas cover even that.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. GitOps and secrets
&lt;/h2&gt;

&lt;p&gt;Everything is an Argo CD Application under one app-of-apps. Each Helm-based component uses &lt;strong&gt;multi-source&lt;/strong&gt; Applications: the upstream chart from its Helm repo, plus a &lt;code&gt;values.yaml&lt;/code&gt; from our Git repo. Chart upgrades become a one-line version bump in a pull request.&lt;/p&gt;

&lt;p&gt;The rules:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No &lt;code&gt;kubectl apply&lt;/code&gt; or &lt;code&gt;kubectl edit&lt;/code&gt; on these components. Change Git, push, let Argo sync.&lt;/li&gt;
&lt;li&gt;Every credential lives in OpenBao: S3 keys, push credentials, htpasswd lists, the Grafana admin login, DB credentials. External Secrets Operator syncs them. The Git repo is safe to share inside the company.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;VPA in recommend-only mode&lt;/strong&gt; (&lt;code&gt;updateMode: "Off"&lt;/code&gt;) for every workload. It never restarts anything, but after a couple of weeks of real traffic it tells me what the requests and limits should be.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Lessons learned (the hard way)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Removing one Helm values block can silently re-architect a component.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Someone tidied up the Mimir values and deleted the &lt;code&gt;ingester:&lt;/code&gt; block. It looked redundant next to &lt;code&gt;ingest_storage.enabled: false&lt;/code&gt;. It isn't: one configures &lt;em&gt;how data reaches&lt;/em&gt; the ingesters, the other configures the ingester &lt;em&gt;pods&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Without the block, the chart fell back to its default: &lt;strong&gt;zone-aware ingesters&lt;/strong&gt; (&lt;code&gt;ingester-zone-a/b/c&lt;/code&gt;) with no StorageClass. We have no default StorageClass, so the new pods sat &lt;code&gt;Pending&lt;/code&gt; and ingestion stopped.&lt;/p&gt;

&lt;p&gt;Fix: restore the block and leave a loud comment saying why it must stay.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Two memberlist clusters on one network can merge.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Mimir and Loki both use memberlist gossip on port 7946, both with a ring called &lt;code&gt;ingester&lt;/code&gt;. After pods restarted and IPs were reused, Loki's ring contained Mimir's ingesters. Setting a distinct &lt;code&gt;cluster_label&lt;/code&gt; on each fixed it for good.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. RKE2's DNS service isn't called &lt;code&gt;kube-dns&lt;/code&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The gateways' nginx resolver crash-looped until I set &lt;code&gt;global.dnsService: rke2-coredns-rke2-coredns&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Don't put Grafana behind PgBouncer in transaction mode.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Prepared statements break (&lt;code&gt;unnamed prepared statement does not exist&lt;/code&gt;). Grafana connects straight to the Postgres primary.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. An HPA needs requests on &lt;em&gt;every&lt;/em&gt; container in the pod.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Grafana's dashboard sidecar had none. The HPA reported &lt;code&gt;missing request for cpu&lt;/code&gt;, and Argo CD marked the app &lt;em&gt;Degraded&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. A browser login popup in Grafana means a datasource returned 401.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The gateway's &lt;code&gt;WWW-Authenticate&lt;/code&gt; header goes all the way through to the browser. Fix the datasource credentials; the popup isn't the real problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we got out of it
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;One place for everything.&lt;/strong&gt; Metrics and logs from every cluster and every edge site, in one Grafana, correlated by the same &lt;code&gt;cluster&lt;/code&gt; label.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Real history.&lt;/strong&gt; 15 days of metrics and 30 days of logs, regardless of whether the edge machine is still online.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Isolation by design.&lt;/strong&gt; Senders can't pick their tenant. Each tenant has its own limits, so a noisy sender can't starve the rest. Revoking one machine is one line in the vault.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Horizontal scale where it matters.&lt;/strong&gt; The write and read paths scale with HPAs. Storage grows with the object store, not with node disks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cheap and self-hosted.&lt;/strong&gt; No per-series SaaS bill. The expensive part (history) lives on commodity S3.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reproducible.&lt;/strong&gt; The whole stack can be rebuilt from Git plus the vault. Every change has a commit and a reviewer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;One agent to maintain.&lt;/strong&gt; Alloy handles logs and metrics on Kubernetes and on bare hosts.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What's next
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;More worker nodes.&lt;/strong&gt; Replication factor 3 doesn't protect against losing the node it all runs on, and our hub currently has a single worker. Anti-affinity is already set to &lt;em&gt;preferred&lt;/em&gt;, so pods will spread on their own once the nodes exist.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SSO for Grafana&lt;/strong&gt; and IP allowlists on the push endpoints.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Per-tenant limit overrides&lt;/strong&gt;, so the edge tenant and the hub can have different budgets.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Self-monitoring&lt;/strong&gt; of Mimir, Loki and Grafana, plus Kubernetes events as logs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you're building something similar, my strongest advice is about the multi-tenancy boundary. &lt;strong&gt;Put it at the gateway and derive it from the identity, not from a header the client controls.&lt;/strong&gt; Everything else in this stack is a sizing question.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Questions or a different approach? Leave a comment, I'd love to compare notes.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>infrastructure</category>
      <category>kubernetes</category>
      <category>monitoring</category>
    </item>
    <item>
      <title>Rebuilding an On-Prem Kubernetes Platform With GitOps After a Storage Wipe</title>
      <dc:creator>S M Jamal Uddin AL Gilani</dc:creator>
      <pubDate>Tue, 27 Oct 2026 06:12:21 +0000</pubDate>
      <link>https://dev.to/jamal-gilani/rebuilding-an-on-prem-kubernetes-platform-with-gitops-after-a-storage-wipe-2ep0</link>
      <guid>https://dev.to/jamal-gilani/rebuilding-an-on-prem-kubernetes-platform-with-gitops-after-a-storage-wipe-2ep0</guid>
      <description>&lt;p&gt;description: How we rebuilt an RKE2 on-prem cluster from Argo CD only — OpenBao, External Secrets, TrueNAS CSI, CloudNativePG, Harbor, MinIO, and GitHub Actions runners.&lt;/p&gt;




&lt;h2&gt;
  
  
  Rebuilding an On-Prem Kubernetes Platform With GitOps After a Storage Wipe
&lt;/h2&gt;

&lt;p&gt;We wiped the old HDD-era cluster and rebuilt on SSD-backed storage. The rule was simple: &lt;strong&gt;Argo CD is the only thing applied by hand&lt;/strong&gt;. Everything else — operators, storage, secrets plumbing, Postgres, the registry, ingress, CI runners — had to come back from git.&lt;/p&gt;

&lt;p&gt;This is the story of that rebuild: what we put in GitOps, what we deliberately left out of git, and the failures that taught us more than the happy path.&lt;/p&gt;

&lt;p&gt;I work on an on-prem platform team. The cluster is RKE2 (Canal, a typical RKE2 pod CIDR) on a private LAN. A TrueNAS box provides iSCSI, NFS, and S3. Platform hostnames (&lt;code&gt;argocd&lt;/code&gt;, &lt;code&gt;vault&lt;/code&gt;, &lt;code&gt;harbor&lt;/code&gt;, &lt;code&gt;s3&lt;/code&gt;) terminate on a MetalLB VIP. Source of truth is a private GitOps repo, watched by Argo CD on &lt;code&gt;main&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  The constraint that kept us honest
&lt;/h2&gt;

&lt;p&gt;Empty-cluster bootstrap is one command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl apply -k infra/&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;cluster&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/argocd/bootstrap
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That applies official Argo CD &lt;strong&gt;v3.5.2&lt;/strong&gt; &lt;code&gt;install.yaml&lt;/code&gt;, an AppProject, and a root Application. The root app points at &lt;code&gt;argocd/applications/infra&lt;/code&gt;, which owns:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the infra &lt;strong&gt;app-of-apps&lt;/strong&gt; (&lt;code&gt;infra/&amp;lt;cluster&amp;gt;&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;the Gateway&lt;/li&gt;
&lt;li&gt;CloudNativePG Postgres&lt;/li&gt;
&lt;li&gt;a dump client&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Enabling a component is adding a directory to &lt;code&gt;infra/&amp;lt;cluster&amp;gt;/kustomization.yaml&lt;/code&gt; and pushing. We did &lt;strong&gt;not&lt;/strong&gt; &lt;code&gt;kubectl apply&lt;/code&gt; Harbor, CSI, or runners “just this once.” When something was wrong, we fixed git or OpenBao, not the live object — except one-time secret material that cannot live in git.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl apply (once)
  └── Argo CD + AppProject + root Application
        └── applications/infra
              ├── on-prem-infra          → operators, storage, Harbor, ARC
              ├── infra-gateway          → Gateway API + TLS
              ├── general-postgres       → CNPG cluster
              └── general-postgres-dump  → dump job/client
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  How the repo is shaped
&lt;/h2&gt;

&lt;p&gt;One folder per component. Typical layout:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;infra/&amp;lt;cluster&amp;gt;/&amp;lt;component&amp;gt;/
  application.yaml      # Argo Application (Helm multi-source or Kustomize)
  values.yaml           # chart values, referenced as $values/...
  external-secret.yaml  # ESO → OpenBao → Kubernetes Secret
  kustomization.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Platform workloads (Postgres, dump) are &lt;strong&gt;sibling&lt;/strong&gt; Applications, not nested inside the infra tree. That keeps “cluster plumbing” separate from “data plane.”&lt;/p&gt;

&lt;p&gt;The AppProject lists every destination namespace and every Helm &lt;code&gt;repoURL&lt;/code&gt;. Miss one and Argo returns ComparisonError or permission denied. We hit that more than once when adding Harbor (public Harbor Helm repo) and extra runner namespaces.&lt;/p&gt;




&lt;h2&gt;
  
  
  Network first: VIP, DNS, and why pods cannot “just reach” the NAS
&lt;/h2&gt;

&lt;p&gt;MetalLB L2 advertises a small reserved range with &lt;code&gt;autoAssign: false&lt;/code&gt;. The Gateway VIP is a &lt;strong&gt;single pinned address&lt;/strong&gt; in that range. DNS A records for platform names must point there — not a jump host, not a tunnel endpoint. We learned that the hard way when Harbor’s registry returned HTTP 500 and S3 XML parse errors: the S3 hostname was resolving to the wrong box and serving HTML 404 instead of MinIO.&lt;/p&gt;

&lt;p&gt;TLS is Gateway API (NGINX Gateway Fabric) plus cert-manager &lt;strong&gt;Cloudflare DNS-01&lt;/strong&gt; for a wildcard on our public zone.&lt;/p&gt;

&lt;p&gt;Pods live on the cluster pod CIDR and &lt;strong&gt;do not SNAT&lt;/strong&gt; onto the LAN. The NAS must have a route back to that CIDR via the node IPs. If a CSI controller times out talking to the NAS API, it is almost always routing, not “the chart is wrong.” Node plugins for iSCSI/NFS already use &lt;code&gt;hostNetwork&lt;/code&gt; where the chart sets it. We did not flip the controller onto &lt;code&gt;hostNetwork&lt;/code&gt; as a shortcut.&lt;/p&gt;

&lt;p&gt;MinIO itself is not in-cluster. We published a Service + EndpointSlice to the NAS S3 port and an HTTPRoute for the S3 hostname. A subtle Gateway API rule: the HTTPRoute &lt;strong&gt;parent namespace must match the Gateway namespace&lt;/strong&gt;. A wrong parent left the route Progressing forever.&lt;/p&gt;




&lt;h2&gt;
  
  
  Secrets: OpenBao is the store, ESO is the only door
&lt;/h2&gt;

&lt;p&gt;OpenBao (Raft, Shamir &lt;strong&gt;5 shares / threshold 3&lt;/strong&gt;) is the secret engine. External Secrets Operator is the &lt;strong&gt;only&lt;/strong&gt; supported way to materialize Kubernetes Secrets.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;ClusterSecretStore&lt;/td&gt;
&lt;td&gt;a single cluster-scoped store&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;KV&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;secret/&lt;/code&gt; (v2)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Auth&lt;/td&gt;
&lt;td&gt;Kubernetes mount, dedicated ESO role&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Audience&lt;/td&gt;
&lt;td&gt;the in-cluster API server audience&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ESO SA&lt;/td&gt;
&lt;td&gt;the operator ServiceAccount in its namespace&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Path convention:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;secret/&amp;lt;env&amp;gt;/&amp;lt;name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Examples: CSI driver configs, Harbor admin/DB/S3, GitHub App credentials for ARC, DNS-01 token, Harbor pull secret for the dump image.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Never committed:&lt;/strong&gt; NAS API keys, SSH private keys, Harbor passwords, GitHub App PEMs, unseal shares, tokens.&lt;/p&gt;

&lt;h3&gt;
  
  
  Init, unseal, and a new Raft
&lt;/h3&gt;

&lt;p&gt;After a wipe, the Raft PVC is new. Old unseal keys are dead. We ran &lt;code&gt;bao operator init&lt;/code&gt;, stored the JSON offline, unsealed with three keys, enabled KV and Kubernetes auth, and bound an ESO role to the operator ServiceAccount.&lt;/p&gt;

&lt;p&gt;ESO then failed with &lt;strong&gt;403&lt;/strong&gt; on Kubernetes login until audience + role matched. Connection refused meant OpenBao was sealed or the pod was down — not an ESO bug.&lt;/p&gt;

&lt;h3&gt;
  
  
  Audit that the API will not let you enable
&lt;/h3&gt;

&lt;p&gt;We wanted file audit. &lt;code&gt;bao audit enable&lt;/code&gt; returned &lt;strong&gt;400&lt;/strong&gt; (declarative config owns audit devices). The working pattern is an HCL stanza in Helm values:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="n"&gt;audit&lt;/span&gt; &lt;span class="s2"&gt;"file"&lt;/span&gt; &lt;span class="s2"&gt;"file-audit"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;file_path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"/openbao/audit/audit.log"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OpenBao’s Helm chart uses &lt;strong&gt;OnDelete&lt;/strong&gt;. Changing the ConfigMap does &lt;strong&gt;not&lt;/strong&gt; roll the pod. Delete the OpenBao pod, wait for recreate, &lt;strong&gt;unseal again with the same keys&lt;/strong&gt;. Empty &lt;code&gt;bao audit list&lt;/code&gt; usually meant &lt;code&gt;options {}&lt;/code&gt; never made it into the running config.&lt;/p&gt;

&lt;p&gt;We created a human CLI user with an admin policy for day-2 work. Tokens stay out of git.&lt;/p&gt;




&lt;h2&gt;
  
  
  Storage: Longhorn, then TrueNAS CSI
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;StorageClass&lt;/th&gt;
&lt;th&gt;Backend&lt;/th&gt;
&lt;th&gt;Use&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;SSD Longhorn RWO&lt;/td&gt;
&lt;td&gt;Longhorn&lt;/td&gt;
&lt;td&gt;general RWO, OpenBao audit volume&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SSD iSCSI&lt;/td&gt;
&lt;td&gt;democratic-csi / TrueNAS iSCSI&lt;/td&gt;
&lt;td&gt;OpenBao Raft, CNPG&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HDD iSCSI&lt;/td&gt;
&lt;td&gt;democratic-csi / TrueNAS iSCSI&lt;/td&gt;
&lt;td&gt;Harbor PVCs, dump PVC&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HDD NFS&lt;/td&gt;
&lt;td&gt;democratic-csi / TrueNAS NFS&lt;/td&gt;
&lt;td&gt;shared / bulk HDD&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;CSI driver names must stay unique (one name per backend/protocol). Each chart uses &lt;code&gt;existingConfigSecret&lt;/code&gt;. ESO fills &lt;code&gt;driver-config-file.yaml&lt;/code&gt; from OpenBao. YAML &lt;strong&gt;spaces only&lt;/strong&gt; — tabs in an SSH &lt;code&gt;privateKey&lt;/code&gt; CrashLoop the driver.&lt;/p&gt;

&lt;h3&gt;
  
  
  StorageClass parameters are immutable
&lt;/h3&gt;

&lt;p&gt;We changed &lt;code&gt;fsType&lt;/code&gt; from &lt;code&gt;ext4&lt;/code&gt; to &lt;code&gt;xfs&lt;/code&gt; on the database class. Kubernetes rejected the patch. Delete the StorageClass, let Argo recreate it. Existing PVs keep the old parameters.&lt;/p&gt;

&lt;h3&gt;
  
  
  NAS 401
&lt;/h3&gt;

&lt;p&gt;HDD iSCSI CrashLooped with &lt;strong&gt;401 Invalid API key&lt;/strong&gt;. The key had been rotated or mistyped in OpenBao; it also showed up in driver logs (rotate immediately if that happens). After the Secret hash changed, we deleted the CSI pods so they remounted config.&lt;/p&gt;

&lt;h3&gt;
  
  
  The NFS bug that looks like a chart bug
&lt;/h3&gt;

&lt;p&gt;HDD NFS came up as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;initializing csi driver: undefined
Error: invalid csi driver: undefined
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The ExternalSecret was Ready. The Secret existed. Grepping the decoded Secret showed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: v1
kind: Secret
stringData:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We had stored a &lt;strong&gt;full Kubernetes Secret manifest&lt;/strong&gt; in OpenBao. ESO copies a &lt;strong&gt;property&lt;/strong&gt;. Democratic-csi reads a &lt;strong&gt;driver config file&lt;/strong&gt;. It expects a top-level &lt;code&gt;driver: freenas-nfs&lt;/code&gt; (or &lt;code&gt;freenas-iscsi&lt;/code&gt;). It does not understand &lt;code&gt;apiVersion: v1&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The fix is not in git. Unwrap the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# This is what the OpenBao property must contain.
# Not a Secret wrapper. No real hosts or keys.
&lt;/span&gt;&lt;span class="na"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;freenas-nfs&lt;/span&gt;
&lt;span class="na"&gt;instance_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
&lt;span class="na"&gt;httpConnection&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="c1"&gt;# host, apiKey — values live only in the secret store
&lt;/span&gt;&lt;span class="na"&gt;sshConnection&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="c1"&gt;# host, username, privateKey — same
&lt;/span&gt;&lt;span class="na"&gt;nfs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;shareHost&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;lt;nas-address&amp;gt;&lt;/span&gt;
  &lt;span class="c1"&gt;# datasetParentName, …
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bao kv put secret/&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;env&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;csi-nfs-config&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; \
  driver-config-file.yaml=@/tmp/nfs-driver.yaml

kubectl -n &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;csi-namespace&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; annotate externalsecret &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;nfs-config&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; \
  force-sync=&lt;span class="s2"&gt;"$(date +%s)"&lt;/span&gt; --overwrite
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Confirm the live Secret’s first key is &lt;code&gt;driver:&lt;/code&gt;, then delete the NFS CSI pods. If logs still show a timestamp from before the put, you are looking at a dead container.&lt;/p&gt;

&lt;p&gt;Also watch NFS &lt;code&gt;shareAllowedNetworks&lt;/code&gt;. An empty list can lock out both LAN and pod CIDR. You typically want the node/LAN range and, if mounts come from pods, the pod CIDR. The NAS still needs &lt;code&gt;zfs allow&lt;/code&gt; for the CSI dataset parent.&lt;/p&gt;




&lt;h2&gt;
  
  
  Postgres with CloudNativePG
&lt;/h2&gt;

&lt;p&gt;Order mattered: CSI SSD healthy → CNPG operator → cluster (Postgres 16.1, data/WAL on SSD iSCSI) → PgBouncer pooler → Harbor role/database.&lt;/p&gt;

&lt;p&gt;Apps connect through the in-cluster pooler Service.&lt;/p&gt;

&lt;p&gt;Harbor needs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a managed role (password from an ESO Secret)&lt;/li&gt;
&lt;li&gt;a &lt;code&gt;registry&lt;/code&gt; database (CNPG &lt;code&gt;Database&lt;/code&gt; CR)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When the Database CR never appeared, the cause was a &lt;strong&gt;kustomization referencing a file that did not exist&lt;/strong&gt;. Argo failed the whole app with a manifest generation error. Commenting or adding the missing resource unblocked sync.&lt;/p&gt;

&lt;p&gt;Harbor core then failed with Postgres &lt;code&gt;08P01&lt;/code&gt; / password failures until &lt;code&gt;ALTER USER&lt;/code&gt; matched the Secret, and then &lt;code&gt;CREATE DATABASE registry&lt;/code&gt; because the CR had not created it yet.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CNPG &lt;code&gt;volumeClaimTemplates&lt;/code&gt; are immutable.&lt;/strong&gt; Size or StorageClass changes need an operator replace strategy and usually PVC recreate. Plan storage before the first PVC.&lt;/p&gt;

&lt;p&gt;A dump client uses a private registry image and a PVC on HDD iSCSI. ImagePullBackOff was either “tag not in the registry yet” or a missing &lt;code&gt;dockerconfigjson&lt;/code&gt; pull Secret from OpenBao. The ExternalSecret maps username/password into a Docker config; the path name in OpenBao must match what ESO asks for.&lt;/p&gt;




&lt;h2&gt;
  
  
  Harbor and S3
&lt;/h2&gt;

&lt;p&gt;Harbor chart (1.19.x) with in-cluster Redis/Trivy, &lt;strong&gt;external&lt;/strong&gt; Postgres, &lt;strong&gt;S3&lt;/strong&gt; on the NAS via the Gateway hostname (dedicated bucket).&lt;/p&gt;

&lt;p&gt;HTTPRoute parent: the Gateway’s namespace.&lt;/p&gt;

&lt;p&gt;If &lt;code&gt;docker push&lt;/code&gt; returns 500 and registry logs talk about S3 XML, curl the S3 hostname from a node. You want S3 XML, not an HTML 404 from a reverse proxy in another network.&lt;/p&gt;




&lt;h2&gt;
  
  
  GitHub Actions runners (ARC)
&lt;/h2&gt;

&lt;p&gt;Controller &lt;code&gt;gha-runner-scale-set-controller&lt;/code&gt; &lt;strong&gt;0.14.1&lt;/strong&gt; in its own namespace.&lt;/p&gt;

&lt;p&gt;Two gotchas:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;CRDs.&lt;/strong&gt; The controller chart was installed with &lt;code&gt;skipCrds: true&lt;/code&gt;. Without a separate CRD Application, scale sets fail on missing &lt;code&gt;EphemeralRunnerSet&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;One controller ServiceAccount.&lt;/strong&gt; Every scale set must set &lt;code&gt;controllerServiceAccount.name&lt;/code&gt; to the &lt;strong&gt;actual&lt;/strong&gt; controller SA. A generated SA name looks fine until the listener cannot read the GitHub App Secret (&lt;code&gt;can-i&lt;/code&gt; is no; pods Pending “secret not found” even when the Secret exists).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We run several org scale sets (&lt;code&gt;minRunners: 0&lt;/code&gt;): work only appears when a job is queued. A listener should still exist once credentials and RBAC are correct. &lt;code&gt;runnerScaleSetName&lt;/code&gt; overrides keep &lt;code&gt;runs-on&lt;/code&gt; labels stable.&lt;/p&gt;




&lt;h2&gt;
  
  
  How we actually sequenced the empty cluster
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Apply Argo bootstrap from a jump host whose kubeconfig is &lt;strong&gt;this&lt;/strong&gt; cluster.&lt;/li&gt;
&lt;li&gt;Register the git repo (URL includes &lt;code&gt;.git&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Let the root app sync. Wait for CRDs/webhooks (MetalLB-style configs need skip-dry-run patterns).&lt;/li&gt;
&lt;li&gt;Confirm the Gateway VIP and DNS.&lt;/li&gt;
&lt;li&gt;Init / unseal OpenBao. Enable KV + Kubernetes auth + the ESO role.&lt;/li&gt;
&lt;li&gt;Put CSI and app secrets in OpenBao &lt;strong&gt;before&lt;/strong&gt; expecting ExternalSecrets to go Ready.&lt;/li&gt;
&lt;li&gt;NAS: API reachability from the pod CIDR, &lt;code&gt;zfs allow&lt;/code&gt;, iSCSI initiator IQNs.&lt;/li&gt;
&lt;li&gt;Enable components &lt;strong&gt;one line at a time&lt;/strong&gt; in &lt;code&gt;kustomization.yaml&lt;/code&gt;: MetalLB → Longhorn → cert-manager → Gateway → OpenBao → ESO → SSD CSI → CNPG → Postgres → HDD CSI → dump → Harbor → MinIO route → ARC.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;One change, sync, verify pods/PVCs, then the next. That sounds slow. It is faster than debugging five CrashLoops at once.&lt;/p&gt;




&lt;h2&gt;
  
  
  Day-2 rules we wrote down after we paid for them
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Do not “fix values to make it work”&lt;/strong&gt; without an explicit change. Prefer names and enable/disable lines. Drift from the pasted chart values is how you lose the next rebuild.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Helm OnDelete&lt;/strong&gt; (OpenBao): delete the pod and unseal. ConfigMaps lie until then.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AppProject&lt;/strong&gt; is part of the API surface. New namespace or chart repo = patch the project first.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Missing file in &lt;code&gt;resources:&lt;/code&gt;&lt;/strong&gt; fails the entire Application.&lt;/li&gt;
&lt;li&gt;CSI CrashLoop order: (1) Secret YAML parse / wrapper vs inner &lt;code&gt;driver:&lt;/code&gt;, (2) NAS 401, (3) timeout from the pod CIDR to the NAS.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rotate&lt;/strong&gt; anything that hit a log line or a chat paste: NAS API keys, SSH keys.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Adding the next component (the template we reuse)
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Create &lt;code&gt;infra/&amp;lt;cluster&amp;gt;/&amp;lt;name&amp;gt;/&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Add namespace + Helm repo to the AppProject.&lt;/li&gt;
&lt;li&gt;Add &lt;code&gt;- &amp;lt;name&amp;gt;&lt;/code&gt; to the infra &lt;code&gt;kustomization.yaml&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;If it needs a secret: ExternalSecret + OpenBao path — never the value in git.&lt;/li&gt;
&lt;li&gt;Push &lt;code&gt;main&lt;/code&gt;. Synced/Healthy before starting the next one.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;New ARC org: copy a runner folder, change &lt;strong&gt;names and &lt;code&gt;githubConfigUrl&lt;/code&gt; only&lt;/strong&gt;, same controller ServiceAccount.&lt;/p&gt;




&lt;h2&gt;
  
  
  What this rebuild proved
&lt;/h2&gt;

&lt;p&gt;GitOps is not “Argo exists.” GitOps is &lt;strong&gt;one manual apply&lt;/strong&gt;, secrets that are not in the repo, and the discipline to treat OpenBao payloads as part of the interface (inner YAML, not a Secret wrapper).&lt;/p&gt;

&lt;p&gt;The cluster is boring again: Gateway VIP, Longhorn, three CSI drivers, OpenBao + ESO, CNPG, Harbor on external PG + S3, MinIO HTTPRoute, ARC listeners. The interesting parts were routing, immutable StorageClasses, Raft unseal after wipe, and a CSI factory that printed &lt;code&gt;undefined&lt;/code&gt; because we stored the wrong document type.&lt;/p&gt;

&lt;p&gt;If you rebuild after a storage wipe, write the bootstrap order down &lt;strong&gt;before&lt;/strong&gt; you are tired. The next wipe will not wait for you to remember why S3 returned HTML.&lt;/p&gt;




</description>
      <category>kubernetes</category>
      <category>git</category>
      <category>docker</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Running a Live Media Monitoring Platform on Kubernetes</title>
      <dc:creator>S M Jamal Uddin AL Gilani</dc:creator>
      <pubDate>Sat, 05 Sep 2026 06:11:39 +0000</pubDate>
      <link>https://dev.to/jamal-gilani/running-a-live-media-monitoring-platform-on-kubernetes-3en6</link>
      <guid>https://dev.to/jamal-gilani/running-a-live-media-monitoring-platform-on-kubernetes-3en6</guid>
      <description>&lt;p&gt;Media monitoring sounds simple from the outside: watch TV channels, pull out mentions, show sentiment on a dashboard. Underneath, it's a real-time media pipeline — live UDP video feeds coming in continuously, AI models transcribing and analyzing them, and a production system that isn't allowed to just "restart and try again" when something breaks, because the broadcast doesn't pause for you.&lt;/p&gt;

&lt;p&gt;That's the infrastructure challenge behind &lt;a href="https://betacodespk.com/electronic-media-monitoring/" rel="noopener noreferrer"&gt;BetaMedia&lt;/a&gt;, Beta Codes' electronic media monitoring platform, and it's the project where I moved from managing container networking to owning a full Kubernetes-based microservices deployment end to end.&lt;/p&gt;

&lt;h2&gt;
  
  
  What BetaMedia Does
&lt;/h2&gt;

&lt;p&gt;BetaMedia is built to watch media so people don't have to — pulling in live TV broadcasts and digital media, then running them through AI to make them searchable and analyzable. On the product side that means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Live TV streaming and playback&lt;/strong&gt;, with clipping and archiving of past broadcasts&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sentiment and emotion analysis&lt;/strong&gt; across mentions, in real time&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Speech-to-text&lt;/strong&gt; for turning broadcast audio into searchable transcripts&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;OCR, ticker extraction, and "flasher" detection&lt;/strong&gt; for on-screen text, scrolling news tickers, and breaking-news banners&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Facial recognition&lt;/strong&gt; for tracking public figures across clips&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Customizable dashboards&lt;/strong&gt; built around KPIs like sentiment shifts and keyword frequency&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's used by broadcasters, government and policy units, regulators, and security teams who need to know what's being said about a brand, a policy, or an event, as it's being said — not the next morning.&lt;/p&gt;

&lt;p&gt;None of that AI output means anything if the pipeline feeding it drops frames, falls behind, or goes down. That's the part I own.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Core Challenge: Continuous Streams, Zero Room for Downtime
&lt;/h2&gt;

&lt;p&gt;Media monitoring is unlike a typical web app in one important way: &lt;strong&gt;the input never stops.&lt;/strong&gt; A broadcast doesn't wait for your deployment window. That shapes almost every infrastructure decision:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;UDP video streams have to be captured and handed off to processing continuously, not batched&lt;/li&gt;
&lt;li&gt;Deployments and updates need to happen without interrupting streams already in flight&lt;/li&gt;
&lt;li&gt;A single-service app isn't enough — ingestion, transcoding, and each AI module need to scale and fail independently&lt;/li&gt;
&lt;li&gt;Storage has to keep up with continuously growing video, transcripts, and clips&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Kubernetes as the Backbone
&lt;/h2&gt;

&lt;p&gt;BetaMedia runs as a set of microservices on Kubernetes — ingestion, transcoding, and each AI module (speech-to-text, OCR, facial recognition, sentiment analysis) deployed and scaled independently rather than bundled into one monolith. That separation matters here specifically because these services have very different resource profiles: transcoding is CPU/GPU-heavy and constant, while something like ticker extraction only needs to run against new segments as they arrive.&lt;/p&gt;

&lt;p&gt;Managing the cluster means keeping that mix of workloads healthy together — right-sizing resources per service, keeping pods scheduled sensibly across nodes, and making sure a spike in one AI module doesn't starve the ingestion pipeline feeding everything else.&lt;/p&gt;

&lt;h2&gt;
  
  
  Serving UDP Streams Into the Processing Pipeline
&lt;/h2&gt;

&lt;p&gt;Live TV feeds come in as UDP streams, which then have to be transcoded (FFmpeg) and routed into the application layer for AI processing. Getting this right in Kubernetes means building the networking and workflow so a stream goes from "raw broadcast feed" to "frames the AI services can consume" reliably and continuously — with the pipeline treated as a first-class, always-on system rather than a batch job that happens to run often.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deploying to Production Without Breaking the Stream
&lt;/h2&gt;

&lt;p&gt;"Streamline the deployment process without failure" is a simple sentence that hides a lot of constraints once you're running live infrastructure. It meant building workflows where:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Releases roll out predictably, with a clear path to roll back if something's wrong&lt;/li&gt;
&lt;li&gt;Deployments don't interrupt streams that are actively being ingested or processed&lt;/li&gt;
&lt;li&gt;The path from a code change to a running production service is a defined workflow, not a manual sequence of steps someone has to remember correctly every time&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Working closely with the production side of this — rather than handing off a build and hoping — is what turned deployments from a risk event into a routine one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Monitoring: Watching the Watchers
&lt;/h2&gt;

&lt;p&gt;A media monitoring platform that silently stops ingesting a channel is its own kind of failure — the dashboards look calm, but the data behind them just stopped. So monitoring here has to answer more than "is the pod up":&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Are streams actively being ingested, per channel/source?&lt;/li&gt;
&lt;li&gt;Are the AI processing microservices keeping up, or falling behind?&lt;/li&gt;
&lt;li&gt;Is storage growth on track, or about to become a problem?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Dashboards built around these questions turn silent pipeline stalls into visible, actionable alerts instead of a client noticing a gap in coverage first.&lt;/p&gt;

&lt;h2&gt;
  
  
  Data: Databases, S3, and a Lot of Microservices
&lt;/h2&gt;

&lt;p&gt;Behind the AI modules sits the less visible work: managing the databases behind transcripts, mentions, and metadata, and the S3-compatible object storage handling the growing archive of video and clips. With this many independent microservices, keeping data infrastructure consistent, backed up, and correctly connected to the right service is as much of the job as the Kubernetes layer itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  What This Project Taught Me
&lt;/h2&gt;

&lt;p&gt;BetaMedia taught me something different: how to run &lt;em&gt;many different services&lt;/em&gt;, with very different resource needs and failure modes, as one coherent, always-on system — where "always-on" isn't a nice-to-have; it's the actual product requirement.&lt;/p&gt;

&lt;p&gt;The two problems look similar from a distance — Kubernetes, monitoring, microservices — but the constraints that actually shape the architecture are completely different once you look closely. That's been one of the more useful lessons of doing DevOps across both.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I'm a DevOps Engineer at Beta Codes.pk, working on Kubernetes, GitOps, and infrastructure for AI platforms including BetaMedia and BetaVision. Find me on &lt;a href="https://linkedin.com/in/jamal-al-gillani" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; or check out my &lt;a href="https://jamal-uddin-1.github.io/portfolio" rel="noopener noreferrer"&gt;portfolio&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>microservices</category>
      <category>kubernetes</category>
      <category>socialmedia</category>
    </item>
    <item>
      <title>Scaling AI Surveillance to 400+ Sites: The DevOps Behind BetaVision</title>
      <dc:creator>S M Jamal Uddin AL Gilani</dc:creator>
      <pubDate>Fri, 04 Sep 2026 15:40:07 +0000</pubDate>
      <link>https://dev.to/jamal-gilani/scaling-ai-surveillance-to-400-sites-the-devops-behind-betavision-4l0d</link>
      <guid>https://dev.to/jamal-gilani/scaling-ai-surveillance-to-400-sites-the-devops-behind-betavision-4l0d</guid>
      <description>&lt;p&gt;Most DevOps write-ups talk about deploying &lt;em&gt;an&lt;/em&gt; application to &lt;em&gt;a&lt;/em&gt; cluster. This one is about deploying the same AI platform to &lt;strong&gt;hundreds of independent, physically separate sites&lt;/strong&gt; each with its own hardware, its own network, and its own failure modes and still being able to see all of them from one dashboard.&lt;/p&gt;

&lt;p&gt;That's the problem I work on as a DevOps Engineer at Beta Codes.pk, building the infrastructure behind &lt;a href="https://betacodespk.com/smart-surveillance/" rel="noopener noreferrer"&gt;BetaVision&lt;/a&gt;, our AI-powered smart surveillance platform for urban and organizational security.&lt;/p&gt;

&lt;h2&gt;
  
  
  What BetaVision Does
&lt;/h2&gt;

&lt;p&gt;BetaVision is an AI-driven surveillance platform built around continuous, automated monitoring rather than passive CCTV footage. On the product side, it combines:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;24/7 AI-driven monitoring&lt;/strong&gt; across critical infrastructure, public spaces, and high-risk areas&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Video analytics&lt;/strong&gt; for spotting suspicious activity and unusual patterns automatically&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;License plate recognition (LPR)&lt;/strong&gt; for traffic control, parking, and law-enforcement use cases&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Facial recognition&lt;/strong&gt; for identifying individuals of interest and managing access&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Real-time alerts&lt;/strong&gt; that notify security personnel the moment something needs attention&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;centralized command-and-control dashboard&lt;/strong&gt; giving a single, unified view across every connected feed&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;mobile app&lt;/strong&gt; for remote monitoring&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's aimed at city governments, law enforcement agencies, corporate security teams, event organizers, retailers, and smart-city / property developments — anywhere a lot of camera feeds need to become actionable intelligence instead of just recorded video. The platform is deployed on GPU-enabled client and government infrastructure, running object detection, facial recognition, and ANPR/LPR on live feeds, with results streamed back to a central production dashboard.&lt;/p&gt;

&lt;p&gt;The AI/ML side is only half the story. The harder, less glamorous half is: how do you take a platform like this and reliably run it on &lt;strong&gt;400 sites&lt;/strong&gt;, each behind different networks, different hardware, different connectivity — and still ship updates, catch failures, and keep every stream visible in real time?&lt;/p&gt;

&lt;p&gt;That's the part I own.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Core Challenge: One Codebase, Hundreds of Independent Deployments
&lt;/h2&gt;

&lt;p&gt;Every site runs its own instance of BetaVision — backend, frontend, and supporting services — on Docker containers, on-premise, on the client's own GPU hardware. That means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;400 separate deployment targets, not one cluster to scale horizontally&lt;/li&gt;
&lt;li&gt;No guarantee of stable public IPs or open inbound ports on client networks&lt;/li&gt;
&lt;li&gt;Updates that need to reach every site without 400 manual SSH sessions&lt;/li&gt;
&lt;li&gt;A central command-and-control dashboard that needs live visibility into sites it can't directly reach&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's how each of those gets solved.&lt;/p&gt;

&lt;h2&gt;
  
  
  Making 400 Private Networks Publicly Reachable
&lt;/h2&gt;

&lt;p&gt;Client sites are, by design, locked-down networks. We don't control their firewalls, and we can't always get inbound access. But the whole point of BetaVision is that streams and results need to be visible centrally, 24/7.&lt;/p&gt;

&lt;p&gt;The solution is &lt;strong&gt;FRP (Fast Reverse Proxy)&lt;/strong&gt;, running as a client on each site and a server on our side. Every site's containers only need to make an &lt;em&gt;outbound&lt;/em&gt; connection — no inbound firewall rules required on the client's end. FRP tunnels the stream back through, and we wrap every tunnel in TLS so nothing is exposed in plaintext across the public internet.&lt;/p&gt;

&lt;p&gt;This one decision is what turns "400 isolated on-prem boxes" into "400 endpoints visible from a single pane of glass."&lt;/p&gt;

&lt;h2&gt;
  
  
  Docker + Networking at Site Level
&lt;/h2&gt;

&lt;p&gt;Each site runs BetaVision's backend and frontend as Docker containers, with internal networks configured so services can talk to each other — the AI inference services, the API layer, the database layer, and the streaming layer all need to communicate reliably on-box before anything goes external through FRP.&lt;/p&gt;

&lt;p&gt;Multiply the usual "make sure your containers can talk to each other" problem by 400, across hardware you don't physically control, and debugging becomes as much about reproducibility as it is about the fix itself. A problem on site #217 needs to be diagnosable and fixable using the same playbook as site #12.&lt;/p&gt;

&lt;h2&gt;
  
  
  Automating 400 Pipelines Without Losing Control
&lt;/h2&gt;

&lt;p&gt;Manually deploying to 400 sites isn't a scaling problem, it's a guaranteed-to-fail problem. So the deployment pipeline is built on &lt;strong&gt;GitHub Actions&lt;/strong&gt;, with dedicated pipelines per site for backend and frontend releases.&lt;/p&gt;

&lt;p&gt;A few things matter more here than in a typical single-cluster CI/CD setup:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Release history has to be real, not aspirational.&lt;/strong&gt; With this many deployment targets, "what version is site X running right now" needs to be answerable instantly, not reconstructed from memory.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;One-click releases replace multi-step manual processes.&lt;/strong&gt; What used to be a manual, error-prone rollout became a single pipeline trigger — this matters even more at 400-site scale than it did rolling this pattern out internally at 10-microservice scale.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Failures need to be isolated.&lt;/strong&gt; A bad deploy to one site should never cascade or block releases to the other 399.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Monitoring: Seeing Problems Before Clients Report Them
&lt;/h2&gt;

&lt;p&gt;None of this matters if you find out about outages from a client phone call. Monitoring across this many independent deployments has to answer two different questions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Is each individual site healthy?&lt;/li&gt;
&lt;li&gt;Is the aggregate platform healthy?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We run a Prometheus, Grafana, and Loki stack for visibility and alerting, so incidents surface through dashboards and automated alerts instead of user reports. At single-cluster scale this is standard practice; at 400-site scale, it's the difference between catching a dead stream in minutes versus finding out days later.&lt;/p&gt;

&lt;h2&gt;
  
  
  Data: MinIO S3 and Databases, Per Site
&lt;/h2&gt;

&lt;p&gt;Each deployment needs its own storage and database layer — provisioned, backed up, and secured independently. We use MinIO S3 buckets for object storage and manage the database infrastructure per deployment, with backup and recovery built in from day one rather than bolted on after a data loss incident.&lt;/p&gt;

&lt;p&gt;Security runs through all of this, not around it — from access control down to how data moves off each site, aligned with our ISO 9001 and ISO 27001 certified information security standards.&lt;/p&gt;

&lt;h2&gt;
  
  
  From POC to Production, Repeatedly
&lt;/h2&gt;

&lt;p&gt;Before a site goes live, it usually starts as a proof of concept — deployed on a client's own GPU server, demoed live, sometimes directly to CIOs, under real production conditions. That means the deployment tooling has to work identically whether it's POC #1 or production site #380. There's no separate "demo mode" — if the automation only works for the polished cases, it doesn't scale to 400 real ones.&lt;/p&gt;

&lt;h2&gt;
  
  
  What This Actually Teaches You About DevOps
&lt;/h2&gt;

&lt;p&gt;Working on BetaVision reframed how I think about scale. It's not just "more replicas of the same thing." It's:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Reliability without central control&lt;/strong&gt; — most of your infrastructure lives on hardware and networks you don't own.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Observability as a first-class deliverable&lt;/strong&gt;, not an afterthought — you cannot manually check 400 sites.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automation as risk reduction&lt;/strong&gt;, not just convenience — every manual step is a failure point multiplied by 400.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you're building infrastructure for a platform that needs to run in many independent, disconnected environments rather than one big cluster, I'd genuinely love to compare notes — feel free to reach out.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I'm a DevOps Engineer at Beta Codes.pk, working on Kubernetes, GitOps, and infrastructure for AI platforms deployed across hundreds of sites. Find me on &lt;a href="https://linkedin.com/in/jamal-al-gillani" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; or check out my &lt;a href="https://jamal-uddin-1.github.io/portfolio" rel="noopener noreferrer"&gt;portfolio&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>kubernetes</category>
      <category>docker</category>
      <category>cicd</category>
    </item>
    <item>
      <title>Hub-and-Spoke Kubernetes: Building a Multi-Cluster RKE2 Platform with HAProxy, Keepalived &amp; Centralized Operations</title>
      <dc:creator>S M Jamal Uddin AL Gilani</dc:creator>
      <pubDate>Wed, 02 Sep 2026 07:05:10 +0000</pubDate>
      <link>https://dev.to/jamal-gilani/hub-and-spoke-kubernetes-building-a-multi-cluster-rke2-platform-with-haproxy-keepalived--5ba9</link>
      <guid>https://dev.to/jamal-gilani/hub-and-spoke-kubernetes-building-a-multi-cluster-rke2-platform-with-haproxy-keepalived--5ba9</guid>
      <description>&lt;p&gt;&lt;strong&gt;The Hub-and-Spoke Model&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Instead of duplicating monitoring stacks, container registries, secret managers, and GitOps controllers in every cluster, we run them once in a central &lt;strong&gt;hub&lt;/strong&gt; cluster and connect all &lt;strong&gt;spoke&lt;/strong&gt; clusters back to it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdptcso9ftt377yuvdhxo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdptcso9ftt377yuvdhxo.png" alt="Image description1" width="799" height="482"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Hub-and-Spoke?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Without it:&lt;/strong&gt; Every cluster runs its own Prometheus, Grafana, Loki, ArgoCD, Harbor, and Vault. That's 4× the infrastructure, 4× the maintenance, 4× the dashboards to check, and zero correlation between clusters.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;With it:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Centralized monitoring&lt;/strong&gt; — One Grafana, one set of dashboards. Spoke clusters ship metrics (via remote-write Prometheus) and logs (via Promtail → central Loki) to the hub. You see all clusters in one place.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Single container registry&lt;/strong&gt; — Harbor runs in the hub. All spoke clusters pull images from one place. One vulnerability scan covers everything.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unified secrets management&lt;/strong&gt; — Vault in the hub, with agents or sidecar injectors in each spoke. Rotate a secret once, it propagates everywhere.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitOps from one control plane&lt;/strong&gt; — ArgoCD in the hub manages deployments across all spoke clusters. One PR, one review, deploys to the right cluster.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Cluster Inventory
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Cluster&lt;/th&gt;
&lt;th&gt;Role&lt;/th&gt;
&lt;th&gt;Masters&lt;/th&gt;
&lt;th&gt;Workers&lt;/th&gt;
&lt;th&gt;Shared Services&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Hub (Internal Tools)&lt;/td&gt;
&lt;td&gt;Central operations&lt;/td&gt;
&lt;td&gt;3 × (8C/16G/300G)&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Grafana, Prometheus, Loki, ArgoCD, Harbor, Vault&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Spoke A&lt;/td&gt;
&lt;td&gt;Application workloads&lt;/td&gt;
&lt;td&gt;3 × (8C/16G/300G)&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;Promtail, Prometheus (remote-write), Vault agent&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Spoke B&lt;/td&gt;
&lt;td&gt;Application workloads&lt;/td&gt;
&lt;td&gt;3 × (8C/16G/300G)&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;Same as Spoke A&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Spoke C&lt;/td&gt;
&lt;td&gt;Application workloads&lt;/td&gt;
&lt;td&gt;3 × (8C/16G/300G)&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;Same as Spoke A&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Each cluster also has &lt;strong&gt;2 HAProxy nodes&lt;/strong&gt; (1C/2G/30G each) for load balancing.&lt;/p&gt;




&lt;h2&gt;
  
  
  Architecture of a Single Cluster
&lt;/h2&gt;

&lt;p&gt;Every cluster — hub or spoke — follows the same HA skeleton: a floating VIP in front of two HAProxy nodes, three masters running the control plane, and a data-plane tier of workers. The two diagrams below are the actual topology diagrams I drew while planning this, with every project/cluster name scrubbed out.&lt;/p&gt;

&lt;h3&gt;
  
  
  Hub Cluster Layout
&lt;/h3&gt;

&lt;p&gt;The hub only needs to run shared tooling for one "tenant" (itself), so it gets a single worker node. Masters pick up the slack, once the &lt;code&gt;NoSchedule&lt;/code&gt; taint is lifted (more on that later).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F48raua1wmiz12na0ygcz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F48raua1wmiz12na0ygcz.png" alt="Image description2" width="800" height="965"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Spoke Cluster Layout
&lt;/h3&gt;

&lt;p&gt;Spokes carry real application traffic, so they get more workers &lt;strong&gt;and&lt;/strong&gt; a MetalLB address pool for &lt;code&gt;LoadBalancer&lt;/code&gt;-type Services — something the hub doesn't need since its own services are exposed through Ingress. That extra range pushes the LB tier and masters a bit further up the subnet compared to the hub.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3xxuv3uzz801vy8tf3hh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3xxuv3uzz801vy8tf3hh.png" alt="Image description3" width="800" height="967"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;There are &lt;strong&gt;3 spoke clusters&lt;/strong&gt; in this platform, and all three are byte-for-byte identical in topology — they only differ in the subnet octet (&lt;code&gt;192.168.X.0/24&lt;/code&gt;) and hostnames. I'm showing one generic template instead of three near-duplicate diagrams:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Spoke&lt;/th&gt;
&lt;th&gt;Subnet (anonymized)&lt;/th&gt;
&lt;th&gt;Masters&lt;/th&gt;
&lt;th&gt;Workers&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Spoke A&lt;/td&gt;
&lt;td&gt;&lt;code&gt;192.168.11.0/24&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Spoke B&lt;/td&gt;
&lt;td&gt;&lt;code&gt;192.168.12.0/24&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Spoke C&lt;/td&gt;
&lt;td&gt;&lt;code&gt;192.168.13.0/24&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;How HA works:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Master failure:&lt;/strong&gt; If one master dies, the other two still have etcd quorum. The API server stays up.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Load balancer failure:&lt;/strong&gt; If haproxy-01 dies, Keepalived moves the VIP to haproxy-02 within ~4 seconds.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;kubectl never breaks:&lt;/strong&gt; It always points at the VIP, which always points at a healthy load balancer, which always routes to a healthy master.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  IP Allocation Scheme
&lt;/h2&gt;

&lt;p&gt;The hub and the spokes use slightly different offsets, because spokes reserve a block for MetalLB and the hub doesn't. Only the subnet octet (&lt;code&gt;x&lt;/code&gt; / &lt;code&gt;X&lt;/code&gt;) changes between clusters of the same type.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hub cluster&lt;/strong&gt; (&lt;code&gt;192.168.x.0/24&lt;/code&gt;):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Range&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;.1 – .39&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Network infrastructure (reserved)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;.40 – .49&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;HAProxy load balancers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;.50 – .59&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Master nodes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;.60 – .99&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Worker nodes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;.100&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Floating VIP&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Node&lt;/th&gt;
&lt;th&gt;IP&lt;/th&gt;
&lt;th&gt;Specs&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;haproxy-01&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.40&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;1C / 2G / 30G&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;haproxy-02&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.41&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;1C / 2G / 30G&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;master-01&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.50&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;8C / 16G / 300G&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;master-02&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.51&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;8C / 16G / 300G&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;master-03&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.52&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;8C / 16G / 300G&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;worker-01&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.60&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;As needed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;VIP&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.100&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Floating&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Spoke cluster&lt;/strong&gt; (&lt;code&gt;192.168.X.0/24&lt;/code&gt;, X = per-spoke octet):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Range&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;.1 – .50&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Network infrastructure (reserved)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;.51 – .59&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;MetalLB address pool&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;.60 – .69&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;HAProxy load balancers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;.70 – .79&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Master nodes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;.80 – .99&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Worker nodes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;.100&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Floating VIP&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Node&lt;/th&gt;
&lt;th&gt;IP&lt;/th&gt;
&lt;th&gt;Specs&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;haproxy-01&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.60&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;1C / 2G / 30G&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;haproxy-02&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.61&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;1C / 2G / 30G&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;master-01&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.70&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;8C / 16G / 300G&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;master-02&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.71&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;8C / 16G / 300G&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;master-03&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.72&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;8C / 16G / 300G&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;worker-01 … worker-08&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;.80&lt;/code&gt; – &lt;code&gt;.87&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;As needed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;VIP&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.100&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Floating&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;The hub cluster uses only worker-01 (&lt;code&gt;.60&lt;/code&gt;). Spoke clusters use workers 01–08 (&lt;code&gt;.80&lt;/code&gt;–&lt;code&gt;.87&lt;/code&gt;) plus the MetalLB pool for &lt;code&gt;LoadBalancer&lt;/code&gt; services.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;For each cluster, generate a unique token:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;openssl rand -hex 32
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Each cluster gets its own token.&lt;/strong&gt; Don't reuse tokens across clusters.&lt;/p&gt;




&lt;h2&gt;
  
  
  Phase 1: Preparing the Nodes
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Run on:&lt;/strong&gt; Every master and worker node (NOT the haproxy nodes).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  1.1 — System Update
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo apt update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; sudo apt dist-upgrade -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  1.2 — Host Resolution
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo tee -a /etc/hosts &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s1"&gt;'EOF'&lt;/span&gt;
&lt;span class="c"&gt;# RKE2 Cluster Nodes&lt;/span&gt;
192.168.x.50   master-01
192.168.x.51   master-02
192.168.x.52   master-03
192.168.x.60   worker-01
&lt;span class="c"&gt;# Add remaining workers as needed&lt;/span&gt;
192.168.x.40   haproxy-01
192.168.x.41   haproxy-02
EOF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  1.3 — Disable Swap
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo swapoff -a
sudo sed -i &lt;span class="s1"&gt;'/\sswap\s/ s/^/#/'&lt;/span&gt; /etc/fstab
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;kubelet won't start with swap enabled. Kubernetes does its own memory management — swap adds unpredictable latency.&lt;/p&gt;

&lt;h3&gt;
  
  
  1.4 — Kernel Modules
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo tee /etc/modules-load.d/k8s.conf &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s1"&gt;'EOF'&lt;/span&gt;
br_netfilter
overlay
EOF

sudo modprobe overlay
sudo modprobe br_netfilter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;overlay&lt;/code&gt; is required by containerd. &lt;code&gt;br_netfilter&lt;/code&gt; makes bridged traffic visible to iptables for pod networking.&lt;/p&gt;

&lt;h3&gt;
  
  
  1.5 — Network Parameters
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo tee /etc/sysctl.d/99-rke2.conf &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s1"&gt;'EOF'&lt;/span&gt;
net.bridge.bridge-nf-call-iptables  &lt;span class="o"&gt;=&lt;/span&gt; 1
net.bridge.bridge-nf-call-ip6tables &lt;span class="o"&gt;=&lt;/span&gt; 1
net.ipv4.ip_forward                 &lt;span class="o"&gt;=&lt;/span&gt; 1
EOF

sudo sysctl --system
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Without &lt;code&gt;ip_forward&lt;/code&gt;, packets between pods on different nodes stop at the node boundary.&lt;/p&gt;

&lt;h3&gt;
  
  
  1.6 — Disable UFW
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo systemctl stop ufw
sudo systemctl disable ufw
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  1.7 — Required Packages
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo apt install -y curl wget tar nfs-common open-iscsi lsscsi sg3-utils
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Package&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;nfs-common&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Mount NFS persistent volumes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;open-iscsi&lt;/code&gt;, &lt;code&gt;lsscsi&lt;/code&gt;, &lt;code&gt;sg3-utils&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Block storage (Longhorn)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  1.8 — Enable iSCSI
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo systemctl &lt;span class="nb"&gt;enable&lt;/span&gt; iscsid
sudo systemctl start iscsid
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  1.9 — Reboot
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo reboot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify after reboot:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;lsmod &lt;span class="o"&gt;|&lt;/span&gt; grep br_netfilter        &lt;span class="c"&gt;# ✓ loaded&lt;/span&gt;
sysctl net.ipv4.ip_forward       &lt;span class="c"&gt;# ✓ = 1&lt;/span&gt;
free -h                          &lt;span class="c"&gt;# ✓ swap = 0&lt;/span&gt;
systemctl is-active iscsid       &lt;span class="c"&gt;# ✓ active&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;✅ Complete on ALL master + worker nodes before Phase 2.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Phase 2: HAProxy &amp;amp; Keepalived
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Run on:&lt;/strong&gt; haproxy-01 (.40) first, then haproxy-02 (.41).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  2.1 — Install
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo apt update
sudo apt install -y haproxy keepalived curl
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2.2 — Sysctl Tuning
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo tee /etc/sysctl.d/99-lb-tuning.conf &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s1"&gt;'EOF'&lt;/span&gt;
net.ipv4.ip_nonlocal_bind &lt;span class="o"&gt;=&lt;/span&gt; 1
net.core.somaxconn &lt;span class="o"&gt;=&lt;/span&gt; 65535
EOF

sudo sysctl --system
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;ip_nonlocal_bind&lt;/code&gt; lets HAProxy bind to the VIP before Keepalived assigns it. Without this, HAProxy crashes on startup when the VIP is on the other node.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.3 — File Descriptor Limits
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo mkdir -p /etc/systemd/system/haproxy.service.d

sudo tee /etc/systemd/system/haproxy.service.d/limits.conf &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s1"&gt;'EOF'&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;Service&lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="nv"&gt;LimitNOFILE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;100000
EOF

sudo systemctl daemon-reload
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2.4 — HAProxy Configuration
&lt;/h3&gt;

&lt;p&gt;Find your interface:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ip -4 addr show &lt;span class="o"&gt;|&lt;/span&gt; grep &lt;span class="s2"&gt;"192.168.x.40"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Deploy the config:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo tee /etc/haproxy/haproxy.cfg &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s1"&gt;'EOF'&lt;/span&gt;
global
    log /dev/log local0
    log /dev/log local1 notice
    chroot /var/lib/haproxy
    user haproxy
    group haproxy
    daemon
    maxconn 30000

defaults
    log     global
    mode    tcp
    option  tcplog
    option  dontlognull
    option  tcpka
    timeout connect 5s
    timeout client  60s
    timeout server  60s
    retries 3

listen stats
    &lt;span class="nb"&gt;bind&lt;/span&gt; 127.0.0.1:8404
    mode http
    stats &lt;span class="nb"&gt;enable&lt;/span&gt;
    stats uri /stats
    stats refresh 10s

frontend rke2_registration_9345
    &lt;span class="nb"&gt;bind&lt;/span&gt; 192.168.x.100:9345
    maxconn 2500
    default_backend rke2_servers_9345

backend rke2_servers_9345
    balance roundrobin
    option tcp-check
    default-server inter 2s fall 2 rise 3 slowstart 10s maxconn 1000
    server master1 192.168.x.50:9345 check
    server master2 192.168.x.51:9345 check
    server master3 192.168.x.52:9345 check

frontend kubernetes_api_6443
    &lt;span class="nb"&gt;bind&lt;/span&gt; 192.168.x.100:6443
    maxconn 26000
    default_backend kube_apiservers_6443

backend kube_apiservers_6443
    balance roundrobin
    option tcp-check
    default-server inter 2s fall 2 rise 3 slowstart 15s maxconn 10000
    server master1 192.168.x.50:6443 check
    server master2 192.168.x.51:6443 check
    server master3 192.168.x.52:6443 check
EOF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two frontends bind to the VIP: port &lt;strong&gt;9345&lt;/strong&gt; (node registration) and port &lt;strong&gt;6443&lt;/strong&gt; (Kubernetes API). Both round-robin across the 3 masters with health checks every 2 seconds.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.5 — Start HAProxy
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo systemctl &lt;span class="nb"&gt;enable&lt;/span&gt; haproxy
sudo systemctl start haproxy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2.6 — Health Check Script
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo tee /etc/keepalived/check_haproxy.sh &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s1"&gt;'SCRIPT'&lt;/span&gt;
&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
systemctl is-active --quiet haproxy &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;exit&lt;/span&gt; 1
curl -sf http://127.0.0.1:8404/stats &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/dev/null &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;exit&lt;/span&gt; 1
&lt;span class="nb"&gt;exit&lt;/span&gt; 0
SCRIPT

sudo chmod 755 /etc/keepalived/check_haproxy.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keepalived runs this every 2 seconds. Non-zero exit = HAProxy is dead = VIP moves to backup.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.7 — Keepalived Configuration
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;On haproxy-01 (PRIMARY):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;INTERFACE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"eth0"&lt;/span&gt;   &lt;span class="c"&gt;# Replace with your actual interface&lt;/span&gt;

sudo tee /etc/keepalived/keepalived.conf &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; EOF
global_defs &lt;span class="o"&gt;{&lt;/span&gt;
    router_id HAPROXY_01
    enable_script_security
    script_user root
&lt;span class="o"&gt;}&lt;/span&gt;

vrrp_script chk_haproxy &lt;span class="o"&gt;{&lt;/span&gt;
    script &lt;span class="s2"&gt;"/etc/keepalived/check_haproxy.sh"&lt;/span&gt;
    interval 2
    fall 2
    rise 2
    timeout 2
&lt;span class="o"&gt;}&lt;/span&gt;

vrrp_instance VI_RKE2 &lt;span class="o"&gt;{&lt;/span&gt;
    state MASTER
    interface &lt;span class="nv"&gt;${INTERFACE}&lt;/span&gt;
    virtual_router_id 51
    priority 120
    advert_int 1

    unicast_src_ip 192.168.x.40
    unicast_peer &lt;span class="o"&gt;{&lt;/span&gt;
        192.168.x.41
    &lt;span class="o"&gt;}&lt;/span&gt;

    authentication &lt;span class="o"&gt;{&lt;/span&gt;
        auth_type PASS
        auth_pass &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;your-vrrp-password&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    virtual_ipaddress &lt;span class="o"&gt;{&lt;/span&gt;
        192.168.x.100/24
    &lt;span class="o"&gt;}&lt;/span&gt;

    track_script &lt;span class="o"&gt;{&lt;/span&gt;
        chk_haproxy
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
EOF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How VRRP failover works:&lt;/strong&gt; Both nodes send heartbeats. The higher-priority node (120) holds the VIP. If the primary stops advertising — crash, network failure, failed health check — the backup (priority 110) takes ownership of the VIP by adding it to its own interface. Recovery is automatic when the primary comes back.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Multi-cluster note:&lt;/strong&gt; Each cluster needs a unique &lt;code&gt;virtual_router_id&lt;/code&gt;. If all clusters share the same L2 network, use 51 for the hub, 52 for Spoke A, 53 for Spoke B, 54 for Spoke C.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  2.8 — Start Keepalived
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo systemctl &lt;span class="nb"&gt;enable&lt;/span&gt; keepalived
sudo systemctl start keepalived
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2.9 — Repeat on haproxy-02
&lt;/h3&gt;

&lt;p&gt;Same steps, but in the Keepalived config:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="n"&gt;router_id&lt;/span&gt; &lt;span class="no"&gt;HAPROXY_02&lt;/span&gt;
&lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="no"&gt;BACKUP&lt;/span&gt;
&lt;span class="n"&gt;priority&lt;/span&gt; &lt;span class="mi"&gt;110&lt;/span&gt;
&lt;span class="n"&gt;unicast_src_ip&lt;/span&gt; &lt;span class="mf"&gt;192.168&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;41&lt;/span&gt;
&lt;span class="n"&gt;unicast_peer&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="mf"&gt;192.168&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;40&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2.10 — Verify
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo systemctl is-active haproxy
sudo systemctl is-active keepalived
curl -s http://127.0.0.1:8404/stats &lt;span class="o"&gt;|&lt;/span&gt; head -5
ip addr show &lt;span class="o"&gt;|&lt;/span&gt; grep 192.168.x.100   &lt;span class="c"&gt;# VIP visible on primary&lt;/span&gt;
ping -c 2 192.168.x.100             &lt;span class="c"&gt;# Reachable from the network&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;✅ Load balancer tier ready.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Phase 3: Bootstrapping RKE2
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Strictly sequential.&lt;/strong&gt; master-01 must be fully running before touching master-02.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  3.1 — First Master (.50)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo mkdir -p /etc/rancher/rke2

curl -sfL https://get.rke2.io &lt;span class="o"&gt;|&lt;/span&gt; \
  sudo &lt;span class="nv"&gt;INSTALL_RKE2_TYPE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"server"&lt;/span&gt; \
  &lt;span class="nv"&gt;INSTALL_RKE2_VERSION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"v1.35.2+rke2r1"&lt;/span&gt; sh -
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  First Master Config
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo tee /etc/rancher/rke2/config.yaml &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s1"&gt;'EOF'&lt;/span&gt;
token: &lt;span class="s2"&gt;"&amp;lt;your-cluster-token&amp;gt;"&lt;/span&gt;

tls-san:
  - &lt;span class="s2"&gt;"192.168.x.50"&lt;/span&gt;
  - &lt;span class="s2"&gt;"192.168.x.51"&lt;/span&gt;
  - &lt;span class="s2"&gt;"192.168.x.52"&lt;/span&gt;
  - &lt;span class="s2"&gt;"192.168.x.100"&lt;/span&gt;
cni: cilium
disable-cloud-controller: &lt;span class="kc"&gt;true&lt;/span&gt;

disable: rke2-ingress-nginx

etcd-expose-metrics: &lt;span class="kc"&gt;true&lt;/span&gt;
etcd-snapshot-schedule-cron: &lt;span class="s2"&gt;"0 2 * * *"&lt;/span&gt;
etcd-snapshot-retention: 7
etcd-snapshot-compress: &lt;span class="kc"&gt;true&lt;/span&gt;
etcd-s3: &lt;span class="kc"&gt;true&lt;/span&gt;
etcd-s3-config-secret: rke2-etcd-snapshot-s3-config

etcd-arg:
  - &lt;span class="s2"&gt;"heartbeat-interval=200"&lt;/span&gt;
  - &lt;span class="s2"&gt;"election-timeout=2000"&lt;/span&gt;

kube-apiserver-arg:
  - &lt;span class="s2"&gt;"audit-log-maxage=30"&lt;/span&gt;
  - &lt;span class="s2"&gt;"audit-log-maxbackup=10"&lt;/span&gt;
  - &lt;span class="s2"&gt;"audit-log-maxsize=100"&lt;/span&gt;
  - &lt;span class="s2"&gt;"audit-log-mode=blocking"&lt;/span&gt;
  - &lt;span class="s2"&gt;"request-timeout=120s"&lt;/span&gt;
  - &lt;span class="s2"&gt;"default-not-ready-toleration-seconds=120"&lt;/span&gt;
  - &lt;span class="s2"&gt;"default-unreachable-toleration-seconds=120"&lt;/span&gt;
  - &lt;span class="s2"&gt;"event-ttl=2h"&lt;/span&gt;

kube-controller-manager-arg:
  - &lt;span class="s2"&gt;"terminated-pod-gc-threshold=200"&lt;/span&gt;
  - &lt;span class="s2"&gt;"bind-address=0.0.0.0"&lt;/span&gt;

kube-scheduler-arg:
  - &lt;span class="s2"&gt;"bind-address=0.0.0.0"&lt;/span&gt;

kube-proxy-arg:
  - &lt;span class="s2"&gt;"metrics-bind-address=0.0.0.0"&lt;/span&gt;

node-taint:
  - &lt;span class="s2"&gt;"node-role.kubernetes.io/control-plane:NoSchedule"&lt;/span&gt;
EOF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Key settings explained:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Setting&lt;/th&gt;
&lt;th&gt;Why&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;token&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Shared secret for cluster join authentication&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;tls-san&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;All master IPs + VIP in the API server's TLS cert&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;disable: rke2-ingress-nginx&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Install your own ingress controller instead&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;etcd-snapshot-*&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Automated daily backups, compressed, keep 7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;node-taint: NoSchedule&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Keep workloads off masters&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;bind-address=0.0.0.0&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Expose metrics for Prometheus scraping&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;CNI is left as default (Canal).&lt;/strong&gt; Add &lt;code&gt;cni: calico&lt;/code&gt; or &lt;code&gt;cni: cilium&lt;/code&gt; based on your needs.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Start and Wait
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo systemctl &lt;span class="nb"&gt;enable&lt;/span&gt; rke2-server.service
sudo systemctl start rke2-server.service

&lt;span class="c"&gt;# Watch logs (takes 2-5 min)&lt;/span&gt;
sudo journalctl -u rke2-server -f

&lt;span class="c"&gt;# Wait for registration port&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; ! sudo ss -tlnp &lt;span class="o"&gt;|&lt;/span&gt; grep -q &lt;span class="s1"&gt;':9345'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Waiting for port 9345..."&lt;/span&gt;
  sleep 10
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Ready for additional masters"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Verify and Set Up kubectl
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo /var/lib/rancher/rke2/bin/kubectl \
  --kubeconfig /etc/rancher/rke2/rke2.yaml get nodes

&lt;span class="c"&gt;# Set up shortcuts&lt;/span&gt;
cat &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.bashrc &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s1"&gt;'EOF'&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$PATH&lt;/span&gt;:/var/lib/rancher/rke2/bin
&lt;span class="nb"&gt;source&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;kubectl completion bash&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;alias&lt;/span&gt; &lt;span class="nv"&gt;k&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;kubectl
complete -F __start_kubectl k
EOF

mkdir -p ~/.kube
sudo cp /etc/rancher/rke2/rke2.yaml ~/.kube/config
sudo chown &lt;span class="nv"&gt;$(&lt;/span&gt;id -u&lt;span class="o"&gt;)&lt;/span&gt;:&lt;span class="nv"&gt;$(&lt;/span&gt;id -g&lt;span class="o"&gt;)&lt;/span&gt; ~/.kube/config
chmod 600 ~/.kube/config
&lt;span class="nb"&gt;source&lt;/span&gt; ~/.bashrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  3.2 — Additional Masters (.51, .52)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo mkdir -p /etc/rancher/rke2

curl -sfL https://get.rke2.io &lt;span class="o"&gt;|&lt;/span&gt; \
  sudo &lt;span class="nv"&gt;INSTALL_RKE2_TYPE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"server"&lt;/span&gt; \
  &lt;span class="nv"&gt;INSTALL_RKE2_VERSION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"v1.35.2+rke2r1"&lt;/span&gt; sh -
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The config is identical to the first master &lt;strong&gt;plus one line at the top:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo tee /etc/rancher/rke2/config.yaml &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s1"&gt;'EOF'&lt;/span&gt;
server: &lt;span class="s2"&gt;"https://192.168.x.100:9345"&lt;/span&gt;
token: &lt;span class="s2"&gt;"&amp;lt;your-cluster-token&amp;gt;"&lt;/span&gt;

tls-san:
  - &lt;span class="s2"&gt;"192.168.x.50"&lt;/span&gt;
  - &lt;span class="s2"&gt;"192.168.x.51"&lt;/span&gt;
  - &lt;span class="s2"&gt;"192.168.x.52"&lt;/span&gt;
  - &lt;span class="s2"&gt;"192.168.x.100"&lt;/span&gt;

&lt;span class="c"&gt;# ... rest identical to first master config ...&lt;/span&gt;

node-taint:
  - &lt;span class="s2"&gt;"node-role.kubernetes.io/control-plane:NoSchedule"&lt;/span&gt;
EOF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;server:&lt;/code&gt; line is the only difference — it tells this node to &lt;strong&gt;join&lt;/strong&gt; the existing cluster through the VIP instead of bootstrapping a new one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo systemctl &lt;span class="nb"&gt;enable&lt;/span&gt; rke2-server.service
sudo systemctl start rke2-server.service
sudo journalctl -u rke2-server -f
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Wait for &lt;code&gt;Ready&lt;/code&gt;, then repeat for master-03. After all three:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;NAME        STATUS   ROLES                       AGE
master-01   Ready    control-plane,etcd,master   10m
master-02   Ready    control-plane,etcd,master   5m
master-03   Ready    control-plane,etcd,master   2m
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  3.3 — Worker Nodes
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo mkdir -p /etc/rancher/rke2

curl -sfL https://get.rke2.io &lt;span class="o"&gt;|&lt;/span&gt; \
  sudo &lt;span class="nv"&gt;INSTALL_RKE2_TYPE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"agent"&lt;/span&gt; \
  &lt;span class="nv"&gt;INSTALL_RKE2_VERSION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"v1.35.2+rke2r1"&lt;/span&gt; sh -
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: &lt;strong&gt;&lt;code&gt;agent&lt;/code&gt;&lt;/strong&gt; not &lt;code&gt;server&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo tee /etc/rancher/rke2/config.yaml &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s1"&gt;'EOF'&lt;/span&gt;
server: &lt;span class="s2"&gt;"https://192.168.x.100:9345"&lt;/span&gt;
token: &lt;span class="s2"&gt;"&amp;lt;your-cluster-token&amp;gt;"&lt;/span&gt;

disable:
  - rke2-ingress-nginx

kube-proxy-arg:
  - &lt;span class="s2"&gt;"metrics-bind-address=0.0.0.0"&lt;/span&gt;
EOF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo systemctl &lt;span class="nb"&gt;enable&lt;/span&gt; rke2-agent.service
sudo systemctl start rke2-agent.service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Repeat for all workers. Spoke clusters get 8 workers (.60–.67), the hub gets 1 worker (.60).&lt;/p&gt;




&lt;h2&gt;
  
  
  Connecting the Spokes to the Hub
&lt;/h2&gt;

&lt;p&gt;Once all clusters are running, the hub-and-spoke connectivity looks like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9b69tq9ycupo5wj0phvg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9b69tq9ycupo5wj0phvg.png" alt="Image description4" width="800" height="535"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How Each Service Connects
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Prometheus (Metrics):&lt;/strong&gt;&lt;br&gt;
Each spoke cluster runs its own Prometheus instance, but instead of storing metrics locally, it uses &lt;code&gt;remote_write&lt;/code&gt; to push them to the hub's central Prometheus. The hub's Grafana queries the central Prometheus for dashboards across all clusters.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Loki (Logs):&lt;/strong&gt;&lt;br&gt;
Each spoke cluster runs Promtail as a DaemonSet. Promtail ships container logs to the hub's Loki endpoint. In Grafana, you can filter logs by &lt;code&gt;cluster&lt;/code&gt;, &lt;code&gt;namespace&lt;/code&gt;, and &lt;code&gt;pod&lt;/code&gt; — all from one place.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ArgoCD (GitOps):&lt;/strong&gt;&lt;br&gt;
ArgoCD runs in the hub and registers each spoke cluster as a target. Application manifests live in Git. A PR merge triggers ArgoCD to sync the changes to the correct spoke cluster. One ArgoCD instance, one Git source of truth, deploys everywhere.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Harbor (Container Registry):&lt;/strong&gt;&lt;br&gt;
Harbor runs in the hub cluster. All spoke clusters have their containerd configured to pull images from the hub's Harbor instance. One scan, one set of vulnerability reports, one place to manage image lifecycle.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vault (Secrets):&lt;/strong&gt;&lt;br&gt;
HashiCorp Vault runs in the hub. Spoke clusters run the Vault Agent Injector, which authenticates using Kubernetes service accounts and injects secrets into pods at runtime. Rotate a database password in Vault once — all clusters get it.&lt;/p&gt;


&lt;h2&gt;
  
  
  Hub Cluster: Special Considerations
&lt;/h2&gt;

&lt;p&gt;The hub cluster has only 1 worker node, but it runs critical shared services. A few things to consider:&lt;/p&gt;
&lt;h3&gt;
  
  
  Removing the NoSchedule Taint
&lt;/h3&gt;

&lt;p&gt;With only 1 worker, you might need the masters to share the workload:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Allow pods on masters (only for the hub cluster)&lt;/span&gt;
kubectl taint nodes master-01 \
  node-role.kubernetes.io/control-plane:NoSchedule-
kubectl taint nodes master-02 \
  node-role.kubernetes.io/control-plane:NoSchedule-
kubectl taint nodes master-03 \
  node-role.kubernetes.io/control-plane:NoSchedule-
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The 3 masters have 24 CPUs and 48 GB RAM combined — plenty for Grafana, ArgoCD, Harbor, and Vault alongside the control plane.&lt;/p&gt;

&lt;h3&gt;
  
  
  Storage Planning
&lt;/h3&gt;

&lt;p&gt;Hub services are storage-heavy:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Service&lt;/th&gt;
&lt;th&gt;Storage Needs&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Prometheus&lt;/td&gt;
&lt;td&gt;Time-series data from all clusters. Plan 50–100 GB+&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Loki&lt;/td&gt;
&lt;td&gt;Log chunks from all clusters. Plan 100 GB+ (use object storage)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Harbor&lt;/td&gt;
&lt;td&gt;Container images. Plan 200 GB+&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Vault&lt;/td&gt;
&lt;td&gt;Minimal (secrets are small), but HA storage backend needed&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This is why the masters have 300 GB each. Consider using Longhorn or a dedicated NFS server for persistent volumes.&lt;/p&gt;




&lt;h2&gt;
  
  
  Execution Cheat Sheet
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FOR EACH CLUSTER (hub first, then spokes):

PHASE 1 — All master + worker nodes (parallel):
  ├── apt update &amp;amp; upgrade
  ├── /etc/hosts
  ├── disable swap
  ├── kernel modules (overlay, br_netfilter)
  ├── sysctl (iptables bridge, ip_forward)
  ├── disable UFW
  ├── install packages
  ├── enable iscsid
  └── reboot

PHASE 2 — HAProxy nodes (primary first):
  ├── install haproxy + keepalived
  ├── sysctl (nonlocal_bind, somaxconn)
  ├── systemd NOFILE limit
  ├── haproxy.cfg
  ├── start haproxy
  ├── check_haproxy.sh
  ├── keepalived.conf
  ├── start keepalived
  └── verify VIP

PHASE 3 — RKE2 (sequential):
  ├── master-01: first-master config, start, wait for :9345
  ├── master-02: additional-master config (server: line), start
  ├── master-03: same
  └── workers: agent install, start

POST-CLUSTER:
  Hub:  Install Grafana, Prometheus, Loki, ArgoCD, Harbor, Vault
  Spokes: Install Promtail, Prometheus (remote-write), Vault agent
          Register as ArgoCD target
          Configure containerd to pull from Hub's Harbor
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Troubleshooting
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Master won't start:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo journalctl -u rke2-server -f --no-pager &lt;span class="o"&gt;|&lt;/span&gt; tail -50
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Node stuck in NotReady:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl describe node &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;node-name&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Connection refused on port 9345:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo ss -tlnp &lt;span class="o"&gt;|&lt;/span&gt; grep 9345
curl -k https://192.168.x.100:9345
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;VIP not failing over:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo journalctl -u keepalived -f
sudo tcpdump -i eth0 vrrp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Spoke metrics not appearing in Hub Grafana:&lt;/strong&gt;&lt;br&gt;
Check the spoke's Prometheus remote-write config — the endpoint should point to the hub's Prometheus push endpoint, and network policies should allow cross-cluster traffic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Spoke logs missing in Hub Loki:&lt;/strong&gt;&lt;br&gt;
Check Promtail's config on the spoke — &lt;code&gt;clients.url&lt;/code&gt; should point to &lt;code&gt;http://&amp;lt;hub-loki-gateway&amp;gt;:3100/loki/api/v1/push&lt;/code&gt;. Verify the hub's Loki ingester isn't rejecting streams (check for "rate limit" or "stream limit" errors).&lt;/p&gt;




&lt;h2&gt;
  
  
  Ports Reference
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Port&lt;/th&gt;
&lt;th&gt;Protocol&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;6443&lt;/td&gt;
&lt;td&gt;TCP&lt;/td&gt;
&lt;td&gt;Kubernetes API server&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;9345&lt;/td&gt;
&lt;td&gt;TCP&lt;/td&gt;
&lt;td&gt;RKE2 node registration&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2379–2380&lt;/td&gt;
&lt;td&gt;TCP&lt;/td&gt;
&lt;td&gt;etcd client/peer&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8472&lt;/td&gt;
&lt;td&gt;UDP&lt;/td&gt;
&lt;td&gt;VXLAN overlay (Canal/Flannel)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10250&lt;/td&gt;
&lt;td&gt;TCP&lt;/td&gt;
&lt;td&gt;kubelet API&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8404&lt;/td&gt;
&lt;td&gt;TCP&lt;/td&gt;
&lt;td&gt;HAProxy stats (localhost)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;112&lt;/td&gt;
&lt;td&gt;VRRP&lt;/td&gt;
&lt;td&gt;Keepalived heartbeat&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  What I Learned
&lt;/h2&gt;

&lt;p&gt;Building clusters manually takes 10× longer than running Ansible. But now when something breaks at 2 AM — and in a hub-and-spoke setup, the hub going down means &lt;em&gt;all clusters&lt;/em&gt; lose their operational visibility — I know exactly which component failed and why.&lt;/p&gt;

&lt;p&gt;The hub-and-spoke model is worth the added complexity. One Grafana to check instead of four. One ArgoCD to manage instead of four. One Harbor to scan instead of four. The operational overhead drops dramatically once the initial setup is done.&lt;/p&gt;

&lt;p&gt;If you're managing more than two clusters, centralize your tooling. Your future self — the one debugging a production incident across three clusters at midnight — will thank you.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;This article is based on building a hub-and-spoke platform with 4 production RKE2 clusters. All project names, secrets, credentials, and identifying details have been anonymized.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Questions? Hit the comments — I've probably run into the same issue.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>kubernetes</category>
      <category>docker</category>
      <category>sre</category>
    </item>
  </channel>
</rss>
