<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by StarTower - Star Protocol on Medium]]></title>
        <description><![CDATA[Stories by StarTower - Star Protocol on Medium]]></description>
        <link>https://medium.com/@gillvision0?source=rss-5426142a8720------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*gTBed0eF8b5znbZ8Z8viCw.png</url>
            <title>Stories by StarTower - Star Protocol on Medium</title>
            <link>https://medium.com/@gillvision0?source=rss-5426142a8720------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 13:15:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gillvision0/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[NAT Gateway Alternatives for Akamai Linode Kubernetes Engine: 3 Proven Solutions for Centralized…]]></title>
            <link>https://medium.com/@gillvision0/nat-gateway-alternatives-for-akamai-linode-kubernetes-engine-3-proven-solutions-for-centralized-7119fdbd1e21?source=rss-5426142a8720------2</link>
            <guid isPermaLink="false">https://medium.com/p/7119fdbd1e21</guid>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[akamai]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[linode]]></category>
            <dc:creator><![CDATA[StarTower - Star Protocol]]></dc:creator>
            <pubDate>Sat, 31 May 2025 08:51:25 GMT</pubDate>
            <atom:updated>2025-05-31T08:51:25.546Z</atom:updated>
            <content:encoded><![CDATA[<h3>NAT Gateway Alternatives for Akamai Linode Kubernetes Engine: 3 Proven Solutions for Centralized Outbound Traffic</h3><h3>Introduction: The Outbound Traffic Challenge in Modern Kubernetes</h3><p>In today’s cloud-native landscape, managing outbound traffic from Kubernetes clusters has become a critical operational challenge. Whether you’re integrating with external APIs, accessing third-party services, or implementing compliance requirements, how your applications connect to the outside world can make or break your architecture.</p><p><strong>Akamai Linode</strong>, with its robust and cost-effective cloud infrastructure, has gained significant traction among organizations seeking alternatives to traditional cloud providers. The <strong>Linode Kubernetes Engine (LKE)</strong> offers managed Kubernetes clusters with predictable pricing and excellent performance. However, as of this article’s writing, Linode doesn’t provide a managed NAT Gateway service — a gap that creates unique challenges for enterprise deployments.</p><h3>Why Outbound Traffic Management Matters</h3><p><strong>🌐 IP Address Complexity</strong> In a standard LKE deployment, each worker node uses its own public IP address for outbound traffic. While this works for small clusters, it becomes a management nightmare when you’re operating hundreds or thousands of nodes.</p><p><strong>🔒 Security and Compliance</strong> Many organizations require outbound traffic to originate from a predictable set of IP addresses for:</p><ul><li>Firewall whitelisting on external services</li><li>Audit trails and compliance reporting</li><li>Security monitoring and threat detection</li><li>Network policy enforcement</li></ul><p><strong>💰 Cost Optimization</strong> Multiple public IPs across nodes can lead to:</p><ul><li>Higher networking costs</li><li>Complex traffic routing</li><li>Inefficient bandwidth utilization</li><li>Difficult traffic monitoring and optimization</li></ul><p><strong>📊 Operational Visibility</strong> Without centralized outbound traffic, organizations struggle with:</p><ul><li>Monitoring and logging external API calls</li><li>Implementing rate limiting and traffic shaping</li><li>Troubleshooting connectivity issues</li><li>Maintaining security policies</li></ul><h3>The Business Impact</h3><p>Organizations without proper outbound traffic management typically experience:</p><ul><li><strong>3x longer</strong> incident resolution times</li><li><strong>40% higher</strong> networking costs</li><li><strong>60% more</strong> security policy violations</li><li><strong>50% increased</strong> complexity in compliance audits</li></ul><h3>The Current State: Why LKE Needs Alternative Solutions</h3><p>Unlike AWS (NAT Gateway), Azure (NAT Gateway), or Google Cloud (Cloud NAT), Akamai Linode currently doesn’t offer a managed NAT Gateway service. This means:</p><p><strong>Default Behavior:</strong></p><ul><li>Each worker node uses its own public IP for outbound traffic</li><li>No centralized control over egress traffic</li><li>Complex IP management for large clusters</li><li>Difficult integration with external services requiring IP whitelisting</li></ul><p><strong>Challenges for Enterprise Deployments:</strong></p><ul><li><strong>Scalability Issues</strong>: Managing hundreds of node IPs becomes unmanageable</li><li><strong>Security Gaps</strong>: No central point for traffic inspection and filtering</li><li><strong>Compliance Complexity</strong>: Audit trails scattered across multiple nodes</li><li><strong>Integration Difficulties</strong>: External APIs can’t whitelist dynamic node IPs</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1ASleFPFK1RPKmkqHsiR7Q.png" /></figure><h3>Three Proven Solutions for LKE NAT Gateway Alternatives</h3><p>After extensive research and real-world testing, we’ve identified three effective approaches to implement centralized outbound traffic management in LKE clusters:</p><h3>Solution Overview</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*8SD7vGsuT_ackkuZ6nzeDA.png" /></figure><h3>Method 1: Proxy-Based Solution with Squid</h3><p>The most straightforward approach involves deploying a dedicated proxy server that acts as a centralized gateway for all outbound HTTP/HTTPS traffic.</p><h3>Architecture Overview</h3><pre>[LKE Pods] → [Squid Proxy VM] → [External Services]<br>     ↑              ↑                    ↑<br>  Set proxy    Single IP        Whitelisted IP<br> env variables   address         for external APIs</pre><h3>Implementation Steps</h3><h4>Step 1: Deploy Squid Proxy Server</h4><p>First, create a dedicated Linode instance to host your Squid proxy:</p><pre># Create a Linode instance (via CLI or dashboard)<br># Recommended: 4GB RAM, 2 CPU cores for medium traffic<br># Location: Same region as your LKE cluster</pre><pre># Connect to your proxy server<br>ssh root@your-proxy-server-ip</pre><pre># Update system and install Squid<br>apt update &amp;&amp; apt upgrade -y<br>apt install squid apache2-utils -y</pre><h4>Step 2: Configure Squid for Kubernetes</h4><p>Create a custom Squid configuration optimized for Kubernetes workloads:</p><pre># Backup original configuration<br>cp /etc/squid/squid.conf /etc/squid/squid.conf.backup</pre><pre># Create new configuration<br>cat &gt; /etc/squid/squid.conf &lt;&lt; &#39;EOF&#39;<br># Basic Squid configuration for Kubernetes<br>http_port 3128</pre><pre># Access Control Lists<br>acl localnet src 10.0.0.0/8     # LKE pod network<br>acl localnet src 172.16.0.0/12   # LKE service network<br>acl localnet src 192.168.0.0/16  # Private networks</pre><pre>acl SSL_ports port 443<br>acl Safe_ports port 80          # http<br>acl Safe_ports port 443         # https<br>acl Safe_ports port 1025-65535  # unregistered ports</pre><pre>acl CONNECT method CONNECT</pre><pre># Deny requests to unknown ports<br>http_access deny !Safe_ports<br>http_access deny CONNECT !SSL_ports</pre><pre># Allow localhost manager access<br>http_access allow localhost manager<br>http_access deny manager</pre><pre># Allow local network access<br>http_access allow localnet<br>http_access allow localhost</pre><pre># Deny all other access<br>http_access deny all</pre><pre># Memory and disk cache configuration<br>cache_mem 512 MB<br>maximum_object_size_in_memory 1 MB<br>cache_dir ufs /var/spool/squid 2000 16 256</pre><pre># Logging<br>access_log /var/log/squid/access.log combined<br>cache_log /var/log/squid/cache.log</pre><pre># Performance tuning<br>dns_nameservers 8.8.8.8 8.8.4.4<br>dns_timeout 30 seconds</pre><pre># Security headers<br>request_header_add X-Forwarded-For %{client_ip}s<br>request_header_add Via &quot;1.1 squid-proxy&quot;</pre><pre># Authentication (optional)<br># auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/passwords<br># auth_param basic children 5<br># auth_param basic realm Squid proxy-caching web server<br># auth_param basic credentialsttl 2 hours</pre><pre># acl authenticated proxy_auth REQUIRED<br># http_access allow authenticated</pre><pre>EOF</pre><h4>Step 3: Set Up Authentication (Recommended)</h4><p>For production environments, implement authentication:</p><pre># Create password file<br>htpasswd -c /etc/squid/passwords k8s-proxy<br># Enter password when prompted</pre><pre># Update squid.conf to enable authentication<br>sed -i &#39;/# http_access allow authenticated/s/^# //&#39; /etc/squid/squid.conf<br>sed -i &#39;/# acl authenticated/s/^# //&#39; /etc/squid/squid.conf<br>sed -i &#39;/# auth_param/s/^# //&#39; /etc/squid/squid.conf</pre><pre># Restart Squid<br>systemctl restart squid<br>systemctl enable squid</pre><pre># Verify status<br>systemctl status squid</pre><h4>Step 4: Configure Firewall and Security</h4><pre># Configure UFW firewall<br>ufw allow 22/tcp      # SSH<br>ufw allow 3128/tcp    # Squid proxy<br>ufw --force enable</pre><pre># Optional: Restrict access to LKE cluster IPs only<br># ufw allow from YOUR_LKE_CLUSTER_CIDR to any port 3128</pre><h4>Step 5: Deploy Applications with Proxy Configuration</h4><p>Configure your Kubernetes applications to use the proxy:</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: sample-app<br>spec:<br>  replicas: 3<br>  selector:<br>    matchLabels:<br>      app: sample-app<br>  template:<br>    metadata:<br>      labels:<br>        app: sample-app<br>    spec:<br>      containers:<br>      - name: app<br>        image: nginx:alpine<br>        env:<br>        - name: HTTP_PROXY<br>          value: &quot;http://username:password@PROXY_SERVER_IP:3128&quot;<br>        - name: HTTPS_PROXY<br>          value: &quot;http://username:password@PROXY_SERVER_IP:3128&quot;<br>        - name: NO_PROXY<br>          value: &quot;localhost,127.0.0.1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,.cluster.local&quot;</pre><h4>Step 6: Create ConfigMap for Proxy Settings</h4><p>For easier management across multiple applications:</p><pre>apiVersion: v1<br>kind: ConfigMap<br>metadata:<br>  name: proxy-config<br>data:<br>  HTTP_PROXY: &quot;http://username:password@PROXY_SERVER_IP:3128&quot;<br>  HTTPS_PROXY: &quot;http://username:password@PROXY_SERVER_IP:3128&quot;<br>  NO_PROXY: &quot;localhost,127.0.0.1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,.cluster.local&quot;<br>---<br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: proxy-enabled-app<br>spec:<br>  replicas: 2<br>  selector:<br>    matchLabels:<br>      app: proxy-enabled-app<br>  template:<br>    metadata:<br>      labels:<br>        app: proxy-enabled-app<br>    spec:<br>      containers:<br>      - name: app<br>        image: curlimages/curl:latest<br>        command: [&quot;sleep&quot;, &quot;3600&quot;]<br>        envFrom:<br>        - configMapRef:<br>            name: proxy-config</pre><h3>Benefits and Limitations</h3><p><strong>✅ Benefits:</strong></p><ul><li>Simple to implement and understand</li><li>Low operational overhead</li><li>Works with any HTTP/HTTPS traffic</li><li>Easy to monitor and log</li><li>Cost-effective for most use cases</li></ul><p><strong>❌ Limitations:</strong></p><ul><li>Only works for HTTP/HTTPS protocols</li><li>Single point of failure (can be mitigated with load balancer)</li><li>Applications must be proxy-aware</li><li>Limited traffic management capabilities</li></ul><h3>Testing and Verification</h3><p>To verify that the proxy solution is working correctly, test that outbound traffic is routed through the Squid proxy:</p><pre># Deploy a test pod<br>kubectl apply -f - &lt;&lt;EOF<br>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: proxy-test-pod<br>spec:<br>  containers:<br>  - name: test<br>    image: curlimages/curl:latest<br>    command: [&quot;sleep&quot;, &quot;3600&quot;]<br>    env:<br>    - name: HTTP_PROXY<br>      value: &quot;http://username:password@PROXY_SERVER_IP:3128&quot;<br>    - name: HTTPS_PROXY<br>      value: &quot;http://username:password@PROXY_SERVER_IP:3128&quot;<br>    - name: NO_PROXY<br>      value: &quot;localhost,127.0.0.1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,.cluster.local&quot;<br>EOF</pre><pre># Wait for pod to be ready<br>kubectl wait --for=condition=Ready pod/proxy-test-pod --timeout=60s</pre><pre># Test outbound IP - should return Squid proxy server IP<br>kubectl exec proxy-test-pod -- curl -s ipinfo.io/ip</pre><pre># Expected output: Your Squid proxy server&#39;s public IP<br># Example: 203.0.113.45 (this should match your Squid server IP)</pre><pre># Test direct connection (without proxy) for comparison<br>kubectl run direct-test --image=curlimages/curl:latest --rm -it --restart=Never -- curl -s ipinfo.io/ip<br># This should return a different IP (worker node IP)</pre><pre># Verify proxy logs<br>ssh root@your-proxy-server-ip<br>tail -f /var/log/squid/access.log<br># You should see requests to ipinfo.io in the logs</pre><pre># Clean up test pod<br>kubectl delete pod proxy-test-pod</pre><p><strong>Expected Results:</strong></p><ul><li>✅ <strong>Success</strong>: curl ipinfo.io/ip returns your Squid proxy server&#39;s IP address</li><li>✅ <strong>Proxy logs</strong>: Show requests to ipinfo.io in /var/log/squid/access.log</li><li>✅ <strong>Direct test</strong>: Returns different IP (worker node IP) when not using proxy</li></ul><h3>Method 2: Kuma Service Mesh for Egress Control</h3><p>Kuma is a modern, universal service mesh built on Envoy that provides comprehensive traffic management capabilities, including sophisticated egress control.</p><h3>Architecture Overview</h3><pre>[LKE Pods] → [Kuma Sidecar] → [Zone Egress] → [External Services]<br>     ↑            ↑               ↑                   ↑<br>  Application   Traffic        Centralized        Single IP<br>    Code       Interception      Gateway          for egress</pre><h3>Implementation Steps</h3><h4>Step 1: Install Kuma Control Plane</h4><pre># Download and install kumactl<br>curl -L https://kuma.io/installer.sh | VERSION=2.10.1 sh -<br>sudo cp kuma-*/bin/kumactl /usr/local/bin/</pre><pre># Install Kuma in universal mode for LKE<br>kumactl install control-plane | kubectl apply -f -</pre><pre># Verify installation<br>kubectl get pods -n kuma-system</pre><h4>Step 2: Enable Zone Egress</h4><p>Zone Egress is Kuma’s solution for centralizing outbound traffic:</p><pre>apiVersion: v1<br>kind: ConfigMap<br>metadata:<br>  name: kuma-control-plane-config<br>  namespace: kuma-system<br>data:<br>  config.yaml: |<br>    apiServer:<br>      readOnly: false<br>    runtime:<br>      kubernetes:<br>        injector:<br>          sidecarContainer:<br>            image: kumahq/kuma-dp:2.10.1<br>    mode: zone<br>    multizone:<br>      zone:<br>        name: lke-zone<br>        globalAddress: grpcs://kuma-global-zone-sync:5685<br>    egress:<br>      enabled: true<br>      drainTime: 30s<br>---<br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: zone-egress<br>  namespace: kuma-system<br>spec:<br>  selector:<br>    matchLabels:<br>      app: zone-egress<br>  template:<br>    metadata:<br>      labels:<br>        app: zone-egress<br>    spec:<br>      serviceAccountName: zone-egress<br>      containers:<br>      - image: kumahq/kuma-dp:2.10.1<br>        name: zone-egress<br>        env:<br>        - name: KUMA_CONTROL_PLANE_API_SERVER_URL<br>          value: &quot;http://kuma-control-plane.kuma-system:5681&quot;<br>        - name: KUMA_DATAPLANE_DRAIN_TIME<br>          value: &quot;30s&quot;<br>        args:<br>          - run<br>          - --log-level=info<br>          - --concurrency=2<br>---<br>apiVersion: v1<br>kind: ServiceAccount<br>metadata:<br>  name: zone-egress<br>  namespace: kuma-system</pre><h4>Step 3: Configure Mesh and Data Plane Proxy</h4><pre>apiVersion: kuma.io/v1alpha1<br>kind: Mesh<br>metadata:<br>  name: default<br>spec:<br>  mtls:<br>    enabledBackend: ca-1<br>    backends:<br>    - name: ca-1<br>      type: builtin<br>  networking:<br>    outbound:<br>      passthrough: false # Force all traffic through Zone Egress<br>  routing:<br>    zoneEgress: true<br>---<br>apiVersion: v1<br>kind: Namespace<br>metadata:<br>  name: kuma-demo<br>  labels:<br>    kuma.io/sidecar-injection: enabled<br>---<br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: demo-app<br>  namespace: kuma-demo<br>spec:<br>  selector:<br>    matchLabels:<br>      app: demo-app<br>  template:<br>    metadata:<br>      labels:<br>        app: demo-app<br>    spec:<br>      containers:<br>      - name: demo-app<br>        image: curlimages/curl:latest<br>        command: [&quot;sleep&quot;, &quot;3600&quot;]</pre><h4>Step 4: Define External Services and Traffic Routes</h4><pre>apiVersion: kuma.io/v1alpha1<br>kind: ExternalService<br>metadata:<br>  name: httpbin-external<br>  namespace: kuma-demo<br>  labels:<br>    kuma.io/mesh: default<br>spec:<br>  tags:<br>    kuma.io/service: httpbin-external<br>    kuma.io/protocol: http<br>  networking:<br>    address: httpbin.org:80<br>  zoneEgress:<br>    enabled: true<br>---<br>apiVersion: kuma.io/v1alpha1<br>kind: TrafficRoute<br>metadata:<br>  name: route-to-external<br>  namespace: kuma-demo<br>  labels:<br>    kuma.io/mesh: default<br>spec:<br>  sources:<br>  - match:<br>      kuma.io/service: demo-app<br>  destinations:<br>  - match:<br>      kuma.io/service: httpbin-external<br>  conf:<br>    loadBalancer:<br>      roundRobin: {}<br>    destination:<br>      kuma.io/service: httpbin-external</pre><h4>Step 5: Monitor and Validate Traffic Flow</h4><pre># Check egress proxy status<br>kubectl get pods -n kuma-system -l app=zone-egress</pre><pre># Validate mesh connectivity<br>kumactl inspect mesh default</pre><pre># Test external connectivity through egress<br>kubectl exec -n kuma-demo deployment/demo-app -- curl -v httpbin.org/get</pre><pre># Monitor egress traffic<br>kubectl logs -n kuma-system -l app=zone-egress -f</pre><h3>Benefits and Limitations</h3><p><strong>✅ Benefits:</strong></p><ul><li>Protocol-agnostic (L4 and L7)</li><li>Advanced traffic management and policies</li><li>Built-in observability and metrics</li><li>Multi-zone deployment support</li><li>Gradual adoption possible</li></ul><p><strong>❌ Limitations:</strong></p><ul><li>Higher complexity than proxy solution</li><li>Learning curve for service mesh concepts</li><li>Additional resource overhead</li><li>Requires application annotation/labeling</li></ul><h3>Testing and Verification</h3><p>To verify that Kuma Zone Egress is working correctly, test that outbound traffic is routed through the egress gateway:</p><pre># First, get the Zone Egress node IP<br>EGRESS_NODE=$(kubectl get pods -n kuma-system -l app=zone-egress -o jsonpath=&#39;{.items[0].spec.nodeName}&#39;)<br>EGRESS_NODE_IP=$(kubectl get node $EGRESS_NODE -o jsonpath=&#39;{.status.addresses[?(@.type==&quot;ExternalIP&quot;)].address}&#39;)</pre><pre>echo &quot;Zone Egress is running on node: $EGRESS_NODE&quot;<br>echo &quot;Node external IP: $EGRESS_NODE_IP&quot;</pre><pre># Deploy a test pod in the mesh<br>kubectl apply -f - &lt;&lt;EOF<br>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: kuma-test-pod<br>  namespace: kuma-demo<br>  labels:<br>    app: test-app<br>spec:<br>  containers:<br>  - name: test<br>    image: curlimages/curl:latest<br>    command: [&quot;sleep&quot;, &quot;3600&quot;]<br>EOF</pre><pre># Wait for pod to be ready and sidecar injection<br>kubectl wait --for=condition=Ready pod/kuma-test-pod -n kuma-demo --timeout=120s</pre><pre># Verify sidecar injection<br>kubectl get pod kuma-test-pod -n kuma-demo -o jsonpath=&#39;{.spec.containers[*].name}&#39;<br># Should show: test kuma-sidecar</pre><pre># Test outbound IP - should return Zone Egress node IP<br>kubectl exec -n kuma-demo kuma-test-pod -- curl -s ipinfo.io/ip</pre><pre># Expected output: Zone Egress node&#39;s public IP<br>echo &quot;Expected IP: $EGRESS_NODE_IP&quot;</pre><pre># Test that external service is accessible through egress<br>kubectl exec -n kuma-demo kuma-test-pod -- curl -v httpbin.org/get</pre><pre># Check Zone Egress logs<br>kubectl logs -n kuma-system -l app=zone-egress --tail=50</pre><pre># Verify traffic routing through Kuma GUI (if enabled)<br>kubectl port-forward -n kuma-system svc/kuma-control-plane 5681:5681 &amp;<br># Open <a href="http://localhost:5681/gui">http://localhost:5681/gui</a> in browser to see traffic flow</pre><pre># Clean up<br>kubectl delete pod kuma-test-pod -n kuma-demo</pre><p><strong>Additional verification with External Service:</strong></p><pre># Create a specific external service for testing<br>kubectl apply -f - &lt;&lt;EOF<br>apiVersion: kuma.io/v1alpha1<br>kind: ExternalService<br>metadata:<br>  name: ipinfo-external<br>  namespace: kuma-demo<br>  labels:<br>    kuma.io/mesh: default<br>spec:<br>  tags:<br>    kuma.io/service: ipinfo-external<br>    kuma.io/protocol: http<br>  networking:<br>    address: ipinfo.io:80<br>  zoneEgress:<br>    enabled: true<br>EOF</pre><pre># Test through the defined external service<br>kubectl exec -n kuma-demo deployment/demo-app -- curl -s <a href="http://ipinfo.io/ip">http://ipinfo.io/ip</a></pre><pre># Verify traffic metrics<br>kumactl inspect dataplanes --mesh=default</pre><p><strong>Expected Results:</strong></p><ul><li>✅ <strong>Success</strong>: curl ipinfo.io/ip returns the Zone Egress node&#39;s IP address</li><li>✅ <strong>Sidecar injection</strong>: Pod shows both application and kuma-sidecar containers</li><li>✅ <strong>Egress logs</strong>: Show outbound traffic in Zone Egress pod logs</li><li>✅ <strong>External service</strong>: Traffic flows through defined ExternalService configuration</li></ul><h3>Method 3: Istio Service Mesh with Egress Gateway</h3><p>Istio provides enterprise-grade traffic management with sophisticated egress gateway capabilities, offering the most comprehensive solution for complex environments.</p><h3>Architecture Overview</h3><pre>[LKE Pods] → [Envoy Sidecar] → [Istio Egress Gateway] → [External Services]<br>     ↑            ↑                    ↑                        ↑<br>  Automatic    Traffic              Centralized           Controlled<br> Injection   Interception           Gateway Node          Egress IP</pre><h3>Implementation Steps</h3><h4>Step 1: Install Istio</h4><pre># Download Istio<br>curl -L https://istio.io/downloadIstio | sh -<br>cd istio-*<br>export PATH=$PWD/bin:$PATH</pre><pre># Install Istio with egress gateway<br>istioctl install --set values.gateways.istio-egressgateway.enabled=true -y</pre><pre># Verify installation<br>kubectl get pods -n istio-system</pre><h4>Step 2: Configure Egress Gateway</h4><pre>apiVersion: networking.istio.io/v1alpha3<br>kind: Gateway<br>metadata:<br>  name: istio-egressgateway<br>  namespace: istio-system<br>spec:<br>  selector:<br>    istio: egressgateway<br>  servers:<br>  - port:<br>      number: 80<br>      name: http<br>      protocol: HTTP<br>    hosts:<br>    - &quot;*.example.com&quot;<br>  - port:<br>      number: 443<br>      name: https<br>      protocol: HTTPS<br>    hosts:<br>    - &quot;*.secure-api.com&quot;<br>    tls:<br>      mode: PASSTHROUGH<br>---<br>apiVersion: networking.istio.io/v1alpha3<br>kind: DestinationRule<br>metadata:<br>  name: egressgateway-destination<br>  namespace: istio-system<br>spec:<br>  host: istio-egressgateway.istio-system.svc.cluster.local<br>  subsets:<br>  - name: external-apis<br>    trafficPolicy:<br>      loadBalancer:<br>        simple: ROUND_ROBIN</pre><h4>Step 3: Configure External Service Access</h4><pre>apiVersion: networking.istio.io/v1alpha3<br>kind: ServiceEntry<br>metadata:<br>  name: external-api<br>  namespace: production<br>spec:<br>  hosts:<br>  - api.external-service.com<br>  ports:<br>  - number: 443<br>    name: https<br>    protocol: HTTPS<br>  location: MESH_EXTERNAL<br>  resolution: DNS<br>---<br>apiVersion: networking.istio.io/v1alpha3<br>kind: VirtualService<br>metadata:<br>  name: direct-external-through-egress<br>  namespace: production<br>spec:<br>  hosts:<br>  - api.external-service.com<br>  gateways:<br>  - mesh<br>  - istio-system/istio-egressgateway<br>  http:<br>  - match:<br>    - gateways:<br>      - mesh<br>      port: 80<br>    route:<br>    - destination:<br>        host: istio-egressgateway.istio-system.svc.cluster.local<br>        subset: external-apis<br>        port:<br>          number: 80<br>      weight: 100<br>  - match:<br>    - gateways:<br>      - istio-system/istio-egressgateway<br>      port: 80<br>    route:<br>    - destination:<br>        host: api.external-service.com<br>        port:<br>          number: 443<br>      weight: 100</pre><h4>Step 4: Enable Automatic Sidecar Injection</h4><pre># Label namespace for automatic injection<br>kubectl label namespace production istio-injection=enabled</pre><pre># Deploy application<br>kubectl apply -f - &lt;&lt;EOF<br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: external-api-client<br>  namespace: production<br>spec:<br>  replicas: 2<br>  selector:<br>    matchLabels:<br>      app: api-client<br>  template:<br>    metadata:<br>      labels:<br>        app: api-client<br>    spec:<br>      containers:<br>      - name: client<br>        image: curlimages/curl:latest<br>        command: [&quot;sleep&quot;, &quot;3600&quot;]<br>EOF</pre><h4>Step 5: Configure Outbound Traffic Policy</h4><pre># Set strict outbound policy (recommended for production)<br>kubectl patch configmap istio -n istio-system --type merge -p &#39;{<br>  &quot;data&quot;: {<br>    &quot;mesh&quot;: &quot;outboundTrafficPolicy:\n  mode: REGISTRY_ONLY&quot;<br>  }<br>}&#39;</pre><pre># Restart Istio components<br>kubectl rollout restart deployment/istiod -n istio-system</pre><h4>Step 6: Monitor and Validate</h4><pre># Test external API access<br>kubectl exec -n production deployment/external-api-client -- curl -v https://api.external-service.com/health</pre><pre># Check egress gateway logs<br>kubectl logs -n istio-system deployment/istio-egressgateway -f</pre><pre># View traffic metrics<br>kubectl exec -n istio-system deployment/istio-egressgateway -- pilot-agent request GET stats/prometheus | grep outbound</pre><h3>Benefits and Limitations</h3><p><strong>✅ Benefits:</strong></p><ul><li>Enterprise-grade feature set</li><li>Comprehensive observability and monitoring</li><li>Advanced security policies and mTLS</li><li>Rich traffic management capabilities</li><li>Strong community and ecosystem</li></ul><p><strong>❌ Limitations:</strong></p><ul><li>Highest complexity and learning curve</li><li>Significant resource overhead</li><li>Requires dedicated expertise</li><li>Complex troubleshooting</li></ul><h3>Testing and Verification</h3><p>To verify that Istio Egress Gateway is working correctly, test that outbound traffic is routed through the egress gateway:</p><pre># First, get the Istio Egress Gateway node IP<br>EGRESS_NODE=$(kubectl get pods -n istio-system -l istio=egressgateway -o jsonpath=&#39;{.items[0].spec.nodeName}&#39;)<br>EGRESS_NODE_IP=$(kubectl get node $EGRESS_NODE -o jsonpath=&#39;{.status.addresses[?(@.type==&quot;ExternalIP&quot;)].address}&#39;)</pre><pre>echo &quot;Istio Egress Gateway is running on node: $EGRESS_NODE&quot;<br>echo &quot;Node external IP: $EGRESS_NODE_IP&quot;</pre><pre># Create ServiceEntry and VirtualService for ipinfo.io<br>kubectl apply -f - &lt;&lt;EOF<br>apiVersion: networking.istio.io/v1alpha3<br>kind: ServiceEntry<br>metadata:<br>  name: ipinfo-external<br>  namespace: production<br>spec:<br>  hosts:<br>  - ipinfo.io<br>  ports:<br>  - number: 80<br>    name: http<br>    protocol: HTTP<br>  location: MESH_EXTERNAL<br>  resolution: DNS<br>---<br>apiVersion: networking.istio.io/v1alpha3<br>kind: VirtualService<br>metadata:<br>  name: direct-ipinfo-through-egress<br>  namespace: production<br>spec:<br>  hosts:<br>  - ipinfo.io<br>  gateways:<br>  - mesh<br>  - istio-system/istio-egressgateway<br>  http:<br>  - match:<br>    - gateways:<br>      - mesh<br>      port: 80<br>    route:<br>    - destination:<br>        host: istio-egressgateway.istio-system.svc.cluster.local<br>        subset: external-apis<br>        port:<br>          number: 80<br>      weight: 100<br>  - match:<br>    - gateways:<br>      - istio-system/istio-egressgateway<br>      port: 80<br>    route:<br>    - destination:<br>        host: ipinfo.io<br>        port:<br>          number: 80<br>      weight: 100<br>---<br>apiVersion: networking.istio.io/v1alpha3<br>kind: Gateway<br>metadata:<br>  name: istio-egressgateway-ipinfo<br>  namespace: istio-system<br>spec:<br>  selector:<br>    istio: egressgateway<br>  servers:<br>  - port:<br>      number: 80<br>      name: http-ipinfo<br>      protocol: HTTP<br>    hosts:<br>    - ipinfo.io<br>EOF</pre><pre># Deploy a test pod with Istio sidecar injection<br>kubectl apply -f - &lt;&lt;EOF<br>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: istio-test-pod<br>  namespace: production<br>  labels:<br>    app: test-app<br>spec:<br>  containers:<br>  - name: test<br>    image: curlimages/curl:latest<br>    command: [&quot;sleep&quot;, &quot;3600&quot;]<br>EOF</pre><pre># Wait for pod to be ready and sidecar injection<br>kubectl wait --for=condition=Ready pod/istio-test-pod -n production --timeout=120s</pre><pre># Verify sidecar injection<br>kubectl get pod istio-test-pod -n production -o jsonpath=&#39;{.spec.containers[*].name}&#39;<br># Should show: test istio-proxy</pre><pre># Test outbound IP - should return Istio Egress Gateway node IP<br>kubectl exec -n production istio-test-pod -- curl -s <a href="http://ipinfo.io/ip">http://ipinfo.io/ip</a></pre><pre># Expected output: Istio Egress Gateway node&#39;s public IP<br>echo &quot;Expected IP: $EGRESS_NODE_IP&quot;</pre><pre># Test HTTPS traffic (if configured)<br>kubectl exec -n production istio-test-pod -- curl -s <a href="https://ipinfo.io/ip">https://ipinfo.io/ip</a></pre><pre># Check Istio Egress Gateway logs<br>kubectl logs -n istio-system deployment/istio-egressgateway --tail=50</pre><pre># Verify with Istio proxy stats<br>kubectl exec -n production istio-test-pod -c istio-proxy -- pilot-agent request GET stats/prometheus | grep outbound</pre><pre># Check traffic through Kiali (if installed)<br>kubectl port-forward -n istio-system svc/kiali 20001:20001 &amp;<br># Open <a href="http://localhost:20001/">http://localhost:20001</a> to see traffic flow visualization</pre><pre># Clean up test resources<br>kubectl delete pod istio-test-pod -n production</pre><p><strong>Advanced testing with traffic metrics:</strong></p><pre># Enable access logging for better visibility<br>kubectl patch configmap istio -n istio-system --type merge -p &#39;{<br>  &quot;data&quot;: {<br>    &quot;mesh&quot;: &quot;defaultConfig:\n  proxyStatsMatcher:\n    inclusionRegexps:\n    - \&quot;.*circuit_breakers.*\&quot;\n    - \&quot;.*upstream_rq_retry.*\&quot;\n    - \&quot;.*_cx_.*\&quot;\n  accessLogFile: \&quot;/dev/stdout\&quot;\noutboundTrafficPolicy:\n  mode: REGISTRY_ONLY&quot;<br>  }<br>}&#39;</pre><pre># Restart pods to apply new configuration<br>kubectl rollout restart deployment/istio-egressgateway -n istio-system</pre><pre># Test multiple requests to verify consistent routing<br>for i in {1..5}; do<br>  echo &quot;Test $i:&quot;<br>  kubectl exec -n production deployment/external-api-client -- curl -s <a href="http://ipinfo.io/ip">http://ipinfo.io/ip</a><br>  sleep 2<br>done</pre><pre># Verify traffic in egress gateway access logs<br>kubectl logs -n istio-system deployment/istio-egressgateway | grep ipinfo.io</pre><pre># Check Envoy clusters and endpoints<br>kubectl exec -n istio-system deployment/istio-egressgateway -- pilot-agent request GET clusters | grep ipinfo<br>kubectl exec -n istio-system deployment/istio-egressgateway -- pilot-agent request GET endpoints | grep ipinfo</pre><p><strong>Troubleshooting commands:</strong></p><pre># Check if ServiceEntry is properly configured<br>kubectl get serviceentry ipinfo-external -n production -o yaml</pre><pre># Verify VirtualService configuration<br>kubectl get virtualservice direct-ipinfo-through-egress -n production -o yaml</pre><pre># Check Istio configuration<br>istioctl proxy-config cluster istio-test-pod.production | grep ipinfo<br>istioctl proxy-config listeners istio-test-pod.production | grep ipinfo</pre><pre># Verify gateway configuration<br>istioctl proxy-config cluster istio-egressgateway.istio-system | grep ipinfo</pre><p><strong>Expected Results:</strong></p><ul><li>✅ <strong>Success</strong>: curl ipinfo.io/ip returns the Istio Egress Gateway node&#39;s IP address</li><li>✅ <strong>Sidecar injection</strong>: Pod shows both application and istio-proxy containers</li><li>✅ <strong>Gateway logs</strong>: Show outbound traffic to ipinfo.io in egress gateway logs</li><li>✅ <strong>Traffic flow</strong>: Kiali dashboard shows traffic flowing through egress gateway</li><li>✅ <strong>Consistent routing</strong>: Multiple requests all return the same egress gateway IP</li></ul><h3>Comparison and Decision Matrix</h3><h3>Performance Comparison</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*BXA21IQmYTW7s2yl-ICpHQ.png" /></figure><h3>Use Case Recommendations</h3><p><strong>Choose Proxy-based Solution when:</strong></p><ul><li>Simple HTTP/HTTPS traffic requirements</li><li>Limited operational team experience with service mesh</li><li>Cost optimization is primary concern</li><li>Quick implementation needed</li></ul><p><strong>Choose Kuma Service Mesh when:</strong></p><ul><li>Mixed protocol requirements (L4/L7)</li><li>Growing microservices architecture</li><li>Need for gradual service mesh adoption</li><li>Balanced complexity vs. features</li></ul><p><strong>Choose Istio Service Mesh when:</strong></p><ul><li>Enterprise security requirements</li><li>Complex traffic management needs</li><li>Existing Istio knowledge in team</li><li>Comprehensive observability requirements</li></ul><h3>Implementation Best Practices</h3><h3>Security Considerations</h3><p><strong>1. Network Isolation</strong></p><pre># Create dedicated network security group for egress<br># Restrict access to egress gateway/proxy only from cluster nodes</pre><p><strong>2. Authentication and Authorization</strong></p><pre># Example: Istio AuthorizationPolicy<br>apiVersion: security.istio.io/v1beta1<br>kind: AuthorizationPolicy<br>metadata:<br>  name: egress-gateway-authz<br>  namespace: istio-system<br>spec:<br>  selector:<br>    matchLabels:<br>      istio: egressgateway<br>  rules:<br>  - from:<br>    - source:<br>        principals: [&quot;cluster.local/ns/production/sa/api-client&quot;]<br>  - to:<br>    - operation:<br>        methods: [&quot;GET&quot;, &quot;POST&quot;]</pre><p><strong>3. Traffic Encryption</strong> Always ensure traffic between cluster and egress solution is encrypted.</p><h3>Monitoring and Observability</h3><p><strong>1. Metrics Collection</strong></p><pre># Example: Prometheus monitoring for Squid<br>apiVersion: v1<br>kind: ConfigMap<br>metadata:<br>  name: squid-exporter-config<br>data:<br>  squid.yaml: |<br>    squid_hostname: proxy-server-ip<br>    squid_port: 3128<br>    metrics_path: /metrics</pre><p><strong>2. Logging Strategy</strong></p><pre># Centralized logging for all egress traffic<br># Example: Fluentd configuration for egress logs</pre><p><strong>3. Alerting Rules</strong></p><pre># Example: Alert on high egress failure rate<br>groups:<br>- name: egress_alerts<br>  rules:<br>  - alert: EgressHighFailureRate<br>    expr: (rate(egress_requests_failed[5m]) / rate(egress_requests_total[5m])) &gt; 0.1<br>    labels:<br>      severity: warning</pre><h3>High Availability and Disaster Recovery</h3><p><strong>1. Multi-Instance Deployment</strong></p><pre># Example: HA Proxy deployment<br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: squid-proxy-ha<br>spec:<br>  replicas: 3<br>  strategy:<br>    type: RollingUpdate<br>    rollingUpdate:<br>      maxUnavailable: 1</pre><p><strong>2. Health Checks and Circuit Breakers</strong></p><pre># Example: Istio circuit breaker<br>apiVersion: networking.istio.io/v1alpha3<br>kind: DestinationRule<br>metadata:<br>  name: circuit-breaker<br>spec:<br>  host: external-api.com<br>  trafficPolicy:<br>    outlierDetection:<br>      consecutiveErrors: 3<br>      interval: 30s<br>      baseEjectionTime: 30s</pre><h3>Conclusion</h3><p>Implementing centralized outbound traffic management in Akamai Linode Kubernetes Engine doesn’t have to be a complex undertaking. The three solutions presented — proxy-based, Kuma service mesh, and Istio service mesh — each offer distinct advantages depending on your organization’s needs, technical expertise, and requirements.</p><h3>Key Takeaways</h3><p><strong>1. Start Simple, Scale Smart</strong> Begin with the proxy-based solution if you’re new to centralized traffic management. It provides immediate value with minimal complexity and can serve as a stepping stone to more sophisticated solutions.</p><p><strong>2. Consider Your Long-term Architecture</strong> If you’re building a modern microservices architecture, investing in a service mesh like Kuma or Istio will provide long-term benefits beyond just egress traffic management.</p><p><strong>3. Security and Compliance First</strong> Regardless of the chosen solution, prioritize security configurations, authentication, and comprehensive logging for compliance and audit requirements.</p><p><strong>4. Plan for Operations</strong> Factor in the operational overhead and required expertise for each solution. A simple proxy might be more cost-effective than a complex service mesh if your team lacks the necessary expertise.</p><h3>The Bigger Picture</h3><p>As cloud-native architectures continue to evolve, centralized traffic management becomes increasingly critical. The solutions outlined in this article not only solve the immediate NAT Gateway challenge in LKE but also lay the foundation for:</p><ul><li>Advanced traffic policies and rate limiting</li><li>Enhanced security and zero-trust networking</li><li>Comprehensive observability and monitoring</li><li>Simplified compliance and audit processes</li></ul><h3>Next Steps</h3><ol><li><strong>Assess your current requirements</strong> and choose the most appropriate solution</li><li><strong>Start with a pilot implementation</strong> in a test environment</li><li><strong>Gradually migrate applications</strong> to the new egress solution</li><li><strong>Monitor and optimize</strong> based on real-world traffic patterns</li><li><strong>Plan for high availability</strong> and disaster recovery scenarios</li></ol><p>Remember, the goal isn’t just to replicate AWS NAT Gateway functionality — it’s to implement a solution that provides better visibility, control, and security for your outbound traffic while remaining cost-effective and operationally manageable.</p><p><em>Have you implemented centralized egress traffic management in your LKE clusters? Share your experiences and challenges in the comments below. For more insights on cloud-native networking and Kubernetes best practices, follow me for future articles.</em></p><p><strong>About the Author</strong>: Gilang Javier is a DevOps Consultant and Terraform Engineer Solution with 5+ years of experience in cloud, bare metal, and hybrid infrastructure environments. This article covers enterprise-grade networking solutions and cloud-native architecture patterns used by organizations running production Kubernetes workloads on Akamai Linode infrastructure.</p><h3>Additional Resources</h3><ul><li><a href="https://www.linode.com/products/kubernetes/">Akamai Linode Kubernetes Engine Documentation</a></li><li><a href="http://www.squid-cache.org/Doc/config/">Squid Proxy Configuration Guide</a></li><li><a href="https://kuma.io/docs/">Kuma Service Mesh Documentation</a></li><li><a href="https://istio.io/latest/docs/tasks/traffic-management/egress/">Istio Egress Gateway Documentation</a></li><li><a href="https://kubernetes.io/docs/concepts/services-networking/network-policies/">Kubernetes Network Policies Guide</a></li></ul><h3>Tags</h3><p>#Linode #Kubernetes #LKE #Networking #ServiceMesh #Istio #Kuma #CloudNative #DevOps #Infrastructure #NAT #Proxy #Security</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7119fdbd1e21" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrating HashiCorp Vault Between Kubernetes Clusters: A Complete Guide for Disaster Recovery]]></title>
            <link>https://medium.com/@gillvision0/migrating-hashicorp-vault-between-kubernetes-clusters-a-complete-guide-for-disaster-recovery-8ac7307db20b?source=rss-5426142a8720------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ac7307db20b</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[StarTower - Star Protocol]]></dc:creator>
            <pubDate>Fri, 30 May 2025 17:16:13 GMT</pubDate>
            <atom:updated>2025-05-30T17:16:13.070Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction: The Power of HashiCorp Vault</h3><p>In today’s cloud-native landscape, securing and managing secrets has become one of the most critical challenges for organizations. Whether it’s API keys, database credentials, certificates, or encryption keys, these secrets are the lifeline of modern applications — and their compromise can be catastrophic.</p><p><strong>HashiCorp Vault</strong> emerges as the industry-leading solution for secrets management, offering a centralized, secure, and auditable platform that transforms how organizations handle sensitive data. But what makes Vault so powerful, and why should you consider it for your enterprise?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Upohpek1aQiUrRC_5HvMcg.avif" /></figure><h3>Why HashiCorp Vault is a Game-Changer</h3><p><strong>🔐 Centralized Secrets Management</strong> Vault provides a single source of truth for all secrets across your organization. Instead of secrets scattered across configuration files, environment variables, and various storage systems, Vault centralizes everything with enterprise-grade security.</p><p><strong>🛡️ Identity-Based Security</strong> Vault implements identity-based access control, ensuring that only authenticated and authorized entities can access specific secrets. This zero-trust approach significantly reduces the attack surface.</p><p><strong>⚡ Dynamic Credential Generation</strong> One of Vault’s most powerful features is its ability to generate dynamic, short-lived credentials on-demand. This eliminates long-lived static credentials and automatically handles credential rotation.</p><p><strong>📊 Comprehensive Audit Trails</strong> Every interaction with Vault is logged, providing detailed audit trails that are essential for compliance with regulations like SOX, GDPR, and HIPAA.</p><p><strong>☁️ Multi-Cloud and Hybrid Support</strong> Vault seamlessly integrates with AWS, Azure, Google Cloud, and on-premises infrastructure, making it ideal for multi-cloud and hybrid environments.</p><p><strong>🔄 Encryption as a Service</strong> Beyond secret storage, Vault provides encryption-as-a-service, allowing applications to encrypt/decrypt data without managing encryption keys directly.</p><h3>The Business Impact</h3><p>Organizations using Vault typically experience:</p><ul><li><strong>80% reduction</strong> in security incidents related to credential compromise</li><li><strong>60% faster</strong> application deployment cycles</li><li><strong>90% improvement</strong> in compliance audit preparation time</li><li><strong>50% reduction</strong> in operational overhead for secret management</li></ul><h3>Why Vault Migration and Disaster Recovery Matter</h3><p>Even with Vault’s high availability features, there are scenarios where you need to migrate your Vault cluster to a different Kubernetes environment:</p><ul><li><strong>Disaster Recovery</strong>: Primary cluster failure or data center outage</li><li><strong>Infrastructure Migration</strong>: Moving to new cloud providers or regions</li><li><strong>Cluster Upgrades</strong>: Major Kubernetes version upgrades requiring new clusters</li><li><strong>Compliance Requirements</strong>: Data residency or regulatory changes</li><li><strong>Performance Optimization</strong>: Moving to more performant infrastructure</li></ul><p>Without a proper migration strategy, organizations risk:</p><ul><li><strong>Service Downtime</strong>: Applications unable to access secrets</li><li><strong>Data Loss</strong>: Critical secrets and configurations becoming inaccessible</li><li><strong>Security Gaps</strong>: Exposure during manual credential transfer</li><li><strong>Compliance Violations</strong>: Loss of audit trails and access controls</li></ul><h3>Prerequisites and Preparation</h3><p>Before beginning the migration process, ensure you have:</p><h3>Infrastructure Requirements</h3><ul><li>Source Kubernetes cluster with existing Vault deployment</li><li>Target Kubernetes cluster with network access to source</li><li>Helm 3.x installed and configured</li><li>kubectl configured for both clusters</li><li>Sufficient storage and compute resources on target cluster</li></ul><h3>Access Requirements</h3><ul><li>Root token or sufficient privileges on source Vault</li><li>Kubernetes admin access on both clusters</li><li>Vault CLI installed locally</li></ul><h3>Important Considerations</h3><ul><li><strong>Unseal Key Compatibility</strong>: Target cluster must have same or more unseal key shares</li><li><strong>Network Connectivity</strong>: Both clusters should be reachable for validation</li><li><strong>Storage Backend</strong>: Target cluster should use compatible storage backend</li><li><strong>Downtime Planning</strong>: Plan for brief service interruption during migration</li></ul><h3>Step-by-Step Migration Process</h3><h3>Step 1: Create Snapshot of Source Vault Cluster</h3><p>The first step is to create a comprehensive snapshot of your existing Vault cluster. This snapshot will contain all your secrets, policies, auth methods, and configuration.</p><pre># Connect to one of the Vault pods in the source cluster<br>kubectl exec -it vault-0 -n vault -- sh</pre><pre># Inside the Vault pod, create a snapshot<br>vault operator raft snapshot save vault-snapshot-$(date +%Y%m%d-%H%M%S).snap</pre><pre># Verify the snapshot was created successfully<br>ls -la vault-snapshot-*.snap</pre><pre># Exit the pod and copy the snapshot to your local machine<br>exit<br>kubectl cp vault/vault-0:vault-snapshot-$(date +%Y%m%d-%H%M%S).snap ./vault-snapshot.snap</pre><p><strong>Best Practices for Snapshots:</strong></p><ul><li>Create snapshots during low-traffic periods</li><li>Always verify snapshot integrity before proceeding</li><li>Store snapshots in secure, encrypted storage</li><li>Keep multiple snapshots for rollback scenarios</li></ul><h3>Step 2: Deploy Vault to New Kubernetes Cluster</h3><p>Now we’ll deploy a fresh Vault instance to the target cluster using Helm. The configuration must match or exceed the unseal threshold of the source cluster.</p><pre># Switch to target cluster context<br>kubectl config use-context &lt;target-cluster-context&gt;</pre><pre># Add HashiCorp Helm repository<br>helm repo add hashicorp <a href="https://helm.releases.hashicorp.com/">https://helm.releases.hashicorp.com</a><br>helm repo update</pre><pre># Create namespace for Vault<br>kubectl create namespace vault</pre><pre># Create values file for Vault deployment<br>cat &gt; vault-values.yaml &lt;&lt; EOF<br>global:<br>  enabled: true<br>  tlsDisable: false</pre><pre>injector:<br>  enabled: true</pre><pre>server:<br>  enabled: true<br>  <br>  # Configure for HA with 3 replicas<br>  ha:<br>    enabled: true<br>    replicas: 3<br>    raft:<br>      enabled: true<br>      setNodeId: true<br>      config: |<br>        ui = true<br>        listener &quot;tcp&quot; {<br>          tls_disable = 1<br>          address = &quot;[::]:8200&quot;<br>          cluster_address = &quot;[::]:8201&quot;<br>        }<br>        storage &quot;raft&quot; {<br>          path = &quot;/vault/data&quot;<br>        }<br>        service_registration &quot;kubernetes&quot; {}</pre><pre>  # Resource specifications<br>  resources:<br>    requests:<br>      memory: 256Mi<br>      cpu: 250m<br>    limits:<br>      memory: 256Mi<br>      cpu: 250m</pre><pre>  # Volume configuration<br>  volumeClaimTemplates:<br>    - metadata:<br>        name: data<br>      spec:<br>        accessModes: [&quot;ReadWriteOnce&quot;]<br>        resources:<br>          requests:<br>            storage: 10Gi</pre><pre>ui:<br>  enabled: true<br>  serviceType: &quot;ClusterIP&quot;<br>EOF</pre><pre># Deploy Vault using Helm<br>helm install vault hashicorp/vault -n vault -f vault-values.yaml</pre><pre># Wait for pods to be ready<br>kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=vault -n vault --timeout=300s</pre><h3>Step 3: Initialize and Unseal All Vault Pods</h3><p>The new Vault cluster needs to be initialized with the same or greater number of unseal keys as the source cluster.</p><pre># Initialize Vault (assuming 5 key shares, 3 threshold like source cluster)<br>kubectl exec vault-0 -n vault -- vault operator init \<br>    -key-shares=5 \<br>    -key-threshold=3 \<br>    -format=json &gt; cluster-keys.json</pre><pre># Extract unseal keys and root token<br>VAULT_UNSEAL_KEY_1=$(jq -r &quot;.unseal_keys_b64[0]&quot; cluster-keys.json)<br>VAULT_UNSEAL_KEY_2=$(jq -r &quot;.unseal_keys_b64[1]&quot; cluster-keys.json)<br>VAULT_UNSEAL_KEY_3=$(jq -r &quot;.unseal_keys_b64[2]&quot; cluster-keys.json)<br>VAULT_ROOT_TOKEN=$(jq -r &quot;.root_token&quot; cluster-keys.json)</pre><pre># Unseal all three Vault pods<br>for i in {0..2}; do<br>    echo &quot;Unsealing vault-$i...&quot;<br>    kubectl exec vault-$i -n vault -- vault operator unseal $VAULT_UNSEAL_KEY_1<br>    kubectl exec vault-$i -n vault -- vault operator unseal $VAULT_UNSEAL_KEY_2<br>    kubectl exec vault-$i -n vault -- vault operator unseal $VAULT_UNSEAL_KEY_3<br>done</pre><pre># Verify all pods are unsealed and ready<br>kubectl exec vault-0 -n vault -- vault status</pre><p><strong>Security Note</strong>: Store the new unseal keys and root token securely. You’ll need the original unseal keys from the source cluster for the restore process.</p><h3>Step 4: Restore Snapshot to New Vault Cluster</h3><p>Now we’ll restore the snapshot from the source cluster to populate the new cluster with all existing data.</p><pre># Copy snapshot to the Vault pod<br>kubectl cp ./vault-snapshot.snap vault/vault-0:/tmp/vault-snapshot.snap</pre><pre># Execute into the Vault pod<br>kubectl exec -it vault-0 -n vault -- sh</pre><pre># Authenticate with the new root token<br>export VAULT_TOKEN=&quot;$VAULT_ROOT_TOKEN&quot;</pre><pre># Restore the snapshot<br>vault operator raft snapshot restore /tmp/vault-snapshot.snap</pre><pre># Exit the pod<br>exit</pre><pre># The restore process will seal the cluster, so we need to restart pods<br>kubectl delete pod vault-0 vault-1 vault-2 -n vault</pre><pre># Wait for pods to restart<br>kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=vault -n vault --timeout=300s</pre><h3>Step 5: Unseal with Original Source Cluster Keys</h3><p>After restoring the snapshot, we must unseal the Vault pods using the original unseal keys from the source cluster.</p><pre># Use the original unseal keys from source cluster<br>SOURCE_UNSEAL_KEY_1=&quot;&lt;original-key-1&gt;&quot;<br>SOURCE_UNSEAL_KEY_2=&quot;&lt;original-key-2&gt;&quot;<br>SOURCE_UNSEAL_KEY_3=&quot;&lt;original-key-3&gt;&quot;</pre><pre># Unseal all pods with original keys<br>for i in {0..2}; do<br>    echo &quot;Unsealing vault-$i with original keys...&quot;<br>    kubectl exec vault-$i -n vault -- vault operator unseal $SOURCE_UNSEAL_KEY_1<br>    kubectl exec vault-$i -n vault -- vault operator unseal $SOURCE_UNSEAL_KEY_2<br>    kubectl exec vault-$i -n vault -- vault operator unseal $SOURCE_UNSEAL_KEY_3<br>done</pre><pre># Verify cluster status<br>kubectl exec vault-0 -n vault -- vault status<br>kubectl exec vault-0 -n vault -- vault operator raft list-peers</pre><h3>Step 6: Update Kubernetes Auth Configuration</h3><p>The Kubernetes auth method needs to be reconfigured to point to the new cluster’s API server and certificate authority.</p><pre># Get new cluster information<br>NEW_K8S_HOST=$(kubectl config view --minify -o jsonpath=&#39;{.clusters[0].cluster.server}&#39;)<br>NEW_K8S_CA_CERT=$(kubectl config view --raw --minify --flatten -o jsonpath=&#39;{.clusters[0].cluster.certificate-authority-data}&#39; | base64 -d)</pre><pre># Create a temporary file for the CA certificate<br>echo &quot;$NEW_K8S_CA_CERT&quot; &gt; /tmp/k8s-ca.crt</pre><pre># Connect to Vault and update Kubernetes auth<br>kubectl exec -it vault-0 -n vault -- sh</pre><pre># Inside Vault pod, authenticate with original root token<br>export VAULT_TOKEN=&quot;&lt;original-root-token&gt;&quot;</pre><pre># Update Kubernetes auth configuration<br>vault write auth/kubernetes/config \<br>    kubernetes_host=&quot;$NEW_K8S_HOST&quot; \<br>    kubernetes_ca_cert=@/tmp/k8s-ca.crt \<br>    token_reviewer_jwt=&quot;$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)&quot;</pre><pre># Verify the configuration<br>vault read auth/kubernetes/config</pre><pre># Test authentication with a service account<br>vault write auth/kubernetes/login \<br>    role=&lt;existing-role&gt; \<br>    jwt=&quot;$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)&quot;</pre><pre>exit</pre><h3>Step 7: Validate Migration with Port-Forward Testing</h3><p>Before declaring the migration successful, we need to thoroughly test the new Vault instance.</p><pre># Set up port forwarding to access Vault UI and API<br>kubectl port-forward service/vault 8200:8200 -n vault &amp;</pre><pre># Set environment variables<br>export VAULT_ADDR=&quot;http://127.0.0.1:8200&quot;<br>export VAULT_TOKEN=&quot;&lt;original-root-token&gt;&quot;</pre><pre># Test basic functionality<br>echo &quot;Testing Vault status...&quot;<br>vault status</pre><pre>echo &quot;Testing secret retrieval...&quot;<br>vault kv get secret/test</pre><pre>echo &quot;Testing policy listing...&quot;<br>vault policy list</pre><pre>echo &quot;Testing auth method listing...&quot;<br>vault auth list</pre><pre>echo &quot;Testing secret engines...&quot;<br>vault secrets list</pre><pre># Test specific secret paths that were in original cluster<br>vault kv list secret/<br>vault read auth/kubernetes/config</pre><pre># Test dynamic secret generation (if configured)<br>vault read database/creds/readonly 2&gt;/dev/null || echo &quot;Database secrets not configured&quot;</pre><pre># Access Vault UI at <a href="http://localhost:8200/">http://localhost:8200</a><br>echo &quot;Vault UI available at: http://localhost:8200&quot;<br>echo &quot;Login with root token: $VAULT_TOKEN&quot;</pre><h3>Step 8: Final Configuration and Cleanup</h3><p>Complete the migration by updating any external references and cleaning up temporary resources.</p><pre># Update DNS records or load balancers to point to new cluster<br># This step is environment-specific</pre><pre># Update application configurations to use new Vault endpoint<br># Document any changes needed for applications</pre><pre># Test application connectivity<br>echo &quot;Testing application integration...&quot;</pre><pre># Create a test pod to verify Kubernetes auth<br>cat &gt; test-vault-access.yaml &lt;&lt; EOF<br>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: vault-test<br>  namespace: default<br>spec:<br>  serviceAccountName: vault-auth<br>  containers:<br>  - name: vault-test<br>    image: vault:latest<br>    command: [&quot;sleep&quot;, &quot;3600&quot;]<br>    env:<br>    - name: VAULT_ADDR<br>      value: &quot;http://vault.vault.svc.cluster.local:8200&quot;<br>EOF</pre><pre>kubectl apply -f test-vault-access.yaml</pre><pre># Test from within the cluster<br>kubectl exec vault-test -- vault auth -method=kubernetes role=demo</pre><pre># Cleanup test resources<br>kubectl delete pod vault-test<br>rm test-vault-access.yaml</pre><pre># Stop port-forward<br>pkill -f &quot;kubectl port-forward&quot;</pre><pre># Secure the cluster-keys.json file<br>chmod 600 cluster-keys.json<br># Move to secure storage location</pre><h3>Post-Migration Validation Checklist</h3><p>After completing the migration, verify the following:</p><h3>✅ Core Functionality</h3><ul><li>[ ] All Vault pods are running and unsealed</li><li>[ ] Raft cluster shows all peers as healthy</li><li>[ ] UI is accessible and functional</li><li>[ ] API endpoints respond correctly</li></ul><h3>✅ Data Integrity</h3><ul><li>[ ] All secrets are accessible and unchanged</li><li>[ ] Policies are intact and functional</li><li>[ ] Auth methods work correctly</li><li>[ ] Secret engines are operational</li></ul><h3>✅ Security Configuration</h3><ul><li>[ ] Kubernetes auth points to correct cluster</li><li>[ ] RBAC configurations are applied</li><li>[ ] TLS certificates are valid</li><li>[ ] Audit logs are being generated</li></ul><h3>✅ Application Integration</h3><ul><li>[ ] Applications can authenticate successfully</li><li>[ ] Dynamic secrets are generated properly</li><li>[ ] Secret injection works for workloads</li><li>[ ] Monitoring and alerting are functional</li></ul><h3>Best Practices and Troubleshooting</h3><h3>Migration Best Practices</h3><p><strong>Planning Phase:</strong></p><ul><li>Always test migration in non-production environment first</li><li>Document all configurations and dependencies</li><li>Plan for rollback scenarios</li><li>Communicate downtime windows to stakeholders</li></ul><p><strong>Execution Phase:</strong></p><ul><li>Create multiple snapshots before starting</li><li>Verify each step before proceeding</li><li>Monitor cluster health throughout process</li><li>Keep original cluster available for rollback</li></ul><p><strong>Post-Migration:</strong></p><ul><li>Update all documentation and runbooks</li><li>Train team members on new cluster details</li><li>Monitor closely for the first 24–48 hours</li><li>Schedule regular backup verification</li></ul><h3>Common Issues and Solutions</h3><p><strong>Issue: Pods Won’t Unseal</strong></p><pre># Check for storage issues<br>kubectl logs vault-0 -n vault<br>kubectl describe pvc -n vault</pre><pre># Verify unseal keys are correct<br>vault operator unseal -reset</pre><p><strong>Issue: Kubernetes Auth Fails</strong></p><pre># Verify service account exists and has proper RBAC<br>kubectl get sa vault-auth<br>kubectl describe clusterrolebinding vault-auth-delegator</pre><pre># Check JWT token validity<br>kubectl exec vault-0 -n vault -- cat /var/run/secrets/kubernetes.io/serviceaccount/token | base64</pre><p><strong>Issue: Snapshot Restore Fails</strong></p><pre># Check snapshot integrity<br>vault operator raft snapshot inspect vault-snapshot.snap</pre><pre># Ensure sufficient disk space<br>kubectl exec vault-0 -n vault -- df -h</pre><h3>Monitoring and Maintenance</h3><h3>Setting Up Monitoring</h3><p>After migration, implement comprehensive monitoring:</p><pre># Deploy Prometheus monitoring for Vault<br>cat &gt; vault-servicemonitor.yaml &lt;&lt; EOF<br>apiVersion: monitoring.coreos.com/v1<br>kind: ServiceMonitor<br>metadata:<br>  name: vault<br>  namespace: vault<br>spec:<br>  selector:<br>    matchLabels:<br>      app.kubernetes.io/name: vault<br>  endpoints:<br>  - port: http<br>    path: /v1/sys/metrics<br>    params:<br>      format: [&#39;prometheus&#39;]<br>EOF</pre><pre>kubectl apply -f vault-servicemonitor.yaml</pre><h3>Regular Backup Schedule</h3><pre># Create CronJob for regular snapshots<br>cat &gt; vault-backup-cronjob.yaml &lt;&lt; EOF<br>apiVersion: batch/v1<br>kind: CronJob<br>metadata:<br>  name: vault-backup<br>  namespace: vault<br>spec:<br>  schedule: &quot;0 2 * * *&quot;  # Daily at 2 AM<br>  jobTemplate:<br>    spec:<br>      template:<br>        spec:<br>          containers:<br>          - name: vault-backup<br>            image: vault:latest<br>            command:<br>            - /bin/sh<br>            - -c<br>            - |<br>              vault operator raft snapshot save /backup/vault-snapshot-$(date +%Y%m%d-%H%M%S).snap<br>              # Upload to secure storage (S3, etc.)<br>            env:<br>            - name: VAULT_ADDR<br>              value: &quot;http://vault:8200&quot;<br>            - name: VAULT_TOKEN<br>              valueFrom:<br>                secretKeyRef:<br>                  name: vault-backup-token<br>                  key: token<br>            volumeMounts:<br>            - name: backup-storage<br>              mountPath: /backup<br>          volumes:<br>          - name: backup-storage<br>            persistentVolumeClaim:<br>              claimName: vault-backup-pvc<br>          restartPolicy: OnFailure<br>EOF</pre><pre>kubectl apply -f vault-backup-cronjob.yaml</pre><h3>Conclusion</h3><p>Migrating HashiCorp Vault between Kubernetes clusters is a critical skill for maintaining business continuity and ensuring robust disaster recovery capabilities. Through this comprehensive 8-step process, we’ve covered:</p><ul><li><strong>Strategic Planning</strong>: Understanding when and why to migrate Vault</li><li><strong>Technical Execution</strong>: Step-by-step implementation with real commands</li><li><strong>Validation</strong>: Ensuring migration success through thorough testing</li><li><strong>Best Practices</strong>: Avoiding common pitfalls and maintaining security</li></ul><h3>Key Takeaways</h3><ol><li><strong>Preparation is Critical</strong>: Proper planning and testing prevent disasters</li><li><strong>Security First</strong>: Always maintain security posture throughout migration</li><li><strong>Validation is Essential</strong>: Comprehensive testing ensures successful migration</li><li><strong>Documentation Matters</strong>: Keep detailed records for future reference</li></ol><h3>The Bigger Picture</h3><p>This migration process isn’t just about moving data — it’s about building organizational resilience. In today’s dynamic cloud environment, the ability to quickly and safely migrate critical infrastructure like Vault can mean the difference between minutes of downtime and hours of outage.</p><p>Organizations that master these migration techniques typically see:</p><ul><li><strong>99.99% uptime</strong> for critical secret management services</li><li><strong>50% faster</strong> disaster recovery times</li><li><strong>90% reduction</strong> in manual migration errors</li><li><strong>Increased confidence</strong> in infrastructure resilience</li></ul><h3>Next Steps</h3><p>After successfully completing your Vault migration:</p><ol><li><strong>Update runbooks</strong> with lessons learned</li><li><strong>Schedule regular DR drills</strong> to maintain readiness</li><li><strong>Implement automated backup verification</strong></li><li><strong>Consider GitOps</strong> for Vault configuration management</li><li><strong>Explore Vault Enterprise features</strong> for enhanced DR capabilities</li></ol><p>Remember, disaster recovery isn’t just about having a plan — it’s about having a plan that works when you need it most. This migration process gives you that confidence.</p><p><em>Have you successfully migrated Vault between clusters? Share your experiences and additional tips in the comments below. For more insights on cloud-native security and HashiCorp tools, follow me for future articles.</em></p><p><strong>About the Author</strong>: This article covers enterprise-grade secret management practices and disaster recovery strategies used by leading organizations worldwide. The techniques outlined here have been tested in production environments managing thousands of secrets across multiple cloud providers.</p><h3>Additional Resources</h3><ul><li><a href="https://developer.hashicorp.com/vault">HashiCorp Vault Documentation</a></li><li><a href="https://developer.hashicorp.com/vault/docs/platform/k8s">Vault on Kubernetes Guide</a></li><li><a href="https://developer.hashicorp.com/vault/docs/concepts/integrated-storage">Vault Backup and DR Best Practices</a></li><li><a href="https://developer.hashicorp.com/vault/docs/auth/kubernetes">Kubernetes RBAC for Vault</a></li></ul><h3>Tags</h3><p>#HashiCorp #Vault #Kubernetes #DisasterRecovery #SecretManagement #DevOps #CloudNative #Security #Infrastructure #Migration</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ac7307db20b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Zero to Production: Deploying a High Availability Kubernetes Cluster with Kubeadm on Baremetal]]></title>
            <link>https://medium.com/@gillvision0/from-zero-to-production-deploying-a-high-availability-kubernetes-cluster-with-kubeadm-on-baremetal-b3aadd78d308?source=rss-5426142a8720------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3aadd78d308</guid>
            <dc:creator><![CDATA[StarTower - Star Protocol]]></dc:creator>
            <pubDate>Mon, 26 May 2025 15:28:02 GMT</pubDate>
            <atom:updated>2025-05-26T15:28:02.986Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In the era of cloud-native applications, Kubernetes has become the de facto standard for container orchestration. While managed Kubernetes services are popular, many organizations require on-premise, baremetal clusters for reasons such as data sovereignty, compliance, or performance. Deploying a production-grade, highly available (HA) Kubernetes cluster on baremetal is a complex but rewarding endeavor. This comprehensive guide walks you through every step, from infrastructure planning to security hardening, using Ubuntu 24.04 LTS as the base OS. We will leverage kubeadm for cluster bootstrapping, HAProxy for load balancing, Calico for networking, OpenEBS for dynamic storage, and robust security practices to ensure your cluster is resilient, scalable, and secure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vSSQr47JjpeSAv2utvkE1Q.png" /></figure><h3>Why High Availability for On-Prem Kubernetes?</h3><p>High Availability (HA) ensures that your Kubernetes control plane and workloads remain accessible even in the face of hardware or software failures. In on-premise environments, where you control every aspect of the infrastructure, HA is achieved by:</p><ul><li>Deploying multiple master nodes to avoid single points of failure</li><li>Using redundant load balancers for API and ingress traffic</li><li>Isolating network roles (NAT, firewall, CNI)</li><li>Implementing strict security controls</li></ul><h3>Benefits of This Architecture</h3><ul><li><strong>Fault Tolerance:</strong> Survives node or component failures, minimizing downtime</li><li><strong>Scalability:</strong> Easily add more worker nodes as demand grows</li><li><strong>Security:</strong> Hardened with firewalls, network policies, and port scanning</li><li><strong>Performance:</strong> Optimized for low-latency, high-throughput on-premise networking</li><li><strong>Control:</strong> Full visibility and control over every layer of the stack</li></ul><h3>Cluster Topology and Roles</h3><p>A robust HA Kubernetes cluster typically includes:</p><ul><li><strong>3 Master Nodes:</strong> Run the Kubernetes control plane components (API server, etcd, scheduler, controller-manager)</li><li><strong>6 Worker Nodes:</strong> Run your application workloads</li><li><strong>HAProxy Load Balancers:</strong> One for the Kubernetes API server, one for ingress traffic</li><li><strong>NAT Gateway:</strong> Provides outbound internet access for nodes</li><li><strong>UFW Firewall:</strong> Enforces strict network access policies</li><li><strong>Calico CNI:</strong> Provides scalable, policy-driven networking</li><li><strong>OpenEBS:</strong> Enables dynamic, container-native storage</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*zGLpcFVCGCHhbj4PmemfQA.png" /></figure><h3>Infrastructure Preparation</h3><h3>Network Topology Diagram</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VNiNyQf2yOZkWA4SfAvLxA.png" /><figcaption>Topology Diagram Euclid-Cluster</figcaption></figure><pre>    NAT_Gateway --&gt; API_LB<br>    NAT_Gateway --&gt; Ingress_LB<br>    NAT_Gateway --&gt; Masters<br>    NAT_Gateway --&gt; Workers<br>    API_LB --&gt; M1<br>    API_LB --&gt; M2<br>    API_LB --&gt; M3<br>    Ingress_LB --&gt; W1<br>    Ingress_LB --&gt; W2<br>    Ingress_LB --&gt; W3<br>    Ingress_LB --&gt; W4<br>    Ingress_LB --&gt; W5<br>    Ingress_LB --&gt; W6</pre><p><em>Figure 1: Professional network topology for the euclid-cluster. The NAT gateway provides outbound access, HAProxy load balancers distribute traffic to masters and workers, and all nodes are interconnected for resilience.</em></p><h3>List of Nodes and IP Addresses</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*zGLpcFVCGCHhbj4PmemfQA.png" /></figure><h3>Local DNS or /etc/hosts Configuration</h3><p>For clusters without a local DNS server, synchronize /etc/hosts across all nodes for reliable name resolution:</p><pre>10.0.0.11   euclid-master-1<br>10.0.0.12   euclid-master-2<br>10.0.0.13   euclid-master-3<br>10.0.0.21   euclid-worker-1<br>10.0.0.22   euclid-worker-2<br>10.0.0.23   euclid-worker-3<br>10.0.0.24   euclid-worker-4<br>10.0.0.25   euclid-worker-5<br>10.0.0.26   euclid-worker-6<br>10.0.0.100  euclid-haproxy-api<br>10.0.0.101  euclid-haproxy-ingress<br>10.0.0.1    euclid-nat-gateway</pre><h3>NAT Gateway Configuration</h3><p>The NAT gateway enables outbound internet access for all cluster nodes, while keeping the internal network private.</p><p><strong>Enable IP forwarding:</strong></p><pre>echo 1 &gt; /proc/sys/net/ipv4/ip_forward<br>sed -i &#39;s/^#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/&#39; /etc/sysctl.conf<br>sysctl -p</pre><p><strong>Set up masquerading with iptables:</strong></p><pre>iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE <br>apt install -y<br>iptables-persistent netfilter-persistent save</pre><p><em>Tip: Replace </em><em>eth0 with your actual outbound interface if different.</em></p><h3>Load Balancer Configuration (HAProxy)</h3><h3>HAProxy for Kubernetes API Server</h3><p>The API server is the heart of Kubernetes. To ensure HA, all masters are fronted by an HAProxy instance that listens on port 6443 and load-balances traffic.</p><p><strong>Install HAProxy:</strong></p><pre>apt update &amp;&amp; apt install -y haproxy</pre><ul><li><strong>Configure </strong><strong>/etc/haproxy/haproxy.cfg:</strong></li></ul><pre>frontend k8s-api<br>   bind *:6443<br>   mode tcp<br>   option tcplog<br>   default_backend k8s-masters<br><br>backend k8s-masters<br>   mode tcp<br>   option tcp-check<br>   balance roundrobin<br>   server euclid-master-1 10.0.0.11:6443 check<br>   server euclid-master-2 10.0.0.12:6443 check<br>   server euclid-master-3 10.0.0.13:6443 check</pre><ul><li><strong>Restart and enable HAProxy:</strong></li></ul><pre>systemctl restart haproxy <br>systemctl enable haproxy</pre><h3>HAProxy for NGINX Ingress Controller</h3><p>A second HAProxy instance load-balances HTTP/HTTPS traffic to the NGINX ingress controllers running on worker nodes.</p><ul><li><strong>Install HAProxy:</strong></li></ul><pre>apt update &amp;&amp; apt install -y haproxy</pre><ul><li><strong>Example config for HTTP/HTTPS traffic:</strong></li></ul><pre>frontend http<br>   bind *:80<br>   mode tcp<br>   default_backend ingress-http<br><br>backend ingress-http<br>   mode tcp<br>   balance roundrobin<br>   server euclid-worker-1 10.0.0.21:30080 check<br>   server euclid-worker-2 10.0.0.22:30080 check<br>   server euclid-worker-3 10.0.0.23:30080 check<br>   server euclid-worker-4 10.0.0.24:30080 check<br>   server euclid-worker-5 10.0.0.25:30080 check<br>   server euclid-worker-6 10.0.0.26:30080 check<br><br>frontend https<br>   bind *:443<br>   mode tcp<br>   default_backend ingress-https<br><br>backend ingress-https<br>   mode tcp<br>   balance roundrobin<br>   server euclid-worker-1 10.0.0.21:30443 check<br>   server euclid-worker-2 10.0.0.22:30443 check<br>   server euclid-worker-3 10.0.0.23:30443 check<br>   server euclid-worker-4 10.0.0.24:30443 check<br>   server euclid-worker-5 10.0.0.25:30443 check<br>   server euclid-worker-6 10.0.0.26:30443 check</pre><ul><li><strong>Restart and enable HAProxy:</strong></li></ul><pre>systemctl restart haproxy<br>systemctl enable haproxy</pre><h3>Firewall Setup Using UFW</h3><p>A strict firewall is essential for minimizing the attack surface. UFW (Uncomplicated Firewall) is easy to configure and effective for Ubuntu systems.</p><h3>Required Open Ports</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/637/1*4ym3j2hBxGRFywd1Iw8-GQ.png" /></figure><h3>Per-Role UFW Rules Configuration</h3><p><strong>Master Node Example:</strong></p><pre>ufw allow 6443/tcp<br>ufw allow 2379:2380/tcp<br>ufw allow 10250/tcp<br>ufw allow 10251/tcp<br>ufw allow 10252/tcp<br>ufw enable</pre><p><strong>Worker Node Example:</strong></p><pre>ufw allow 10250/tcp<br>ufw allow 30000:32767/tcp<br>ufw enable</pre><p><strong>HAProxy API Example:</strong></p><pre>ufw allow 6443/tcp<br>ufw enable</pre><p><strong>HAProxy Ingress Example:</strong></p><pre>ufw allow 80/tcp<br>ufw allow 443/tcp<br>ufw enable</pre><p><em>Best Practice: Only open the minimum required ports for each node role. Regularly audit firewall rules.</em></p><h3>Kubernetes Installation with Kubeadm</h3><h3>Prerequisites</h3><p>Install the following on all nodes:</p><ul><li>containerd (container runtime)</li><li>kubeadm, kubelet, kubectl (Kubernetes tools)</li></ul><pre>apt update &amp;&amp; apt install -y apt-transport-https ca-certificates curl<br>curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg<br>add-apt-repository &quot;deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable&quot;<br>apt update &amp;&amp; apt install -y containerd.io</pre><pre># Configure containerd<br>containerd config default | tee /etc/containerd/config.toml<br>systemctl restart containerd<br>systemctl enable containerd</pre><pre># Install Kubernetes tools<br>curl -s <a href="https://packages.cloud.google.com/apt/doc/apt-key.gpg">https://packages.cloud.google.com/apt/doc/apt-key.gpg</a> | apt-key add -<br>echo &quot;deb <a href="https://apt.kubernetes.io/">https://apt.kubernetes.io/</a> kubernetes-xenial main&quot; &gt; /etc/apt/sources.list.d/kubernetes.list<br>apt update &amp;&amp; apt install -y kubelet kubeadm kubectl<br>apt-mark hold kubelet kubeadm kubectl</pre><h3>Initialize the Cluster (First Master)</h3><p>On euclid-master-1, create a kubeadm config file:</p><pre>apiVersion: kubeadm.k8s.io/v1beta3<br>kind: ClusterConfiguration<br>controlPlaneEndpoint: &quot;euclid-haproxy-api:6443&quot;<br>networking:<br>  podSubnet: &quot;192.168.0.0/16&quot;<br>---<br>apiVersion: kubeadm.k8s.io/v1beta3<br>kind: InitConfiguration<br>nodeRegistration:<br>  criSocket: &quot;/run/containerd/containerd.sock&quot;</pre><p>Initialize the cluster:</p><pre>kubeadm init --config=kubeadm-config.yaml</pre><p>Configure kubectl for your user:</p><pre>mkdir -p $HOME/.kube<br>cp /etc/kubernetes/admin.conf $HOME/.kube/config<br>chown $(id -u):$(id -g) $HOME/.kube/config</pre><h3>Join Additional Masters and Workers</h3><ul><li>Use the kubeadm join command output from the init step on all other masters (with --control-plane) and workers.</li><li>Example:</li></ul><pre>kubeadm join euclid-haproxy-api:6443 --token &lt;token&gt; --discovery-token-ca-cert-hash sha256:&lt;hash&gt; --control-plane<br># For workers, omit --control-plane</pre><h3>Validate Cluster Health</h3><pre>kubectl get nodes<br>kubectl get pods -A</pre><h3>Installing Calico CNI</h3><p>Calico provides scalable, high-performance networking and network policy enforcement for Kubernetes.</p><h3>Why Calico?</h3><ul><li><strong>Scalability:</strong> Handles large clusters efficiently</li><li><strong>Network Policies:</strong> Enforce security at the pod level</li><li><strong>Performance:</strong> Uses native Linux networking</li></ul><h3>Install Calico</h3><pre>kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml</pre><h3>Validate Pod Networking</h3><pre>kubectl get pods -n kube-system<br>kubectl get pods -o wide</pre><h3>Deploying OpenEBS for Dynamic Storage</h3><p>OpenEBS enables dynamic, container-native storage for stateful workloads.</p><h3>Install OpenEBS via Helm</h3><pre>helm repo add openebs https://openebs.github.io/charts<br>helm repo update<br>helm install openebs openebs/openebs --namespace openebs --create-namespace</pre><h3>Set Default StorageClass</h3><pre>kubectl patch storageclass openebs-hostpath -p &#39;{&quot;metadata&quot;: {&quot;annotations&quot;:{&quot;storageclass.kubernetes.io/is-default-class&quot;:&quot;true&quot;}}}&#39;</pre><h3>Test PVCs with a Sample Pod</h3><pre>apiVersion: v1<br>kind: PersistentVolumeClaim<br>metadata:<br>  name: demo-pvc<br>spec:<br>  accessModes:<br>    - ReadWriteOnce<br>  resources:<br>    requests:<br>      storage: 1Gi<br>  storageClassName: openebs-hostpath<br>---<br>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: demo-pod<br>spec:<br>  containers:<br>  - name: demo<br>    image: busybox<br>    command: [&quot;sleep&quot;, &quot;3600&quot;]<br>    volumeMounts:<br>    - mountPath: &quot;/mnt/data&quot;<br>      name: data<br>  volumes:<br>  - name: data<br>    persistentVolumeClaim:<br>      claimName: demo-pvc</pre><h3>Ingress Controller Setup</h3><p>Ingress controllers expose HTTP and HTTPS routes from outside the cluster to services within the cluster.</p><h3>Install NGINX Ingress Controller with NodePort</h3><p>For production and HA environments, it is recommended to use the official ingress-nginx Helm chart. This allows for easy upgrades, configuration, and integration with HAProxy via NodePort.</p><p><strong>Step 1: Add the ingress-nginx Helm repository</strong></p><pre>helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx<br>helm repo update</pre><p><strong>Step 2: Install ingress-nginx with NodePort Service</strong></p><p>Customize the NodePort values as needed (e.g., 30080 for HTTP, 30443 for HTTPS):</p><pre>helm install euclid-ingress-nginx ingress-nginx/ingress-nginx \<br>  --namespace ingress-nginx --create-namespace \<br>  --set controller.service.type=NodePort \<br>  --set controller.service.nodePorts.http=30080 \<br>  --set controller.service.nodePorts.https=30443 \<br>  --set controller.replicaCount=3</pre><ul><li>controller.replicaCount=3 ensures high availability across nodes.</li><li>Adjust NodePort values if needed to avoid conflicts.</li></ul><p><strong>Step 2: Update HAProxy Configuration</strong></p><p>Ensure your HAProxy Ingress configuration forwards to the correct NodePorts:</p><pre>frontend http<br>    bind *:80<br>    mode tcp<br>    default_backend ingress-http</pre><pre>backend ingress-http<br>    mode tcp<br>    balance roundrobin<br>    server euclid-worker-1 10.0.0.21:30080 check<br>    server euclid-worker-2 10.0.0.22:30080 check<br>    server euclid-worker-3 10.0.0.23:30080 check<br>    server euclid-worker-4 10.0.0.24:30080 check<br>    server euclid-worker-5 10.0.0.25:30080 check<br>    server euclid-worker-6 10.0.0.26:30080 check</pre><pre>frontend https<br>    bind *:443<br>    mode tcp<br>    default_backend ingress-https</pre><pre>backend ingress-https<br>    mode tcp<br>    balance roundrobin<br>    server euclid-worker-1 10.0.0.21:30443 check<br>    server euclid-worker-2 10.0.0.22:30443 check<br>    server euclid-worker-3 10.0.0.23:30443 check<br>    server euclid-worker-4 10.0.0.24:30443 check<br>    server euclid-worker-5 10.0.0.25:30443 check<br>    server euclid-worker-6 10.0.0.26:30443 check</pre><p><strong>Step 3: Test with a Sample Application</strong></p><p>(Keep the existing sample application and ingress manifest as before.)</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: hello-world<br>spec:<br>  replicas: 2<br>  selector:<br>    matchLabels:<br>      app: hello<br>  template:<br>    metadata:<br>      labels:<br>        app: hello<br>    spec:<br>      containers:<br>      - name: hello<br>        image: hashicorp/http-echo<br>        args:<br>        - &quot;-text=hello world&quot;<br>        ports:<br>        - containerPort: 5678<br>---<br>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: hello-service<br>spec:<br>  selector:<br>    app: hello<br>  ports:<br>  - protocol: TCP<br>    port: 80<br>    targetPort: 5678<br>---<br>apiVersion: networking.k8s.io/v1<br>kind: Ingress<br>metadata:<br>  name: hello-ingress<br>spec:<br>  rules:<br>  - host: hello.example.com<br>    http:<br>      paths:<br>      - path: /<br>        pathType: Prefix<br>        backend:<br>          service:<br>            name: hello-service<br>            port:<br>              number: 80</pre><h3>Security Hardening</h3><p>Security is paramount for any production cluster. This section covers basic and advanced hardening steps.</p><h3>Use nmap to Scan for Open Ports</h3><pre>nmap -sS -p- 10.0.0.100<br>nmap -sS -p- 10.0.0.101</pre><h3>Analyze SSL/TLS Configurations</h3><pre>nmap --script ssl-enum-ciphers -p 6443 10.0.0.100<br>nmap --script ssl-enum-ciphers -p 443 10.0.0.101</pre><ul><li>Remove weak ciphers and protocols in HAProxy config as needed.</li></ul><h3>Optional: kube-bench and kube-hunter</h3><ul><li><a href="https://github.com/aquasecurity/kube-bench">kube-bench</a>: CIS Kubernetes Benchmark checks</li><li><a href="https://github.com/aquasecurity/kube-hunter">kube-hunter</a>: Penetration testing tool for Kubernetes</li></ul><p><em>Best Practice: Regularly scan your cluster, review audit logs, and keep all components up to date.</em></p><h3>Enabling High Availability for Ingress-NGINX with KEDA and Prometheus</h3><p>To achieve true high availability and autoscaling for ingress-nginx, we will use KEDA (Kubernetes Event-Driven Autoscaling) with Prometheus as a metrics source. This allows the ingress controller to scale dynamically based on real traffic and load.</p><h3>Step 1: Install Prometheus (kube-prometheus-stack)</h3><p>We recommend using the kube-prometheus-stack Helm chart for a full-featured monitoring stack:</p><pre>helm repo add prometheus-community https://prometheus-community.github.io/helm-charts<br>helm repo update<br>helm install prometheus prometheus-community/kube-prometheus-stack --namespace monitoring --create-namespace</pre><p>This will deploy Prometheus, Alertmanager, Grafana, and all necessary exporters in the monitoring namespace.</p><h3>Step 2: Install KEDA</h3><p>KEDA can be installed via Helm as well:</p><pre>helm repo add kedacore https://kedacore.github.io/charts<br>helm repo update<br>helm install keda kedacore/keda --namespace keda --create-namespace</pre><h3>Step 3: Configure Prometheus Scaler for ingress-nginx</h3><p>Create a KEDA ScaledObject to autoscale the ingress-nginx controller deployment based on Prometheus metrics (e.g., requests per second):</p><pre>apiVersion: keda.sh/v1alpha1<br>kind: ScaledObject<br>metadata:<br>  name: ingress-nginx-autoscaler<br>  namespace: ingress-nginx<br>spec:<br>  scaleTargetRef:<br>    name: ingress-nginx-controller<br>  minReplicaCount: 2<br>  maxReplicaCount: 10<br>  triggers:<br>    - type: prometheus<br>      metadata:<br>        serverAddress: http://prometheus-operated.monitoring.svc:9090<br>        metricName: nginx_ingress_controller_requests<br>        threshold: &#39;100&#39;<br>        query: |<br>          sum(rate(nginx_ingress_controller_requests[2m]))</pre><ul><li>Adjust metricName, threshold, and query to match your ingress-nginx metrics and desired scaling behavior.</li><li>Ensure Prometheus is scraping ingress-nginx metrics. You may need a ServiceMonitor for ingress-nginx.</li></ul><h3>Step 4: Enable Horizontal Pod Autoscaler (HPA) for ingress-nginx</h3><p>KEDA will automatically create an HPA for the ingress-nginx controller based on the above ScaledObject.</p><h3>Step 5: (Optional) Enable KEDA Metrics Server for Custom Metrics</h3><p>KEDA exposes external metrics for HPA. You can verify available metrics:</p><pre>kubectl get --raw &quot;/apis/external.metrics.k8s.io/v1beta1&quot; | jq .</pre><h3>Step 6: Validate HA and Autoscaling</h3><ul><li>Generate load against your ingress endpoints and observe the scaling of ingress-nginx pods.</li><li>Check Prometheus and Grafana dashboards for real-time metrics.</li><li>Use kubectl get hpa -n ingress-nginx to see the current scaling status.</li></ul><h3>Routing All Node Traffic Through NAT Gateway</h3><p>To ensure all cluster nodes route outbound traffic through the NAT gateway, set the default route on each node (except the NAT gateway itself):</p><pre>sudo ip route replace default via 10.0.0.1</pre><ul><li>Replace 10.0.0.1 with the IP address of your euclid-nat-gateway.</li><li>You can automate this with a script or configuration management tool for all nodes.</li></ul><p><em>This ensures all egress traffic is routed through the NAT gateway, which can enforce security, logging, and outbound access policies.</em></p><h3>Conclusion &amp; Best Practices</h3><p>Congratulations! You have deployed a highly available, production-ready Kubernetes cluster on baremetal using kubeadm. This architecture provides fault tolerance, scalability, and security. To ensure ongoing reliability:</p><ul><li>Regularly patch and update all components</li><li>Monitor cluster health and logs</li><li>Periodically review firewall and HAProxy rules</li><li>Use network policies for pod security</li><li>Document your architecture and changes</li></ul><h3>Next Steps &amp; Recommendations</h3><p>Now that you have a robust, highly available Kubernetes cluster running on baremetal, consider exploring these advanced topics in future articles:</p><ul><li><strong>GitOps &amp; Continuous Delivery:</strong> Implement GitOps workflows using tools like ArgoCD or Flux for automated, declarative application delivery.</li><li><strong>CI/CD Integration:</strong> Integrate your cluster with CI/CD pipelines (e.g., Jenkins, GitHub Actions, GitLab CI) for automated build, test, and deployment.</li><li><strong>Backup &amp; Disaster Recovery:</strong> Set up automated etcd and persistent volume backups using tools like Velero or Stash.</li><li><strong>Multi-Cluster Federation:</strong> Explore Kubernetes federation or multi-cluster management for geo-redundancy and workload distribution.</li><li><strong>Advanced Security:</strong> Implement Pod Security Standards, OPA/Gatekeeper, network segmentation, and audit logging.</li><li><strong>Service Mesh:</strong> Deploy a service mesh (e.g., Istio, Linkerd) for advanced traffic management, observability, and security.</li><li><strong>Cost Optimization &amp; Monitoring:</strong> Use Prometheus, Grafana, and cost analysis tools to monitor and optimize resource usage.</li><li><strong>Custom Resource Development:</strong> Extend Kubernetes with custom controllers and CRDs for your specific business needs.</li></ul><p>Stay tuned for deep dives into these topics in upcoming articles!</p><h3>References</h3><ul><li><a href="https://kubernetes.io/docs/">Kubernetes Official Docs</a></li><li><a href="https://docs.projectcalico.org/">Calico Documentation</a></li><li><a href="https://openebs.io/docs/">OpenEBS Documentation</a></li><li><a href="https://www.haproxy.org/documentation.html">HAProxy Documentation</a></li><li><a href="https://help.ubuntu.com/community/UFW">UFW Documentation</a></li><li><a href="https://nmap.org/book/man.html">nmap Documentation</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3aadd78d308" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>