<?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 Gayan Dissanayake on Medium]]></title>
        <description><![CDATA[Stories by Gayan Dissanayake on Medium]]></description>
        <link>https://medium.com/@gayan.dissanayake?source=rss-5016ec278afa------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*2DrhR4aq5368TthM</url>
            <title>Stories by Gayan Dissanayake on Medium</title>
            <link>https://medium.com/@gayan.dissanayake?source=rss-5016ec278afa------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 20:31:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gayan.dissanayake/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[DAST Inside GKE with OWASP ZAP and GitHub Actions]]></title>
            <link>https://medium.com/@gayan.dissanayake/dast-inside-gke-with-owasp-zap-and-github-actions-1f2af649ef2c?source=rss-5016ec278afa------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f2af649ef2c</guid>
            <category><![CDATA[owasp]]></category>
            <category><![CDATA[zap]]></category>
            <category><![CDATA[gke]]></category>
            <category><![CDATA[dast]]></category>
            <dc:creator><![CDATA[Gayan Dissanayake]]></dc:creator>
            <pubDate>Mon, 26 Oct 2026 11:42:40 GMT</pubDate>
            <atom:updated>2026-10-26T11:55:55.667Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How we added dynamic security testing to a private GKE cluster, scanned internal services without exposing them, and what broke along the way.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6WXOuL1qyEwC3Rt2Id1aFw.png" /></figure><h3>SonarQube was green. That wasn’t enough.</h3><p>Our microservices already had a solid pipeline: Maven tests, a SonarQube quality gate, Playwright end-to-end tests, a Trivy image scan, and GitOps deployment through ArgoCD. Every pull request went through all of it.</p><p>Then someone asked a simple question: <em>“Can we do DAST with SonarQube?”</em></p><p>The short answer is no. SonarQube is a <strong>SAST</strong> tool. It reads your source code and finds problems in it, but it never sends a single request to your running application. It can’t tell you that your API returns a stack trace on bad input, that a security header is missing, or that an endpoint is injectable once it’s deployed behind a real ingress.</p><p>That’s the job of <strong>DAST</strong> (Dynamic Application Security Testing): attacking the running app from the outside, the way a real attacker would. The most popular open-source DAST tool is <strong>OWASP ZAP</strong>, so that’s what we added.</p><p>The interesting part wasn’t choosing ZAP. It was fitting it into our setup:</p><ul><li>The GKE control plane is locked down with <strong>master authorized networks</strong> (only our WireGuard VPN IP is allowed).</li><li>The services we want to scan are <strong>internal ClusterIP services</strong> with no public ingress.</li><li>The cluster is <strong>GKE Autopilot</strong> with <strong>OPA Gatekeeper</strong> policies.</li><li>Deployments happen through <strong>ArgoCD</strong>, so the pipeline doesn’t directly control <em>when</em> the new version is live.</li></ul><p>This article walks through the design we ended up with, the full manifests and workflow, and the four problems we hit on the way.</p><h3>The design: ZAP as a short-lived Kubernetes Job</h3><p>Instead of running ZAP on the GitHub runner, we run it <strong>inside the cluster</strong> as a Kubernetes Job, one per pipeline run.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z1cY7NUHCbXpAb6cEQvrpw.png" /></figure><p>The pipeline never needs network access to the app itself, only to the Kubernetes API. ZAP reaches the service over normal cluster DNS.</p><p>This gives us three things:</p><ul><li><strong>No exposed services.</strong> ZAP calls http://employee-service.dev.svc.cluster.local directly. No ingress, no port-forward, no public IP.</li><li><strong>Zero idle cost.</strong> There’s no ZAP server running 24/7. The Job exists only for the few minutes a scan takes.</li><li><strong>A clean slate every time.</strong> Each scan starts from a fresh container, with no leftover session state from the last run.</li></ul><p>We considered running ZAP as a long-lived daemon with its API exposed, but that means another always-on service to secure, patch and pay for.</p><h3>The init container trick</h3><p>The scan Job’s pod has two containers:</p><ol><li><strong>zap (init container)</strong> runs the scan and writes report.html, report.json, report.md and an exit_code file to a shared emptyDir volume.</li><li><strong>report-holder (main container)</strong> is a tiny busybox that just sleeps. It starts only after the scan finishes, and keeps the pod alive long enough for the pipeline to kubectl cp the reports out.</li></ol><p>This avoids needing a GCS bucket, Workload Identity bindings, or any extra IAM setup just to get a few report files back. It also gives the pipeline a clean signal: when the main container is <em>running</em>, the scan is <em>done</em>.</p><h3>The Kubernetes manifests</h3><p>We keep ZAP in our manifest repo in the same numbered layout we use for everything else:</p><pre>zap/<br>├── 00-namespace.yaml<br>├── 01-serviceaccount.yaml<br>├── 02-rbac.yaml<br>├── 03-configmap.yaml<br>└── 04-job.yaml.tpl      # template, filled in by the pipeline</pre><p>Files 00 to 03 are applied once. The Job is a template, which is why it ends in .tpl (more on that in the lessons section).</p><h3>00 and 01: namespace and service account</h3><pre>apiVersion: v1<br>kind: Namespace<br>metadata:<br>  name: zap<br>---<br>apiVersion: v1<br>kind: ServiceAccount<br>metadata:<br>  name: zap-scanner<br>  namespace: zap<br>automountServiceAccountToken: false</pre><p>The scanner’s service account has <strong>no permissions at all</strong>. ZAP only needs network access to the target, not access to the Kubernetes API.</p><h3>02: RBAC for the pipeline</h3><p>The GitHub Actions service account gets rights in the zap namespace only: create and delete Jobs, read pods and logs, and pods/exec (which kubectl cp needs).</p><pre>apiVersion: rbac.authorization.k8s.io/v1<br>kind: Role<br>metadata:<br>  name: zap-job-runner<br>  namespace: zap<br>rules:<br>  - apiGroups: [&quot;batch&quot;]<br>    resources: [&quot;jobs&quot;]<br>    verbs: [&quot;create&quot;, &quot;get&quot;, &quot;list&quot;, &quot;delete&quot;]<br>  - apiGroups: [&quot;&quot;]<br>    resources: [&quot;pods&quot;]<br>    verbs: [&quot;get&quot;, &quot;list&quot;]<br>  - apiGroups: [&quot;&quot;]<br>    resources: [&quot;pods/log&quot;]<br>    verbs: [&quot;get&quot;]<br>  - apiGroups: [&quot;&quot;]<br>    resources: [&quot;pods/exec&quot;]<br>    verbs: [&quot;create&quot;]<br>---<br>apiVersion: rbac.authorization.k8s.io/v1<br>kind: RoleBinding<br>metadata:<br>  name: github-actions-zap-job-runner<br>  namespace: zap<br>subjects:<br>  - kind: User<br>    name: github-actions-sa@&lt;PROJECT_ID&gt;.iam.gserviceaccount.com<br>    apiGroup: rbac.authorization.k8s.io<br>roleRef:<br>  kind: Role<br>  name: zap-job-runner<br>  apiGroup: rbac.authorization.k8s.io</pre><p>On GKE, a Google service account authenticated through Workload Identity Federation shows up in Kubernetes RBAC as a User with its email as the name.</p><h3>03: rule tuning as a ConfigMap</h3><p>ZAP lets you set every rule to FAIL, WARN or IGNORE. This is how you decide what breaks the build:</p><pre>apiVersion: v1<br>kind: ConfigMap<br>metadata:<br>  name: zap-rules<br>  namespace: zap<br>data:<br>  zap-rules.tsv: |<br>    10020	WARN	(Missing Anti-clickjacking Header)<br>    10038	WARN	(Content Security Policy Header Not Set)<br>    10096	IGNORE	(Timestamp Disclosure)<br>    40012	FAIL	(Cross Site Scripting (Reflected))<br>    40018	FAIL	(SQL Injection)<br>    90020	FAIL	(Remote OS Command Injection)</pre><p>The values are <strong>tab-separated</strong>. If your editor converts tabs to spaces, ZAP silently ignores the file. You can generate the full list of rule IDs by running a scan once with -g zap-rules.tsv.</p><h3>04: the scan Job template</h3><pre>apiVersion: batch/v1<br>kind: Job<br>metadata:<br>  name: zap-${RUN_ID}<br>  namespace: zap<br>spec:<br>  backoffLimit: 0                # never retry a scan<br>  activeDeadlineSeconds: 3600    # hard stop after 1 hour<br>  ttlSecondsAfterFinished: 600   # self-cleanup as a safety net<br>  template:<br>    spec:<br>      serviceAccountName: zap-scanner<br>      automountServiceAccountToken: false<br>      restartPolicy: Never<br>      securityContext:<br>        runAsUser: 1000<br>        runAsNonRoot: true<br>        fsGroup: 1000<br>      initContainers:<br>        - name: zap<br>          image: ghcr.io/zaproxy/zaproxy:stable<br>          workingDir: /zap/wrk<br>          command: [&quot;/bin/bash&quot;, &quot;-c&quot;]<br>          args:<br>            - |<br>              cp /config/zap-rules.tsv /zap/wrk/zap-rules.tsv<br>              ${ZAP_SCRIPT} -t &quot;${ZAP_TARGET}&quot; -c zap-rules.tsv \<br>                -r report.html -J report.json -w report.md ${ZAP_EXTRA_OPTS}<br>              echo $? &gt; /zap/wrk/exit_code<br>              exit 0<br>          env:<br>            - name: ZAP_AUTH_HEADER_VALUE     # optional bearer token<br>              valueFrom:<br>                secretKeyRef: { name: zap-auth, key: header-value, optional: true }<br>          resources:<br>            requests: { cpu: &quot;1&quot;, memory: 2Gi }<br>            limits:   { cpu: &quot;1&quot;, memory: 4Gi }<br>          volumeMounts:<br>            - { name: wrk, mountPath: /zap/wrk }<br>            - { name: rules, mountPath: /config }<br>      containers:<br>        - name: report-holder<br>          image: busybox:1.36<br>          command: [&quot;sh&quot;, &quot;-c&quot;, &quot;sleep 900&quot;]<br>          resources:<br>            requests: { cpu: 50m, memory: 64Mi }<br>            limits:   { cpu: 50m, memory: 64Mi }<br>          volumeMounts:<br>            - { name: wrk, mountPath: /zap/wrk }<br>      volumes:<br>        - name: wrk<br>          emptyDir: {}<br>        - name: rules<br>          configMap:<br>            name: zap-rules</pre><p>A few details matter here:</p><ul><li><strong>The scan’s exit code is saved, not returned.</strong> ZAP exits with 1 on FAIL and 2 on WARN. If the init container failed, the pod would never reach report-holder and we&#39;d lose the reports. So we write the code to a file and always exit 0. The pipeline decides pass or fail later.</li><li><strong>backoffLimit: 0</strong> stops Kubernetes from re-running a scan that failed, which would attack your app a second time.</li><li><strong>ZAP_AUTH_HEADER_VALUE</strong> is read by ZAP&#39;s packaged scan scripts. If a zap-auth secret exists, every request carries your token. If it doesn&#39;t exist, optional: true means the pod still starts.</li></ul><h3>The GitHub Actions job</h3><p>Our workflow already had three jobs: test and analyze (SonarQube + Playwright), build and push, and update the Helm chart so ArgoCD deploys it. DAST becomes <strong>job 4</strong>, because it must scan the version this PR just deployed, not the previous one.</p><p>The settings live at the top of the workflow:</p><pre>env:<br>  APP_NAMESPACE: &#39;dev&#39;<br>  APP_DEPLOYMENT: &#39;employee-service&#39;<br>  ZAP_TARGET: &#39;http://employee-service.dev.svc.cluster.local/v3/api-docs&#39;<br>  ZAP_SCRIPT: &#39;zap-api-scan.py&#39;<br>  ZAP_EXTRA_OPTS: &#39;-f openapi&#39;<br>  ZAP_FAIL_ON_WARN: &#39;false&#39;</pre><p>The authentication and runner-IP whitelisting steps are identical to our SonarQube job, so here are just the steps that matter.</p><h3>Step 1: wait for ArgoCD to deploy the new image</h3><p>With GitOps, the pipeline pushes a commit and ArgoCD deploys it <em>eventually</em>. If ZAP starts too early, it scans the old version. So we poll until the Deployment runs the tag built in this run:</p><pre>- name: Wait for ArgoCD to deploy the new image<br>  run: |<br>    for i in $(seq 1 60); do        # up to 10 min<br>      IMG=$(kubectl -n &quot;$APP_NAMESPACE&quot; get deploy &quot;$APP_DEPLOYMENT&quot; \<br>        -o jsonpath=&#39;{.spec.template.spec.containers[*].image}&#39;)<br>      if [[ &quot;$IMG&quot; == *&quot;:${IMAGE_TAG}&quot;* ]]; then<br>        echo &quot;ArgoCD synced: $IMG&quot;; break<br>      fi<br>      [ &quot;$i&quot; -eq 60 ] &amp;&amp; { echo &quot;::error::ArgoCD did not deploy ${IMAGE_TAG}&quot;; exit 1; }<br>      sleep 10<br>    done<br>    kubectl -n &quot;$APP_NAMESPACE&quot; rollout status &quot;deploy/$APP_DEPLOYMENT&quot; --timeout=5m</pre><h3>Step 2: render and launch the Job</h3><pre>- name: Launch ZAP scan job<br>  run: |<br>    RUN_ID=&quot;${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}&quot;<br>    echo &quot;RUN_ID=$RUN_ID&quot; &gt;&gt; &quot;$GITHUB_ENV&quot;<br>    export RUN_ID<br>    envsubst &#39;${RUN_ID} ${ZAP_TARGET} ${ZAP_SCRIPT} ${ZAP_EXTRA_OPTS}&#39; \<br>      &lt; manifest/zap/04-job.yaml.tpl | kubectl apply -f -</pre><p>Note the explicit variable list passed to envsubst. Without it, envsubst replaces <em>every</em> $NAME in the file, and any unset one becomes an empty string. The moment someone adds a shell variable to the scan script, it would silently vanish from the rendered Job.</p><h3>Step 3: wait for the scan to finish</h3><p>The scan is done when the report-holder container is running. If the pod fails instead (usually ZAP running out of memory), we print its logs and stop:</p><pre>- name: Wait for scan to finish<br>  run: |<br>    JOB=&quot;zap-${RUN_ID}&quot;<br>    for i in $(seq 1 360); do       # up to 60 min<br>      POD=$(kubectl -n zap get pods -l job-name=&quot;$JOB&quot; \<br>        -o jsonpath=&#39;{.items[0].metadata.name}&#39; 2&gt;/dev/null || true)<br>      if [ -n &quot;$POD&quot; ]; then<br>        PHASE=$(kubectl -n zap get pod &quot;$POD&quot; -o jsonpath=&#39;{.status.phase}&#39;)<br>        DONE=$(kubectl -n zap get pod &quot;$POD&quot; \<br>          -o jsonpath=&#39;{.status.containerStatuses[0].state.running.startedAt}&#39;)<br>        if [ -n &quot;$DONE&quot; ]; then<br>          echo &quot;ZAP_POD=$POD&quot; &gt;&gt; &quot;$GITHUB_ENV&quot;<br>          kubectl -n zap logs &quot;$POD&quot; -c zap --tail=100 || true<br>          exit 0<br>        fi<br>        if [ &quot;$PHASE&quot; = &quot;Failed&quot; ]; then<br>          kubectl -n zap describe pod &quot;$POD&quot; | tail -20<br>          exit 1<br>        fi<br>      fi<br>      sleep 10<br>    done<br>    exit 1</pre><h3>Step 4: collect, publish and evaluate</h3><pre>- name: Collect reports<br>  if: always() &amp;&amp; env.ZAP_POD != &#39;&#39;<br>  run: kubectl -n zap cp &quot;${ZAP_POD}:/zap/wrk&quot; zap-reports -c report-holder</pre><pre>- name: Upload ZAP report<br>  if: always() &amp;&amp; env.ZAP_POD != &#39;&#39;<br>  uses: actions/upload-artifact@v4<br>  with:<br>    name: zap-report<br>    path: zap-reports/report.*</pre><pre>- name: Add ZAP summary to job page<br>  if: always()<br>  run: |<br>    [ -f zap-reports/report.md ] &amp;&amp; cat zap-reports/report.md &gt;&gt; &quot;$GITHUB_STEP_SUMMARY&quot; || true</pre><pre>- name: Evaluate ZAP result<br>  run: |<br>    CODE=$(cat zap-reports/exit_code 2&gt;/dev/null || echo 3)<br>    case &quot;$CODE&quot; in<br>      0) echo &quot;ZAP scan passed&quot; ;;<br>      1) echo &quot;::error::ZAP found FAIL-level issues&quot;; exit 1 ;;<br>      2) if [ &quot;$ZAP_FAIL_ON_WARN&quot; = &quot;true&quot; ]; then exit 1<br>         else echo &quot;::warning::ZAP found warnings&quot;; fi ;;<br>      *) echo &quot;::error::ZAP scan error ($CODE)&quot;; exit 1 ;;<br>    esac</pre><p>The Markdown report goes straight into the GitHub job summary, so reviewers see findings on the run page without downloading anything.</p><h3>Step 5: always clean up</h3><pre>- name: Delete ZAP job<br>  if: always() &amp;&amp; env.RUN_ID != &#39;&#39;<br>  run: kubectl -n zap delete job &quot;zap-${RUN_ID}&quot; --ignore-not-found</pre><pre>- name: Revoke GitHub Runner IP<br>  if: always()<br>  run: |<br>    gcloud container clusters update &quot;$GKE_CLUSTER&quot; --region=&quot;$GKE_REGION&quot; \<br>      --enable-master-authorized-networks \<br>      --master-authorized-networks=&quot;&lt;VPN_IP&gt;/32&quot;</pre><p>if: always() matters most on the last step. If a failed scan skipped it, the runner&#39;s IP would stay in your authorized networks.</p><h3>Four things that broke (and how we fixed them)</h3><p>None of these are in the ZAP docs. All of them cost us time.</p><h3>1. kubectl apply -f . tried to deploy the template</h3><p>The first time we applied the folder, the setup resources were created fine, and then this appeared:</p><pre>The Job &quot;zap-${RUN_ID}&quot; is invalid:<br>* metadata.name: Invalid value: &quot;zap-${RUN_ID}&quot;: a lowercase RFC 1123 subdomain must consist of...</pre><p>Of course: kubectl has no idea ${RUN_ID} is a placeholder. The fix was renaming the file to 04-job.yaml.tpl. kubectl apply only picks up .yaml, .yml and .json files, so the template is now skipped. As a bonus, ArgoCD will also ignore it if anyone ever points an Application at that folder.</p><h3>2. OPA Gatekeeper silently blocked the pod</h3><p>The next manual run created the Job, but no pod ever appeared. kubectl describe job showed why:</p><pre>Warning  FailedCreate  job-controller  Error creating: admission webhook<br>&quot;validation.gatekeeper.sh&quot; denied the request: [enforce-container-resources]<br>Container &#39;report-holder&#39; is missing resources.limits.cpu</pre><p>Our cluster enforces CPU limits on every container through Gatekeeper, and we had only set memory limits. The Job controller keeps retrying pod creation forever, so nothing fails loudly. You just wait.</p><p>The fix was adding CPU limits to <strong>both</strong> containers, including the init container, even though Gatekeeper only complained about one. If your cluster runs policy engines, check them all up front:</p><pre>kubectl get constraints</pre><p>Look especially for an allowed-registries policy. If ghcr.io or docker.io isn&#39;t allowed, mirror the ZAP and busybox images into your own Artifact Registry.</p><h3>3. Autopilot rewrites your resources</h3><p>GKE Autopilot adjusted our tiny report-holder requests up to its minimum and printed a warning. That&#39;s harmless. The part to watch is memory: Autopilot may cap limits at the requested amount, so the &quot;4Gi limit, 2Gi request&quot; you wrote might not be what you get. ZAP is a Java app and a full scan is memory-hungry. If scans die with an OOM, set the request to 4Gi as well.</p><h3>4. The scan “passed”, but tested nothing</h3><p>This one was the sneakiest. Our first successful run looked great: 66 passed checks, 1 warning, 0 failures. Then we read the top and bottom of the log:</p><pre>Total of 3 URLs<br>...<br>Job spider error accessing URL http://employee-service.dev.svc.cluster.local<br>status code returned : 404 expected 200</pre><p>ZAP’s <strong>baseline scan</strong> is a crawler. It opens the root URL and follows links. Our service is a REST API: there’s nothing at / and no links to follow. So ZAP found exactly three URLs (/, /robots.txt and /sitemap.xml), all returning 404, and never touched a single /api/... endpoint.</p><p>A green DAST result is only meaningful if you check <strong>how many URLs were scanned</strong>. For APIs, the baseline scan is the wrong tool.</p><h3>Scanning an API properly</h3><p>ZAP ships three packaged scans, and choosing the right one matters more than any other setting:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S6rxPjabd4E2xM6bU0egsw.png" /></figure><p>For a Spring Boot service, the easiest source of that spec is springdoc. Add the dependency and the spec appears at /v3/api-docs:</p><pre>&lt;dependency&gt;<br>  &lt;groupId&gt;org.springdoc&lt;/groupId&gt;<br>  &lt;artifactId&gt;springdoc-openapi-starter-webmvc-api&lt;/artifactId&gt;<br>  &lt;version&gt;2.8.9&lt;/version&gt;<br>&lt;/dependency&gt;</pre><p>Pick the springdoc version that matches your Spring Boot release. Then check the spec is reachable before touching the pipeline:</p><pre>kubectl -n dev port-forward svc/employee-service 8001:80 &amp;<br>curl -s localhost:8001/v3/api-docs | head -c 300</pre><p>Switching the pipeline over is just three env values:</p><pre>ZAP_TARGET: &#39;http://employee-service.dev.svc.cluster.local/v3/api-docs&#39;<br>ZAP_SCRIPT: &#39;zap-api-scan.py&#39;<br>ZAP_EXTRA_OPTS: &#39;-f openapi&#39;</pre><p>If the spec’s servers URL points somewhere ZAP can&#39;t reach (like localhost:8080), override it with -O <a href="http://payroll-employee-service.dev.svc.cluster.local./">http://employee-service.dev.svc.cluster.local.</a></p><h3>Before you turn on active scanning</h3><p>The API scan <strong>sends real attacks</strong>: SQL injection strings, XSS payloads and malformed input, to every endpoint, including POST, PUT and DELETE. In a shared dev environment, that means:</p><ul><li>junk records created in your database</li><li>existing records modified or deleted</li><li>other tests (like our Playwright suite) failing on the resulting data</li></ul><p>We run DAST after the E2E tests for exactly this reason. The cleaner option is a dedicated namespace with its own throwaway database, deployed only for scanning. Either way, <strong>never point an active scan at production</strong>.</p><p>Two more things worth setting up:</p><ul><li><strong>Authentication.</strong> If most endpoints return 401, ZAP tests almost nothing. Create the zap-auth secret once and every request carries your token:</li></ul><pre>kubectl -n zap create secret generic zap-auth \<br>  --from-literal=header-value=&quot;Bearer &lt;token&gt;&quot;</pre><ul><li><strong>A time cap.</strong> Add -T 30 to ZAP_EXTRA_OPTS to limit a scan to 30 minutes, so a large API can&#39;t hold the pipeline hostage.</li></ul><h3>Wrapping up</h3><p>Our pipeline now checks security from three angles on every pull request:</p><ul><li><strong>SonarQube</strong> reads the code (SAST).</li><li><strong>Trivy</strong> scans the container image for vulnerable packages.</li><li><strong>ZAP</strong> attacks the running service after ArgoCD deploys it (DAST).</li></ul><p>None of these replaces the others. Each one catches problems the others can’t see.</p><p>If you take one thing from this article, make it this: <strong>running ZAP is easy, but getting a meaningful result isn’t.</strong> Check the URL count on every scan, use the API scan for APIs, give ZAP a token if your endpoints need one, and keep active scans far away from production.</p><p>Next on our list is feeding ZAP’s JSON output into a vulnerability management tool like DefectDojo, so findings from SonarQube, Trivy and ZAP land in one place with deduplication and triage.</p><p><em>If this helped you, or you’ve solved these problems differently, I’d love to hear about it in the comments.</em></p><p>Sample Zap Report looks like below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*At3AtZir9Jkr3V55ijSMqQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f2af649ef2c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Playwright vs Selenium: Testing Modern Web Apps]]></title>
            <link>https://medium.com/@gayan.dissanayake/playwright-vs-selenium-testing-modern-web-apps-93c808b6df64?source=rss-5016ec278afa------2</link>
            <guid isPermaLink="false">https://medium.com/p/93c808b6df64</guid>
            <category><![CDATA[play-write]]></category>
            <dc:creator><![CDATA[Gayan Dissanayake]]></dc:creator>
            <pubDate>Wed, 14 Oct 2026 08:20:52 GMT</pubDate>
            <atom:updated>2026-10-14T08:20:52.831Z</atom:updated>
            <content:encoded><![CDATA[<p>Modern web apps are built as single-page applications with heavy JavaScript, real-time updates, and complex user flows spanning multiple tabs, iframes, and network calls. Testing them reliably requires tools that can keep up with that complexity without producing false failures. Playwright and Selenium are the two most widely used browser automation frameworks for this job, but they were built a decade and a half apart, and it shows in how each one handles modern apps.</p><p>This article demonstrates Playwright’s core capabilities against Selenium, explains why most teams testing modern apps are moving to Playwright, and walks through concrete use cases — including regression testing and critical path testing — along with a clear-eyed look at the advantages and disadvantages of each.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ge_bNRYoHJKBFrqr55w0-w.png" /></figure><h3>Why modern apps need a different tool</h3><p>Selenium was built in 2004, when apps were mostly server-rendered pages with occasional AJAX. It automates browsers through the WebDriver protocol — a standardized wire protocol that sends commands over HTTP to a driver process, which then relays them to the browser. That extra hop adds latency and, more importantly, no built-in understanding of whether the page is actually ready for the next action.</p><p>Modern apps break that assumption constantly: components render asynchronously, data arrives from APIs after the initial paint, animations delay clickability, and state is managed client-side across frameworks like React, Vue, or Angular. A test that clicks before the DOM has settled produces a flaky failure that has nothing to do with a real bug.</p><p>Playwright (Microsoft, 2020) was designed specifically for this environment. It talks to browsers through their native automation protocols (CDP for Chromium, equivalent protocols for Firefox and WebKit) instead of a generic wire protocol, and it auto-waits for elements to be visible, stable, and actionable before interacting with them. It also treats an isolated “browser context” as a first-class concept, so testing multi-tab flows, authenticated sessions, or multiple users at once doesn’t require separate browser instances the way classic Selenium setups often do.</p><h3>Capabilities: Playwright demonstrated against Selenium</h3><p>The table below lines up the capabilities that matter most for modern app testing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y1XtXKVYXCBj7dQugFliLQ.png" /></figure><p>The common thread is that Playwright was designed for the JavaScript-heavy, asynchronous nature of modern apps from the ground up, while Selenium’s flexibility comes from a broader but more assembled ecosystem.</p><h3>Use cases: regression testing and critical path testing</h3><p><strong>Regression testing</strong> — running a large, repeated suite after every code change to confirm nothing that used to work has broken.</p><ul><li>Modern apps ship frequently, so the regression suite runs constantly in CI. Playwright’s built-in parallelization and sharding keep a large suite fast enough to run on every pull request, not just nightly.</li><li>Its auto-waiting cuts down on the false failures that otherwise force teams to re-run or quarantine flaky regression tests, which over time erodes trust in the whole suite.</li><li>The Trace Viewer makes triaging a regression failure fast: a failed run replays step by step with screenshots, network calls, and console output, so the cause is usually clear without reproducing it locally.</li><li>Example: a suite of 500+ tests covering forms, navigation, and data tables across a large SaaS dashboard, run on every commit and sharded across CI workers to finish in minutes instead of hours.</li></ul><p><strong>Critical path testing</strong> — a smaller, high-confidence suite covering the handful of flows the business cannot ship without (login, checkout, core workflow completion).</p><ul><li>These tests need to be reliable above all else, since a false failure blocks a release. Playwright’s auto-waiting and native multi-tab/context support make flows like “log in, open a new tab, complete an OAuth redirect, return to the original tab” straightforward to automate accurately.</li><li>Network interception lets teams test critical paths under controlled conditions — simulating a slow payment API or a failed inventory check — without needing a real backend in that state.</li><li>Example: an e-commerce checkout flow tested end-to-end (add to cart → apply promo code → enter payment → confirm order) across Chromium, Firefox, and WebKit before every production deploy, gating the release if any browser fails.</li></ul><p>Selenium can perform both use cases, but teams typically need to build more of the supporting infrastructure themselves — a Grid setup for parallelism, a proxy for network control, and more disciplined explicit-wait patterns to keep critical path tests from flaking under load.</p><h3>Advantages of Playwright</h3><ul><li><strong>Fewer false failures.</strong> Auto-waiting removes most timing-related flakiness without extra code.</li><li><strong>Faster execution.</strong> Native protocol communication and built-in parallelism generally outperform Selenium + Grid setups.</li><li><strong>Better debugging.</strong> The Trace Viewer and codegen tool shorten the time from “test failed” to “root cause identified.”</li><li><strong>Multi-tab and multi-context testing built in.</strong> No manual window-handle juggling for popups, new tabs, or isolated sessions.</li><li><strong>Network mocking out of the box.</strong> No separate proxy tool needed to simulate slow or failed API responses.</li><li><strong>Modern async API.</strong> Cleaner syntax in JS/TS and Python, less boilerplate than Selenium’s explicit-wait patterns.</li><li><strong>One install, all browsers.</strong> npx playwright install sets up Chromium, Firefox, and WebKit together; no separate driver binaries to manage and version-match.</li></ul><h3>Disadvantages of Playwright</h3><ul><li><strong>No real Safari.</strong> WebKit is close to Safari but not identical; teams needing exact Safari/iOS verification still need real-device or Selenium-based testing.</li><li><strong>No Internet Explorer support.</strong> A blocker for organizations still supporting legacy enterprise browsers.</li><li><strong>Smaller language surface.</strong> No native Ruby, Kotlin, or PHP bindings, unlike Selenium’s broad language support.</li><li><strong>Younger ecosystem.</strong> Less Stack Overflow history, fewer third-party integrations, and fewer engineers with years of hands-on experience than Selenium.</li><li><strong>Not built for load testing.</strong> Neither tool is designed for high-concurrency load simulation — that’s JMeter/k6/Gatling territory — but this is worth repeating since Playwright is sometimes mistaken for a load-testing tool because it can run many browser instances in parallel.</li></ul><p>For comparison, Selenium’s main disadvantages are the flip side of Playwright’s advantages: more flakiness without careful explicit-wait discipline, slower execution, more manual setup for parallelism and network control, and a less polished debugging experience — offset by the widest language and legacy-browser support of any tool in this space.</p><h3>Conclusion</h3><p>For most new projects testing modern, JavaScript-heavy web apps, Playwright is the better default: less flaky, faster, better tooling, and built with today’s async, component-based apps in mind. Selenium remains the right choice when a project genuinely needs Internet Explorer support, exact Safari verification, a language Playwright doesn’t cover, or when an organization already has deep, working Selenium Grid infrastructure that isn’t worth migrating off. Many mature teams end up running both: Playwright for the bulk of regression and critical path coverage, with Selenium kept around narrowly for legacy browser compliance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93c808b6df64" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Microservices Traffic with Apache APISIX: Installation, Routing, Rate Limiting, and…]]></title>
            <link>https://medium.com/@gayan.dissanayake/mastering-microservices-traffic-with-apache-apisix-installation-routing-rate-limiting-and-c38649bb5200?source=rss-5016ec278afa------2</link>
            <guid isPermaLink="false">https://medium.com/p/c38649bb5200</guid>
            <category><![CDATA[apache-apisix]]></category>
            <dc:creator><![CDATA[Gayan Dissanayake]]></dc:creator>
            <pubDate>Mon, 28 Sep 2026 04:41:42 GMT</pubDate>
            <atom:updated>2026-09-28T04:41:42.491Z</atom:updated>
            <content:encoded><![CDATA[<h3>Mastering Microservices Traffic with Apache APISIX: Installation, Routing, Rate Limiting, and Security Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8tq-RQYu3AOBoo1jqfjszg.png" /></figure><p>Modern microservice architectures require high-performance management at the edge. <strong>Apache APISIX</strong> — a dynamic, real-time, high-performance API Gateway built on OpenResty and etcd—delivers ultra-low latency along with dynamic routing and dynamic plugin hot-reloading without service restarts.</p><p>Below is a complete hands-on guide to setting up APISIX, mapping upstreams, enforcing security policies, and understanding where APISIX stands in the current API gateway ecosystem.</p><h3>1. Deploying Apache APISIX &amp; Dashboard on Kubernetes</h3><p>To deploy APISIX on your Kubernetes cluster (such as GKE Autopilot or local Minikube) using Helm:</p><h3>Core APISIX Installation</h3><pre># Add APISIX Helm Repository<br>helm repo add apisix https://apache.github.io/apisix-helm-chart<br>helm repo update</pre><pre># Install APISIX into dedicated namespace<br>helm install apisix apisix/apisix   --create-namespace   --namespace apisix</pre><h3>Dashboard Installation</h3><pre># Add Dashboard Repository &amp; Install<br>helm repo add apisix-dashboard https://charts.apiseven.com<br>helm repo update</pre><pre>helm install apisix-dashboard apisix-dashboard/apisix-dashboard -n apisix</pre><p><strong><em>Note on Deprecation Warnings:</em></strong><em> The standard </em><em>apisix-dashboard Helm chart issues a deprecation warning in newer versions as the community shifts focus toward declarative GitOps workflows (e.g., using </em><em>apisix-ingress-controller and custom resources). However, the legacy dashboard remains fully operational for UI-based route configuration.</em></p><h3>Accessing the Control Plane &amp; Admin API</h3><p>Forward the required ports locally to interact with both the Admin API (port 9180) and the UI Dashboard (port 8080 mapped to container port 9000):</p><pre># 1. Forward Admin API Port<br>kubectl port-forward -n apisix svc/apisix-admin 9180:9180</pre><pre># 2. Forward Dashboard Port<br>export POD_NAME=$(kubectl get pods --namespace apisix -l &quot;app.kubernetes.io/name=apisix-dashboard,app.kubernetes.io/instance=apisix-dashboard&quot; -o jsonpath=&quot;{.items[0].metadata.name}&quot;)<br>kubectl --namespace apisix port-forward $POD_NAME 8080:9000</pre><p>To fetch your active Admin Key directly from the cluster configuration:</p><pre>kubectl get configmap apisix -n apisix -o yaml | grep -A5 admin_key</pre><h3>2. Dynamic Routing &amp; URI Rewriting</h3><p>APISIX decouples the client-facing API contract from the backend microservice implementation. Using the proxy-rewrite plugin, incoming requests matching /sample-app/api/* can be dynamically forwarded to backend nodes while stripping path prefixes on the fly.</p><p>Mapping standard upstream endpoints:</p><pre>curl http://127.0.0.1:9180/apisix/admin/routes/1   -H &#39;X-API-KEY: &lt;KEY&gt;&#39;   -X PUT -d &#39;{<br>    &quot;uri&quot;: &quot;/sample-app/api/*&quot;,<br>    &quot;methods&quot;: [&quot;GET&quot;, &quot;POST&quot;],<br>    &quot;plugins&quot;: {<br>      &quot;proxy-rewrite&quot;: {<br>        &quot;regex_uri&quot;: [&quot;^/sample-app/(.*)&quot;, &quot;/$1&quot;]<br>      }<br>    },<br>    &quot;upstream&quot;: {<br>      &quot;type&quot;: &quot;roundrobin&quot;,<br>      &quot;nodes&quot;: {<br>        &quot;10.128.0.3:8001&quot;: 1<br>      }<br>    }<br>  }&#39;</pre><h3>3. Protecting Services with Rate Limiting</h3><p>To prevent Denial of Service (DoS) attacks, brute-force attempts, and resource exhaustion, apply the limit-count plugin. The payload below restricts clients to <strong>1 request per 60-second window</strong> based on their IP address (remote_addr):</p><pre>curl http://127.0.0.1:9180/apisix/admin/routes/1   -H &#39;X-API-KEY: &lt;KEY&gt;&#39;   -X PUT -d &#39;{<br>    &quot;uri&quot;: &quot;/sample-app/api/*&quot;,<br>    &quot;methods&quot;: [&quot;GET&quot;, &quot;POST&quot;],<br>    &quot;plugins&quot;: {<br>      &quot;proxy-rewrite&quot;: {<br>        &quot;regex_uri&quot;: [&quot;^/sample-app/(.*)&quot;, &quot;/$1&quot;]<br>      },<br>      &quot;limit-count&quot;: {<br>        &quot;count&quot;: 1,<br>        &quot;time_window&quot;: 60,<br>        &quot;rejected_code&quot;: 429,<br>        &quot;key_type&quot;: &quot;var&quot;,<br>        &quot;key&quot;: &quot;remote_addr&quot;<br>      }<br>    },<br>    &quot;upstream&quot;: {<br>      &quot;type&quot;: &quot;roundrobin&quot;,<br>      &quot;nodes&quot;: {<br>        &quot;10.128.0.3:8001&quot;: 1<br>      }<br>    }<br>  }&#39;</pre><p><em>If a single IP attempts a second request within 60 seconds, APISIX instantly drops the connection with an </em><em>HTTP 429 Too Many Requests code without touching the backend microservice.</em></p><h3>4. The Critical Role of an API Gateway in Modern Security Architecture</h3><p>Exposing microservices directly to the public internet presents significant security risks. An API Gateway acts as the single point of entry (reverse proxy), enforcing perimeter defense before traffic reaches internal pods.</p><pre>                      +-----------------------------------+<br>                      |      Public Internet / Client     |<br>                      +-----------------------------------+<br>                                        |<br>                                        v<br>                       [ HTTP/HTTPS Requests (Port 80/443) ]<br>                                        |<br>                                        v<br>+-------------------------------------------------------------------------------+<br>|                             APACHE APISIX GATEWAY                             |<br>|                                                                               |<br>|  +-------------------------------------------------------------------------+  |<br>|  |                           Security Enforcement                          |  |<br>|  |  • TLS Termination   • WAF / IP Filtering   • Global Rate-Limiting      |  |<br>|  +-------------------------------------------------------------------------+  |<br>|                                       |                                       |<br>|  +-------------------------------------------------------------------------+  |<br>|  |                            Plugin Pipeline                              |  |<br>|  |  • Auth (JWT/OAuth2) • URI Rewrite          • Traffic Control (429)     |  |<br>|  +-------------------------------------------------------------------------+  |<br>+-------------------------------------------------------------------------------+<br>                                        |<br>                 +----------------------+----------------------+<br>                 | (Internal Network / Private VPC)            |<br>                 v                                             v<br>    +-------------------------+                   +-------------------------+<br>    | Backend Microservice A  |                   | Backend Microservice B  |<br>    |  (e.g., 10.128.0.3:8001)|                   |   (e.g., 10.128.0.4)    |<br>    +-------------------------+                   +-------------------------+</pre><h3>Key Security Benefits</h3><ul><li><strong>Attack Surface Reduction:</strong> Shields upstream IP addresses (10.128.0.3) and internal network topographies from public discovery.</li><li><strong>Centralized Authentication &amp; Authorization:</strong> Offloads JWT, OAuth2, and API key verification from application code to the edge.</li><li><strong>DDoS &amp; Abusive Traffic Mitigation:</strong> Rate-limiting plugins isolate abusive traffic at the perimeter.</li><li><strong>Zero-Trust Encryption:</strong> Handles incoming client TLS termination while seamlessly managing internal mTLS down to backend pods.</li></ul><h3>5. Apache APISIX vs. Other Open-Source API Gateways</h3><p>Selecting an API gateway depends on performance needs, existing tech stacks, and ecosystem dependencies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iH43O2dMOO_8VVunDg5QFA.png" /></figure><h3>Why Choose Apache APISIX?</h3><ol><li><strong>Zero Downtime Updates:</strong> Uses etcd to push configuration changes to data-plane nodes in milliseconds without reloading NGINX worker processes.</li><li><strong>Multi-Language Plugin Support:</strong> Allows developers to write custom gateway extensions in Java, Python, or Go using RPC runners alongside native Lua and WASM.</li><li><strong>Advanced Traffic Routing:</strong> RadixTree-based matching enables extremely fast, complex path- and header-based route resolution.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c38649bb5200" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Field notes · event-driven integration]]></title>
            <link>https://medium.com/@gayan.dissanayake/field-notes-event-driven-integration-df4df5e29f30?source=rss-5016ec278afa------2</link>
            <guid isPermaLink="false">https://medium.com/p/df4df5e29f30</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[apache-camel]]></category>
            <category><![CDATA[kafka]]></category>
            <dc:creator><![CDATA[Gayan Dissanayake]]></dc:creator>
            <pubDate>Wed, 16 Sep 2026 12:40:25 GMT</pubDate>
            <atom:updated>2026-09-16T12:40:25.716Z</atom:updated>
            <content:encoded><![CDATA[<h3>No Hardcoded Handshake</h3><p><em>Two services on a ABC platform needed to know about each other’s data without ever calling each other. Here’s what it actually took to wire that up with Kafka and Apache Camel — in order, including the six things that broke before it worked.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DVTza2lNLTjw3UuL7d7Dfw.png" /></figure><p>The request that started this arrived in one sentence: <em>employee-service and loan-service need to talk to each other, and I don’t want to hardcode the integration.</em> No further spec. No diagram. Just a constraint, which turned out to be the right amount of information — it ruled out the obvious lazy answer (one service calling the other’s REST API) before anyone had time to reach for it.</p><h3>01 The ask, and why it mattered</h3><p>Both services were freshly scaffolded Spring Boot apps, already running as separate deployments in Kubernetes. An employee record lives in one; a loan against that employee’s payroll lives in the other. The natural first instinct — have loan-service call GET /employees/{id} on employee-service whenever it needs a name or a department — is also the instinct that quietly wires two independently deployable services into one distributed monolith. Call it enough times and: employee-service&#39;s uptime becomes loan-service&#39;s uptime; a slow employee-service response becomes a slow loan-service response; and nobody can deploy one without thinking about the other.</p><p>So the rule was: no synchronous calls between them, ever. Whatever connects them has to let either one be down, slow, or mid-deploy without the other one noticing beyond a short delay.</p><h3>02 The shape of it</h3><p>Kafka as the transport, Apache Camel as the integration layer inside each service. Camel earns its keep here for one reason: a route is a legible, one-line description of where a message comes from and where it goes —</p><pre>from(&quot;direct:loanEvents&quot;)<br>        .marshal(format)<br>        .to(&quot;kafka:{{payroll.topics.loan-events}}?brokers={{kafka.bootstrap-servers}}&quot;);</pre><p>— independent of whatever the endpoint actually is. If this ever needs to become a different broker, or fan out to a second destination, that’s a URI change inside one route, not a rewrite of application code.</p><p>Each service publishes its own domain and consumes the other’s, over two topics:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*Z0THA2jvaTgJi-tUXt-ECQ.png" /></figure><blockquote>Neither service ever calls the other. employee-service publishes to payroll.employee-events and consumes payroll.loan-events; loan-service is the mirror image. Kafka is the only thing either side depends on.</blockquote><p>Each event is a flat envelope — an id, a type, the entity id, the fields the other side actually needs, and a timestamp:</p><pre>public record EmployeeEvent(<br>        String eventId,<br>        String eventType,     // EMPLOYEE_CREATED / _UPDATED / _DELETED<br>        Long employeeId,<br>        String name,<br>        String email,<br>        String department,<br>        Instant occurredAt) {}</pre><p>Each service keeps its own copy of the event shape it depends on rather than sharing a library — a small amount of duplication in exchange for never needing a coordinated release across two repos just to change a field.</p><h3>03 Two bugs before breakfast</h3><p>Before any of this touched a real cluster, I ran both services locally against a broker address that simply didn’t exist — on purpose, to see what “Kafka is down” actually looks like from the outside. It surfaced two problems that would have quietly defeated the entire point of decoupling.</p><h3>The readiness probe that Kafka could fail on my behalf</h3><p>Camel’s Kafka health check feeds straight into Spring Boot’s own readiness and liveness state. With no broker reachable, /actuator/health/readiness reported OUT_OF_SERVICE — meaning a Kafka outage would have pulled the HTTP API out of the load balancer&#39;s rotation entirely, on a cluster that also uses those same probes to decide whether to keep restarting the pod. The fix was one line:</p><pre>camel.health.consumers-enabled=false</pre><h3>The create call that quietly took sixty seconds</h3><p>The first version of the publisher looked reasonable and was wrong:</p><pre>producerTemplate.sendBody(&quot;direct:employeeEvents&quot;, event); // blocks the caller</pre><p>With the broker unreachable, POST /api/employees hung for the Kafka client&#39;s default metadata timeout — a full sixty seconds — then failed with a 500. The record-keeping half of the request had nothing to do with whether the notification half succeeded, so I made that explicit: fire-and-forget, with the failure handled inside the route instead of surfacing to the caller.</p><pre>producerTemplate.asyncSendBody(&quot;direct:employeeEvents&quot;, event);</pre><pre>// inside the route:<br>onException(Exception.class)<br>        .handled(true)<br>        .process(exchange -&gt; log.error(&quot;Failed to publish employee event: {}&quot;, ...));</pre><p>Same test, broker still unreachable: the same POST now returns in about 200 milliseconds with a 201, and the only trace of Kafka being down is one log line, roughly a minute later, nowhere near the request that triggered it.</p><p><em>Decoupling isn’t a property of the diagram. It’s a property of what happens when the thing you decoupled from is actually gone — and the only way to know is to make it gone and watch.</em></p><h3>04 Turning consumption into data</h3><p>Publishing and logging on receipt proves the pipe works, but it doesn’t answer the actual business question: <em>what loans does this employee have</em>, asked from inside employee-service, without employee-service ever picking up a phone to ask loan-service. So the consumer side of each route got a second job — not just log the event, but fold it into a small in-memory read-model, keyed by the id the other service will ask for:</p><pre>public void apply(LoanEvent event) {<br>    if (LoanEvent.DELETED.equals(event.eventType())) {<br>        loansByLoanId.remove(event.loanId());<br>        return;<br>    }<br>    loansByLoanId.put(event.loanId(), new LoanView(<br>            event.loanId(), event.employeeId(), event.amount(),<br>            event.status(), event.occurredAt()));<br>}</pre><p>That turns two new read endpoints into pure lookups against local state — no network call, no second service in the critical path, no shared point of failure:</p><p>ServiceEndpointBacked by employee‑service</p><p>GET /api/employees/{id}/loansloans mirrored from payroll.loan-events</p><p>loan‑service</p><p>GET /api/loans/{id}/employeeemployee mirrored from payroll.employee-events</p><p>It’s the same idea a cache gives you, except the cache is never stale by more than the time it takes one message to cross a topic, and it’s populated by the same event stream that’s already the source of truth for “did this change happen,” rather than a second, separate call built just to keep a copy warm.</p><h3>05 Proof, not faith</h3><p>Code that compiles and a pod that says Running are two different facts, and only one of them means anything works. The last step was making the other one true — end to end, against the real cluster, not a mock.</p><p>The first attempt produced a false negative worth mentioning: two throwaway test instances joined the <em>same</em> Kafka consumer groups as the already-deployed services, and a shared group means Kafka splits partitions between whoever’s listening — so the test messages kept landing on the real pods instead of the test ones, which briefly looked like a bug in the new code and wasn’t one. Pointing the test instances at a pair of disposable, isolated topics removed the ambiguity entirely. After that, the real proof — against the actual deployed services, real Kafka, no shortcuts:</p><p>shell</p><pre>$ curl -s -X POST localhost:8001/api/employees \<br>    -d &#39;{&quot;name&quot;:&quot;Jordan Blake&quot;,&quot;email&quot;:&quot;jordan.blake@example.com&quot;,&quot;department&quot;:&quot;Engineering&quot;}&#39;<br>{&quot;id&quot;:4,&quot;name&quot;:&quot;Jordan Blake&quot;,&quot;email&quot;:&quot;jordan.blake@example.com&quot;,&quot;department&quot;:&quot;Engineering&quot;}<br>$ curl -s -X POST localhost:8002/api/loans \<br>    -d &#39;{&quot;employeeId&quot;:4,&quot;amount&quot;:10000,&quot;purpose&quot;:&quot;Home renovation&quot;}&#39;<br>{&quot;id&quot;:4,&quot;employeeId&quot;:4,&quot;amount&quot;:10000,&quot;purpose&quot;:&quot;Home renovation&quot;,&quot;status&quot;:&quot;PENDING&quot;}<br>$ curl -s localhost:8001/api/employees/4/loans<br>[{&quot;loanId&quot;:4,&quot;employeeId&quot;:4,&quot;amount&quot;:10000,&quot;status&quot;:&quot;PENDING&quot;, ...}]  ✓ mirrored from loan-service<br>$ curl -s localhost:8002/api/loans/4/employee<br>{&quot;employeeId&quot;:4,&quot;name&quot;:&quot;Jordan Blake&quot;,&quot;department&quot;:&quot;Engineering&quot;, ...}  ✓ mirrored from employee-service</pre><p>Both directions, on the actual running services, populated by nothing but Kafka traffic neither service asked the other for directly.</p><h3>— Field notes</h3><p>A health check is a claim about what “healthy” means. Audit what it’s actually wired to before trusting it to gate traffic.</p><p>Async isn’t a performance nicety on the publish side of an event-driven system — it’s the whole point. A blocking call to the “decoupled” transport re-couples everything it touches.</p><p>Every infrastructure failure here came with an error message naming the exact violated rule. Reading it was always faster than guessing around it.</p><p>Two encryption layers that don’t know about each other don’t argue — they hang. A silent, exception-free stall is itself a symptom worth chasing.</p><p>A read-model is what turns “we publish events” into “the other service can actually answer questions with them.” Skipping it leaves the integration half-finished.</p><p>Nothing here called an employee’s loan-service phone number, and nothing ever will. That was the one requirement that mattered from the start — everything else was just what it took to make it true.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df4df5e29f30" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enforced Admission Control Policy Using Gatekeeper]]></title>
            <link>https://medium.com/@gayan.dissanayake/enforced-admission-control-policy-using-gatekeeper-6f490ae420bc?source=rss-5016ec278afa------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f490ae420bc</guid>
            <category><![CDATA[policy]]></category>
            <category><![CDATA[gatekeepers]]></category>
            <category><![CDATA[admission-controller]]></category>
            <dc:creator><![CDATA[Gayan Dissanayake]]></dc:creator>
            <pubDate>Fri, 11 Sep 2026 11:39:53 GMT</pubDate>
            <atom:updated>2026-09-11T11:39:53.550Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r4lx01s91P_6WAawWCcLIg.png" /></figure><h3>Four violations from one kubectl run, and what a blocked debug pod taught me about OPA Gatekeeper on GKE Autopilot</h3><p>I was troubleshooting a service in a GKE Autopilot cluster and did what everyone does: spin up a throwaway pod with curl in it and poke at things from inside the cluster.</p><pre>kubectl run debug-pod \<br>  -n default \<br>  --image=curlimages/curl:8.10.1 \<br>  --restart=Never \<br>  -it --rm -- sh</pre><p>Here’s what I got back:</p><pre>Error from server (Forbidden): admission webhook &quot;validation.gatekeeper.sh&quot; denied the request:<br>[enforce-container-resources] Container &#39;debug-pod&#39; is missing resources.limits.cpu<br>[enforce-container-resources] Container &#39;debug-pod&#39; is missing resources.limits.memory<br>[deny-root-execution] Container &#39;debug-pod&#39; must run as non-root. Set securityContext.runAsNonRoot=true or runAsUser &gt; 0<br>[restrict-to-allowed-namespaces] Deployments are strictly forbidden in &#39;default&#39;. Allowed namespaces are: [&quot;dev&quot;]</pre><p>Four violations. One command. Zero pods created.</p><p>My first reaction was mild annoyance. My second reaction was that this is exactly what I built the policies for, and it worked on the person most likely to cut corners: me.</p><p>This post walks through installing Gatekeeper, the three policies doing the enforcing, how to read the denial message properly, one subtle thing the Autopilot warning tells you, and the gaps I found in my own Rego once I went back and looked at it honestly.</p><h3>Installing Gatekeeper</h3><p>Gatekeeper ships as a Helm chart. Add the repo and refresh:</p><pre>helm repo add gatekeeper https://open-policy-agent.github.io/gatekeeper/charts<br>helm repo update</pre><pre>&quot;gatekeeper&quot; has been added to your repositories</pre><pre>Hang tight while we grab the latest from your chart repositories...<br>...Successfully got an update from the &quot;gatekeeper&quot; chart repository<br>...Successfully got an update from the &quot;jetstack&quot; chart repository<br>...Successfully got an update from the &quot;prometheus-community&quot; chart repository<br>...Successfully got an update from the &quot;bitnami&quot; chart repository<br>Update Complete. ⎈Happy Helming!⎈</pre><p>Then install it, with the validating webhook scoped to the workload kinds I actually care about:</p><pre>helm install gatekeeper gatekeeper/gatekeeper \<br>  --namespace gatekeeper-system \<br>  --create-namespace \<br>  &#39;--set=validatingWebhookTimeoutSeconds=3&#39; \<br>  &#39;--set=validaterules[0].apiGroups[0]=*&#39; \<br>  &#39;--set=validaterules[0].apiVersions[0]=*&#39; \<br>  &#39;--set=validaterules[0].operations[0]=CREATE&#39; \<br>  &#39;--set=validaterules[0].operations[1]=UPDATE&#39; \<br>  &#39;--set=validaterules[0].resources[0]=pods&#39; \<br>  &#39;--set=validaterules[0].resources[1]=deployments&#39; \<br>  &#39;--set=validaterules[0].resources[2]=statefulsets&#39; \<br>  &#39;--set=validaterules[0].resources[3]=daemonsets&#39; \<br>  &#39;--set=validaterules[0].resources[4]=jobs&#39;</pre><p>A few notes on that command, because the flags are doing more work than they look like they are.</p><p><strong>Add </strong><strong>--create-namespace unless </strong><strong>gatekeeper-system already exists.</strong> Helm&#39;s --namespace selects a namespace, it does not create one. Without the flag you get namespaces &quot;gatekeeper-system&quot; not found and no release.</p><p><strong>validaterules is the reason this install is worth customising.</strong> The chart&#39;s default validating webhook configuration is broad, which means the API server calls Gatekeeper on a very wide range of admission requests. Every one of those calls is a network hop in the critical path of writing to your cluster. Narrowing the rule to pods, deployments, statefulsets, daemonsets and jobs on CREATE and UPDATE does two things: it cuts the request volume hitting the webhook, and it shrinks the blast radius if Gatekeeper ever becomes unhealthy. Nothing outside those five kinds can be affected by an outage in the policy controller.</p><p>Note that the values use plural, lowercase <strong>resource</strong> names (pods), while the constraints later use singular, capitalised <strong>kind</strong> names (Pod). That&#39;s not an inconsistency in the tooling. The webhook configuration speaks the API server&#39;s resource vocabulary and the constraint matcher speaks the kind vocabulary. Mixing them up is a common way to end up with a policy that never fires, because the webhook was never invited to the request in the first place.</p><p><strong>Keep the webhook timeout short.</strong> Three seconds is a reasonable starting point. The webhook’s failure policy determines what happens when Gatekeeper doesn’t answer in time, and a long timeout on a struggling controller turns every pod creation in the cluster into a slow one.</p><p><strong>--set values need quoting in most shells.</strong> The square brackets in validaterules[0].resources[0] will be eaten by glob expansion if you leave them bare, which is why each one is wrapped in single quotes above.</p><p>Confirm it came up before you write any policy:</p><pre>kubectl get pods -n gatekeeper-system<br>kubectl get crd | grep gatekeeper</pre><p>You should see the audit controller and the webhook replicas running, plus the constrainttemplates.templates.gatekeeper.sh CRD. Once the templates are applied, each one generates its own CRD too, which is how K8sRequireResources becomes a thing you can kubectl get.</p><p>One GKE Autopilot caveat: Autopilot manages its own namespaces and will not let a third-party webhook intercept objects in them. That’s a guardrail rather than a problem, but it does mean the exclusions in your constraints and the exclusions Autopilot enforces are two separate layers, and you should not assume one covers the other.</p><h3>What’s doing the blocking</h3><p>The cluster runs <a href="https://open-policy-agent.github.io/gatekeeper/">OPA Gatekeeper</a> with three ConstraintTemplate + Constraint pairs. A ConstraintTemplate defines the logic in Rego and generates a new CRD. A Constraint is an instance of that CRD saying where the logic applies and with what parameters.</p><h3>1. Namespace restriction</h3><p>Workloads are only permitted in dev. Everything else is denied unless it&#39;s in the exclusion list.</p><pre>violation[{&quot;msg&quot;: msg}] {<br>  ns := input.review.object.metadata.namespace<br>  not namespace_is_allowed(ns, input.parameters.allowedNamespaces)<br>  msg := sprintf(&quot;Deployments are strictly forbidden in &#39;%v&#39;. Allowed namespaces are: %v&quot;,<br>                 [ns, input.parameters.allowedNamespaces])<br>}</pre><pre>namespace_is_allowed(ns, allowed_list) {<br>  ns == allowed_list[_]<br>}</pre><p>The constraint matches Deployment, StatefulSet, DaemonSet, Pod, and Job, and excludes the GKE-managed namespaces (kube-system, gke-system, gke-gmp-system, the gke-managed-* family) plus the operations tooling: gatekeeper-system, istio-system, argocd, apisix, cert-manager, prometheus, grafana, kiali, jaeger, sonarqube.</p><p>That exclusion list is not optional housekeeping. If you forget gatekeeper-system, you can lock Gatekeeper itself out of scheduling its own pods and end up with a cluster that rejects the fix for the problem it has.</p><h3>2. Required resource requests and limits</h3><p>Four separate violation rules, one each for requests.cpu, requests.memory, limits.cpu, and limits.memory.</p><pre>violation[{&quot;msg&quot;: msg}] {<br>  containers[c]<br>  not c.resources.limits.cpu<br>  msg := sprintf(&quot;Container &#39;%v&#39; is missing resources.limits.cpu&quot;, [c.name])<br>}</pre><pre>containers[c] { c := input.review.object.spec.containers[_] }<br>containers[c] { c := input.review.object.spec.template.spec.containers[_] }</pre><p>Those two containers rules at the bottom are the useful pattern. A bare Pod puts containers at spec.containers, while a Deployment or Job puts them at spec.template.spec.containers. Defining the same partial rule twice gives you one set that covers both, so the violation logic doesn&#39;t care what kind it&#39;s looking at.</p><h3>3. No root, no privilege escalation</h3><pre>violation[{&quot;msg&quot;: msg}] {<br>  containers[c]<br>  not is_non_root(c, input.review.object)<br>  msg := sprintf(&quot;Container &#39;%v&#39; must run as non-root. Set securityContext.runAsNonRoot=true or runAsUser &gt; 0&quot;, [c.name])<br>}</pre><pre>is_non_root(c, review) { c.securityContext.runAsNonRoot == true }<br>is_non_root(c, review) { c.securityContext.runAsUser &gt; 0 }<br>is_non_root(c, review) { review.spec.securityContext.runAsNonRoot == true }<br>is_non_root(c, review) { review.spec.securityContext.runAsUser &gt; 0 }<br>is_non_root(c, review) { review.spec.template.spec.securityContext.runAsNonRoot == true }<br>is_non_root(c, review) { review.spec.template.spec.securityContext.runAsUser &gt; 0 }</pre><p>Six definitions of is_non_root, and in Rego any one of them succeeding is enough. That covers the container-level security context and the pod-level one, for both bare pods and templated workloads. It means a team can set runAsNonRoot once at the pod level instead of repeating it on every container.</p><h3>Reading the denial properly</h3><p>Two things about that error output are worth pointing out.</p><p><strong>Gatekeeper returns every violation at once.</strong> It doesn’t stop at the first failure and make you fix problems one round trip at a time. All three constraints evaluated, all four violations came back in a single response. That’s a real developer-experience win over webhooks that fail fast, and it’s the difference between one fix and four rejected kubectl calls.</p><p><strong>The message wording gave away a bug.</strong> Look at the last line:</p><pre>[restrict-to-allowed-namespaces] Deployments are strictly forbidden in &#39;default&#39;.</pre><p>I didn’t create a Deployment. I created a Pod. The sprintf string is hardcoded to say &quot;Deployments&quot; while the constraint matches five different kinds. It&#39;s cosmetic, but policy messages are the only interface most developers ever have with your policies, and a message that describes the wrong object type sends people looking in the wrong place. The fix is one line:</p><pre>msg := sprintf(&quot;%v is not allowed in namespace &#39;%v&#39;. Allowed namespaces are: %v&quot;,<br>               [input.review.kind.kind, ns, input.parameters.allowedNamespaces])</pre><p>Write your violation messages as if the reader has never seen your Rego, because they haven’t.</p><h3>Actually getting the debug pod</h3><p>The fix is to stop arguing with the policy and satisfy it. Use the allowed namespace, and pass a --overrides blob that declares resources and a security context:</p><pre>kubectl run debug-pod \<br>  -n dev \<br>  --image=curlimages/curl:8.10.1 \<br>  --restart=Never -it --rm \<br>  --overrides=&#39;{<br>    &quot;spec&quot;: {<br>      &quot;securityContext&quot;: { &quot;runAsNonRoot&quot;: true, &quot;runAsUser&quot;: 1000 },<br>      &quot;containers&quot;: [{<br>        &quot;name&quot;: &quot;debug-pod&quot;,<br>        &quot;image&quot;: &quot;curlimages/curl:8.10.1&quot;,<br>        &quot;stdin&quot;: true,<br>        &quot;tty&quot;: true,<br>        &quot;resources&quot;: {<br>          &quot;requests&quot;: { &quot;cpu&quot;: &quot;250m&quot;, &quot;memory&quot;: &quot;256Mi&quot; },<br>          &quot;limits&quot;:   { &quot;cpu&quot;: &quot;250m&quot;, &quot;memory&quot;: &quot;256Mi&quot; }<br>        }<br>      }]<br>    }<br>  }&#39; -- sh</pre><p>One caution on runAsNonRoot. The kubelet validates it against the image&#39;s USER directive, and if the image declares a username rather than a numeric UID, the kubelet can&#39;t verify the user is non-root and the pod fails to start with an error about a non-numeric user. Setting runAsUser explicitly, as above, avoids that class of problem regardless of how the image is built.</p><p>Honestly, though, if your team needs a debug pod more than twice a month, don’t make everyone hand-assemble JSON overrides on the command line. Commit a debug-pod.yaml that already complies and tell people to kubectl apply it. Policies that are tedious to satisfy get routed around, and the route around is usually someone quietly getting an exclusion added.</p><h3>Gaps I found in my own policies</h3><p>Going back through the Rego after this, three things stood out.</p><p><strong>initContainers and </strong><strong>ephemeralContainers aren&#39;t covered.</strong> The containers rule only collects spec.containers and spec.template.spec.containers. An init container can run as root with no limits and sail straight through. So can an ephemeral container, which is what kubectl debug attaches to a running pod. The fix is more partial rules:</p><pre>containers[c] { c := input.review.object.spec.initContainers[_] }<br>containers[c] { c := input.review.object.spec.template.spec.initContainers[_] }<br>containers[c] { c := input.review.object.spec.ephemeralContainers[_] }</pre><p><strong>Privilege escalation is only blocked when explicitly requested.</strong> The rule fires on c.securityContext.allowPrivilegeEscalation == true. Omit the field entirely and there&#39;s no violation, even though omitting it is not the same as setting it to false in the kubelet&#39;s eyes. If the intent is &quot;this must be off,&quot; require it to be off:</p><pre>violation[{&quot;msg&quot;: msg}] {<br>  containers[c]<br>  not c.securityContext.allowPrivilegeEscalation == false<br>  msg := sprintf(&quot;Container &#39;%v&#39; must set securityContext.allowPrivilegeEscalation: false&quot;, [c.name])<br>}</pre><p>Absence-of-bad and presence-of-good are different policies. Pick the one you meant.</p><p><strong>The resource policy has no parameter schema.</strong> K8sRequireResources has no validation.openAPIV3Schema block, so there&#39;s nowhere to put a minimum or maximum. Right now it enforces that limits exist, not that they&#39;re sane. A container asking for 64 CPUs passes cleanly. Adding parameters for maximum allowed values is the natural next step, and it&#39;s the same shape as the allowedNamespaces parameter that policy #1 already uses.</p><h3>If you’re rolling this out on an existing cluster</h3><p>Do not go straight to deny. Constraints support an enforcementAction field, and the sequence that avoids an incident is:</p><ol><li>Deploy with enforcementAction: dryrun. Nothing is blocked.</li><li>Let the audit controller run. It periodically evaluates existing objects in the cluster against your constraints and writes results to the constraint’s status.violations. kubectl get k8srequireresources enforce-container-resources -o yaml will show you exactly what would have been rejected.</li><li>Fix the manifests that show up, or add legitimate namespaces to excludedNamespaces.</li><li>Optionally move to enforcementAction: warn so developers see the message without being blocked.</li><li>Switch to deny once the violation list is empty.</li></ol><p>Worth remembering that Gatekeeper’s validating webhook only fires on admission. Flipping to deny does not evict anything already running. Your non-compliant workloads keep running happily until the next time something tries to recreate them, which is usually a node upgrade, at the least convenient hour.</p><p>And a note on where this sits in the stack: a namespace restriction enforced by admission policy is a backstop, not an access control. RBAC is what should stop someone from creating workloads in default in the first place. Gatekeeper catches the CI pipeline with a stale -n flag and the engineer who forgot to switch contexts. Those are worth catching. They&#39;re just not the same problem as an untrusted user.</p><h3>The point</h3><p>The best outcome from a policy engine is a boring one: you try to do something careless, it explains what’s wrong in plain language, and you do the right thing instead. Four violations in one response, each naming the exact field to set.</p><p>The part I didn’t expect was how much reviewing my own denial message taught me. One wrong word in a sprintf sent me back to the Rego, and I came out with three real gaps to close. If you&#39;ve written Gatekeeper policies and never been blocked by them yourself, that&#39;s not evidence they work. It might just mean nobody&#39;s been running your fast path.</p><p>Go break your own cluster on purpose. Read the message carefully. It’s usually telling you more than you asked.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f490ae420bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Podman vs Docker: Which Container Tool Should You Actually Use?]]></title>
            <link>https://medium.com/@gayan.dissanayake/podman-vs-docker-which-container-tool-should-you-actually-use-3c6abb3d17ea?source=rss-5016ec278afa------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c6abb3d17ea</guid>
            <category><![CDATA[podman-vs-docker]]></category>
            <dc:creator><![CDATA[Gayan Dissanayake]]></dc:creator>
            <pubDate>Tue, 18 Aug 2026 08:45:20 GMT</pubDate>
            <atom:updated>2026-08-18T08:45:20.535Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Im-9YKECs9la6cIejfc6VQ.png" /></figure><p>If you’ve spent any time in the container world, you’ve probably heard someone insist that Podman is “just a drop-in replacement for Docker.” That’s true — and also a little misleading. Yes, you can alias docker=podman and keep typing the same commands you already know. But underneath that familiar CLI, the two tools take fundamentally different approaches to how containers actually run. And that difference matters more than most tutorials let on.</p><p>Let’s break down what’s really going on.</p><h3>The Core Difference: Daemon vs. Daemonless</h3><p>Docker was built around a client-server architecture. When you run docker run, your command talks to a background service called dockerd, which does the actual work of creating and managing containers. This daemon runs continuously in the background — and traditionally, it runs as root.</p><p>That root-level daemon is convenient, but it’s also a security concern. Anyone with access to the Docker socket effectively has root-equivalent access to the host machine. It’s a well-known attack surface, and it’s shaped a lot of hardening advice in production environments.</p><p>Podman throws that model out. There’s no daemon at all. When you run podman run, the command spins up the container as a direct child process, using components like conmon under the hood. No background service, nothing to manage or restart, and nothing that keeps running (and holding privileges) after your command finishes. If a container crashes, it doesn&#39;t take down some shared daemon process with it.</p><h3>Rootless by Design</h3><p>This is arguably Podman’s biggest selling point. It was built rootless-first, meaning ordinary users can run containers without needing elevated privileges from the start. That’s a meaningful security improvement, especially in shared or multi-tenant environments where you don’t want every developer effectively holding root access to the host.</p><p>Docker eventually added a rootless mode too, but it arrived later and still isn’t as seamless or widely adopted. If rootless operation is a hard requirement for your environment, Podman has the head start.</p><h3>Pods: Kubernetes Concepts, Locally</h3><p>Here’s where the name “Podman” actually makes sense. Podman natively supports the Kubernetes idea of a <em>pod</em> — a group of containers that share networking and IPC namespaces, running and scaling together as a single unit.</p><p>Docker doesn’t have this concept built in. You can get similar multi-container behavior through Docker Compose, but it’s a different model entirely. If your team already thinks in Kubernetes terms, Podman’s pod support can make local development feel more consistent with your production environment.</p><h3>Systemd Integration</h3><p>Podman plays nicely with systemd. You can generate unit files directly (podman generate systemd), or use the newer Quadlet approach, to make containers behave like proper native services — start on boot, restart on failure, logged through journald, the works. This is a natural fit if you&#39;re already running RHEL, Fedora, or CentOS, where Podman is the default container engine.</p><h3>The CLI Feels the Same (Mostly)</h3><p>One reason Podman has gained traction so quickly is that its command-line interface was deliberately designed to mirror Docker’s. Most docker commands work identically as podman commands. This is genuinely one of the easiest tool migrations in the infrastructure world — for basic build-and-run workflows, you may not need to relearn anything.</p><p>Where it gets shakier is Compose. podman-compose exists and covers a lot of ground, but it&#39;s not as mature or as widely battle-tested as Docker Compose. If your workflow leans heavily on complex docker-compose.yml files, expect some rough edges.</p><h3>Ecosystem and Tooling</h3><p>This is Docker’s home turf. Docker Hub, Docker Desktop, Docker Compose, and a massive body of tutorials, Stack Overflow answers, and third-party integrations give it an ecosystem advantage that’s hard to overstate. If you’re troubleshooting a weird edge case at 2 a.m., you’re statistically more likely to find someone who’s already solved your Docker problem than your Podman one.</p><p>Podman, backed by Red Hat, doesn’t ship with its own image registry — it relies on existing ones like Docker Hub or Quay. Podman Desktop exists as a GUI counterpart to Docker Desktop and is actively developed, but it has a smaller user base and correspondingly less community content.</p><p>Worth noting: Docker Desktop now requires a paid license for larger companies, which has pushed some organizations to reconsider their tooling — and Podman has been a direct beneficiary of that shift.</p><h3>So Which One Should You Pick?</h3><p>There’s no universally correct answer here — it really depends on what you’re optimizing for.</p><p><strong>Go with Docker if:</strong></p><ul><li>You want the most mature ecosystem and the best Compose support</li><li>Your team is already deep in Docker workflows and tooling</li><li>You don’t have strict rootless or root-daemon security requirements</li></ul><p><strong>Go with Podman if:</strong></p><ul><li>Security matters — especially rootless operation and avoiding a root-level daemon</li><li>You’re working in a RHEL/Fedora-based environment</li><li>You want native pod support that mirrors Kubernetes concepts</li><li>You want tight systemd integration for running containers as services</li></ul><p>For a lot of day-to-day development work, the practical experience is close enough that the decision often comes down to your organization’s security posture, your existing platform, or simply what your team already knows. Both are solid, both speak the same OCI container format, and switching between them is far less painful than switching, say, cloud providers.</p><p>If you’re just getting started and don’t have a strong reason to pick one, Docker’s ecosystem will probably get you unstuck faster. But if security and rootless operation are priorities from day one, it’s worth giving Podman a real try — you might not go back.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c6abb3d17ea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrating SonarQube with GitHub Actions: A Practical Walkthrough]]></title>
            <link>https://medium.com/@gayan.dissanayake/integrating-sonarqube-with-github-actions-a-practical-walkthrough-6e7bbd0e2037?source=rss-5016ec278afa------2</link>
            <guid isPermaLink="false">https://medium.com/p/6e7bbd0e2037</guid>
            <category><![CDATA[sonarqube]]></category>
            <dc:creator><![CDATA[Gayan Dissanayake]]></dc:creator>
            <pubDate>Tue, 21 Jul 2026 04:59:37 GMT</pubDate>
            <atom:updated>2026-07-21T04:59:37.492Z</atom:updated>
            <content:encoded><![CDATA[<p>Code quality doesn’t happen by accident. It happens when a project makes it <em>hard</em> to merge bad code and <em>easy</em> to catch problems early. One of the most reliable ways to enforce that discipline on a TypeScript/React frontend is to wire <strong>SonarQube</strong> static analysis directly into your <strong>GitHub Actions</strong> CI pipeline — so every pull request gets scanned automatically, before a human reviewer even opens the diff.</p><p>This article walks through a real, working setup: a sonar-project.properties configuration file and a GitHub Actions workflow that scans the code, checks the Quality Gate, and reports results — using a frontend project (frontend-demo) as the example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BzJPuo3K0i7L8MY3hJ6sMA.png" /></figure><h3>Why Bother With SonarQube in CI?</h3><p>Linting catches style issues. TypeScript catches type errors. But neither tells you about:</p><ul><li>Duplicated logic scattered across components</li><li>Cyclomatic complexity creeping up in a “simple” utility function</li><li>Security hotspots like unsanitized inputs or hardcoded secrets</li><li>Test coverage silently dropping as new features ship without tests</li></ul><p>SonarQube fills that gap. Running it as a manual, occasional check is better than nothing — but running it automatically on every push and pull request turns it into a real quality gate rather than a suggestion nobody reads.</p><h3>Step 1: Define the Project With sonar-project.properties</h3><p>The scanner needs to know what to analyze, what to ignore, and how to interpret coverage data. Here’s the configuration used for this project:</p><pre># ==============================================================<br># SonarQube Project Configuration<br># Project: frontend-demo<br># ==============================================================</pre><pre># --- Project Identification ---<br>sonar.projectKey=frontend-demo<br>sonar.projectName=Frontend Demo Project<br>sonar.projectVersion=1.0</pre><pre># --- Source &amp; Language ---<br>sonar.sources=src<br>sonar.language=ts</pre><pre># --- Source Inclusions &amp; Exclusions ---<br>sonar.inclusions=**/*.ts,**/*.tsx,**/*.js,**/*.jsx<br>sonar.exclusions=\<br>  **/node_modules/**,\<br>  **/dist/**,\<br>  **/.git/**,\<br>  **/public/**,\<br>  **/nginx/**,\<br>  **/*.config.ts,\<br>  **/*.config.js,\<br>  **/vite.config.ts,\<br>  **/eslint.config.js,\<br>  **/middleware.ts</pre><pre># --- Test Configuration ---<br>sonar.tests=src<br>sonar.test.inclusions=\<br>  **/*.test.ts,\<br>  **/*.test.tsx,\<br>  **/*.spec.ts,\<br>  **/*.spec.tsx</pre><pre># --- Code Coverage ---<br>sonar.javascript.lcov.reportPaths=coverage/lcov.info<br>sonar.coverage.exclusions=\<br>  **/*.config.ts,\<br>  **/*.config.js,\<br>  **/vite.config.ts,\<br>  **/eslint.config.js,\<br>  **/middleware.ts,\<br>  src/main.tsx,\<br>  src/vite-env.d.ts</pre><pre># --- Duplication ---<br>sonar.cpd.exclusions=\<br>  **/*.test.ts,\<br>  **/*.test.tsx,\<br>  **/*.spec.ts,\<br>  **/*.spec.tsx</pre><pre># --- Encoding ---<br>sonar.sourceEncoding=UTF-8</pre><pre># --- SCM ---<br>sonar.scm.provider=git</pre><p>A few design choices worth calling out:</p><ul><li><strong>sonar.exclusions keeps build tooling out of the analysis.</strong> Config files, vite.config.ts, eslint.config.js, and middleware don&#39;t represent application logic, so scanning them just adds noise to the report.</li><li><strong>sonar.coverage.exclusions is deliberately broader than </strong><strong>sonar.exclusions.</strong> Files like src/main.tsx (the app&#39;s entry point) are legitimately hard to unit test and shouldn&#39;t drag the overall coverage percentage down artificially.</li><li><strong>sonar.cpd.exclusions excludes test files from duplication checks.</strong> Test suites often repeat similar setup/assertion patterns by design — that&#39;s not the kind of duplication worth flagging.</li></ul><p>This file lives at the project root and is picked up automatically by the SonarQube scanner during CI.</p><h3>Step 2: Store Credentials as GitHub Secrets</h3><p>Before writing the workflow, add two repository secrets under <strong>Settings → Secrets and variables → Actions</strong>:</p><p>Secret Purpose SONAR_TOKEN Authentication token generated from your SonarQube/SonarCloud project SONAR_HOST_URL The URL of your SonarQube server (e.g. <a href="https://sonarqube.yourcompany.com)/">https://sonarqube.yourcompany.com)</a></p><p>Never hardcode these in the workflow file — GitHub Actions injects them as environment variables at runtime, keeping them out of logs and version control.</p><h3>Step 3: Build the GitHub Actions Workflow</h3><p>The workflow below runs on pushes and pull requests, verifies the secrets are actually configured, confirms the SonarQube server is reachable, runs the scan, and then enforces the Quality Gate result.</p><pre>name: CI/CD Pipeline<br>on:<br>  push:<br>    branches: [main, development]<br>  pull_request:<br>    branches: [main, development]<br>jobs:<br>  sonar-analysis:<br>    runs-on: ubuntu-latest<br>    steps:<br>      # ── 1. Checkout code ────────────────────────────────────────────<br>      - name: Checkout repository<br>        uses: actions/checkout@v4<br>        with:<br>          fetch-depth: 0   # SonarQube needs full history for blame/duplication data</pre><pre>      # ── 2. Set up Node.js ────────────────────────────────────────────<br>      - name: Set up Node.js<br>        uses: actions/setup-node@v4<br>        with:<br>          node-version: &#39;20&#39;<br>          cache: &#39;npm&#39;</pre><pre>      # ── 3. Install dependencies ──────────────────────────────────────<br>      - name: Install dependencies<br>        run: npm ci</pre><pre>      # ── 4. Run linter ────────────────────────────────────────────────<br>      - name: Run ESLint<br>        run: npm run lint<br>        continue-on-error: true</pre><pre>      # ── 5. Run tests with coverage ───────────────────────────────────<br>      - name: Run tests with coverage<br>        run: npm run test -- --coverage<br>        continue-on-error: true</pre><pre>      # ── 6. Check SonarQube secrets ───────────────────────────────────<br>      - name: Check SonarQube secrets<br>        run: |<br>          if [ -z &quot;$SONAR_TOKEN&quot; ]; then<br>            echo &quot;SONAR_TOKEN is NOT set&quot;<br>          else<br>            echo &quot;SONAR_TOKEN is set (length: ${#SONAR_TOKEN})&quot;<br>          fi<br>          if [ -z &quot;$SONAR_HOST_URL&quot; ]; then<br>            echo &quot;SONAR_HOST_URL is NOT set&quot;<br>          else<br>            echo &quot;SONAR_HOST_URL is set: $SONAR_HOST_URL&quot;<br>          fi<br>        continue-on-error: true<br>        env:<br>          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}<br>          SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}</pre><pre>      # ── 7. Check SonarQube reachability ──────────────────────────────<br>      - name: Check SonarQube reachability<br>        run: |<br>          echo &quot;Testing connection to SonarQube...&quot;<br>          curl -v --max-time 10 &quot;$SONAR_HOST_URL/api/system/status&quot; \<br>            -u &quot;$SONAR_TOKEN:&quot; \<br>            || echo &quot;Connection FAILED — server unreachable&quot;<br>        continue-on-error: true<br>        env:<br>          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}<br>          SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}</pre><pre>      # ── 8. SonarQube Scan ─────────────────────────────────────────────<br>      - name: SonarQube Scan<br>        uses: SonarSource/sonarqube-scan-action@v6<br>        continue-on-error: true<br>        env:<br>          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}<br>          SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}</pre><pre>      # ── 9. Quality Gate check (fails pipeline if gate is RED) ─────────<br>      - name: SonarQube Quality Gate<br>        uses: SonarSource/sonarqube-quality-gate-action@v1<br>        timeout-minutes: 5<br>        continue-on-error: true<br>        env:<br>          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}<br>          SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}</pre><h3>What each stage is actually doing</h3><ol><li><strong>Checkout with full history</strong> — fetch-depth: 0 matters here. SonarQube&#39;s blame and duplication features rely on git history; a shallow clone gives incomplete results.</li><li><strong>Diagnostic steps (6 &amp; 7)</strong> — these aren’t strictly required for the scan to run, but they save enormous debugging time. Instead of a cryptic scanner failure, you immediately see whether the problem is a missing secret or an unreachable server.</li><li><strong>The scan itself (8)</strong> — sonarqube-scan-action automatically reads sonar-project.properties from the repo root, so no extra flags are needed in the workflow.</li><li><strong>The Quality Gate (9)</strong> — this is the step that actually enforces standards. SonarQube evaluates the scan against your configured Quality Gate (e.g. “no new bugs,” “coverage on new code ≥ 80%,” “no critical vulnerabilities”) and returns pass/fail.</li></ol><h3>A note on continue-on-error: true</h3><p>Every step here is marked continue-on-error: true, which means the pipeline won&#39;t hard-fail even if analysis breaks. That&#39;s a reasonable <em>rollout</em> posture — useful while you&#39;re first wiring up SonarQube and don&#39;t want a flaky scanner blocking every PR. But it&#39;s a training-wheels setting, not an end state.</p><p>Once the integration is stable, remove continue-on-error from the Quality Gate step (step 9) specifically, so a red gate actually blocks the merge:</p><pre>- name: SonarQube Quality Gate<br>        uses: SonarSource/sonarqube-quality-gate-action@v1<br>        timeout-minutes: 5<br>        env:<br>          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}<br>          SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}</pre><p>Without that change, SonarQube becomes a dashboard nobody has to listen to — which defeats the purpose of putting it in CI in the first place.</p><h3>Step 4: Read the Results</h3><p>Once the workflow runs, results show up in two places:</p><ul><li><strong>The GitHub Actions log</strong>, showing the raw scan output and Quality Gate status</li><li><strong>The SonarQube dashboard</strong>, at the URL in SONAR_HOST_URL, showing bugs, vulnerabilities, code smells, coverage, and duplication trends per commit and pull request</li></ul><p>If you’re using SonarCloud with GitHub integration enabled, results also appear directly as PR annotations and a status check — reviewers see flagged lines inline without leaving GitHub.</p><h3>Common Pitfalls</h3><ul><li><strong>Coverage report path mismatches.</strong> sonar.javascript.lcov.reportPaths=coverage/lcov.info only works if your test runner (Vitest/Jest) is actually configured to emit an lcov report at that path. If coverage shows 0% despite passing tests, this is almost always the culprit.</li><li><strong>Shallow clones.</strong> Forgetting fetch-depth: 0 produces incomplete blame data and can break new-code Quality Gate conditions, which compare against a reference branch.</li><li><strong>Token scope.</strong> A SONAR_TOKEN generated for the wrong project, or with expired/insufficient permissions, fails silently in some scanner versions — which is exactly why the reachability check in step 7 earns its keep.</li><li><strong>Exclusion drift.</strong> As the project grows, new config files or generated code can slip into the analysis and skew metrics. Revisit sonar.exclusions and sonar.coverage.exclusions periodically rather than setting them once and forgetting them.</li></ul><h3>Conclusion</h3><p>Wiring SonarQube into GitHub Actions isn’t complicated, but it does reward being deliberate: a well-scoped sonar-project.properties keeps the analysis meaningful, diagnostic steps in the workflow make failures debuggable instead of mysterious, and enforcing the Quality Gate (rather than just reporting it) is what actually turns code quality from an aspiration into a rule the pipeline enforces on your behalf.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6e7bbd0e2037" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Zero-Downtime IP Migration and DR Expansion on a Live MongoDB Replica Set]]></title>
            <link>https://medium.com/@gayan.dissanayake/zero-downtime-ip-migration-and-dr-expansion-on-a-live-mongodb-replica-set-6153a39c5962?source=rss-5016ec278afa------2</link>
            <guid isPermaLink="false">https://medium.com/p/6153a39c5962</guid>
            <category><![CDATA[migration]]></category>
            <category><![CDATA[mongodb]]></category>
            <dc:creator><![CDATA[Gayan Dissanayake]]></dc:creator>
            <pubDate>Mon, 13 Jul 2026 06:14:29 GMT</pubDate>
            <atom:updated>2026-07-13T06:14:29.459Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A field-notes walkthrough of moving a 3-node production replica set to a new subnet and joining three disaster-recovery nodes — without taking the cluster offline.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9v7GoCcxH6Wq5k8pTUGOpw.png" /></figure><h3>The situation</h3><p>We had a healthy 3-node MongoDB replica set (rs0) in production, each member reachable on two interfaces:</p><p>Node Role Old subnet New subnet Node 1 Primary 10.10.1.18 10.11.1.1 Node 2 Secondary 10.10.1.19 10.11.1.2 Node 3 Secondary 10.10.1.20 10.11.1.3</p><p>The task: shift the replica set’s identity from one subnet to the other, then later join three additional nodes from a disaster-recovery (DR) site — all while the cluster stayed live and serving traffic.</p><p>Two lessons from this exercise turned out to matter more than any single command: <strong>never touch more than one node at a time</strong>, and <strong>check </strong><strong>bindIp before you assume you need a restart at all</strong>.</p><h3>Rule one: protect the majority</h3><p>A 3-node replica set needs 2 of 3 members reachable to hold an election and accept writes. That single constraint shapes the entire migration strategy:</p><ul><li>Migrate <strong>secondaries first</strong>, one at a time, verifying full health before moving to the next.</li><li>Migrate the <strong>primary last</strong>, after stepping it down so the cluster never dips below quorum.</li><li>Never run two rs.reconfig() operations, or two node restarts, back to back.</li></ul><p>Every step below follows that discipline.</p><h3>Step 1: Confirm the starting state</h3><p>Before changing anything, rs.conf() and rs.status() from the primary gave us a clear baseline — three members, one primary, two healthy secondaries, matching configVersion across all nodes. This is the checkpoint to return to after every subsequent change.</p><h3>Step 2: The bindIp shortcut nobody mentions</h3><p>The instinct is to edit mongod.conf on every node and restart mongod for an IP change. But when we actually looked at the config:</p><pre>net:<br>  port: 27017<br>  bindIp: 0.0.0.0</pre><p>0.0.0.0 means the node was already listening on <strong>every interface</strong> — both subnets, simultaneously. That changed the entire plan. There was no need to touch mongod.conf or restart any service at all. The only thing that needed to change was the replica set&#39;s <em>membership record</em> — which IP MongoDB uses to refer to each node internally.</p><p>If your bindIp is already 0.0.0.0, an IP migration is just a sequence of rs.reconfig() calls. If it&#39;s pinned to specific addresses, you&#39;ll need the config-edit-and-restart dance described below as well.</p><h3>Step 3: Reconfigure secondaries, one at a time</h3><p>From mongosh on the primary:</p><pre>cfg = rs.conf()<br>cfg.members[1].host = &quot;10.11.1.2:27017&quot;<br>rs.reconfig(cfg)</pre><p>Then immediately verify before touching the next node:</p><pre>rs.status()</pre><p>Confirm the member shows health: 1 and stateStr: &#39;SECONDARY&#39; with the new address before repeating the same two commands for the third node.</p><h3>Step 4: Step down before touching the primary</h3><p>The primary’s own entry is the trickiest one to change, because you’re asking the current primary to update its own identity. The safe move is to step it down first:</p><pre>rs.stepDown(120)<br>rs.status()   // confirm a secondary has taken over</pre><p>Once a different node holds primary, reconfigure the old primary’s host entry exactly like the others, from whichever node is primary now:</p><pre>cfg = rs.conf()<br>cfg.members[0].host = &quot;10.11.1.1:27017&quot;<br>rs.reconfig(cfg)</pre><h3>Step 5: Verify the whole set</h3><pre>rs.conf()<br>rs.status()</pre><p>All members should show the new subnet, health: 1 across the board, one PRIMARY, two SECONDARY, and a matching configVersion everywhere. At this point the migration is functionally complete — what remains is updating everything <em>outside</em> MongoDB that still points at the old addresses: application connection strings, DNS/SRV records, monitoring agents, backup jobs, and firewall rules. Only once you&#39;re confident nothing depends on the old subnet should you remove it from bindIp (if it was ever pinned) and close the old firewall rules.</p><p>Reversing the migration later — moving back to the original subnet — is exactly the same procedure in the opposite direction. It’s worth pausing here to ask <em>why</em> a network is being flipped back and forth, since every cycle carries a small real risk during the primary step-down, even when executed carefully.</p><h3>Adding disaster-recovery nodes</h3><p>With the primary-site migration settled, the next phase was expanding the replica set to include three DR-site nodes — turning a 3-node set into 6.</p><h3>The voting-member trap</h3><p>The most consequential decision in this phase isn’t about IPs — it’s about <strong>votes</strong>. MongoDB replica sets should never have an even number of <em>voting</em> members, because ties during elections can stall failover exactly when you need it most. Naively adding 3 DR nodes as full voting members turns a clean 3-voter quorum into 6 — a mistake that’s easy to make and awkward to unwind later.</p><p>The fix: give every DR node priority: 0, votes: 0.</p><pre>rs.add({ host: &quot;10.12.1.1:27017&quot;, priority: 0, votes: 0 })<br>rs.add({ host: &quot;10.12.1.2:27017&quot;, priority: 0, votes: 0 })<br>rs.add({ host: &quot;10.12.1.13:27017&quot;, priority: 0, votes: 0 })</pre><p>Added one at a time, letting each finish its own initial sync before the next joins. This preserves:</p><ul><li><strong>3 voting members</strong> at the primary site — the quorum arithmetic never changes.</li><li><strong>Full data replication to DR</strong> — every write still lands on all six nodes.</li><li><strong>No automatic failover across the WAN</strong> — a flaky link to the DR site can never trigger an election or accidentally promote a DR node to primary. In a genuine site-loss scenario, promoting DR becomes a deliberate, manual rs.reconfig({ force: true }) action rather than something the cluster does on its own.</li></ul><h3>Watching initial sync</h3><p>New members don’t join as secondaries instantly — they go through STARTUP2 (cloning every collection from an existing member) before transitioning to SECONDARY. rs.status() surfaces this directly:</p><pre>rs.status().members.filter(m =&gt; m._id &gt;= 3)</pre><p>stateStr tells the whole story: STARTUP2 → RECOVERING → SECONDARY.</p><p>MongoDB doesn’t expose a clean percentage-complete figure for initial sync, but a close approximation comes from comparing data directory size on the source against the target as it grows:</p><pre># primary site<br>du -sh /data/mongo</pre><pre># each DR node, polled every few minutes<br>du -sh /data/mongo</pre><p>The ratio of the two gives a reasonable estimate, and watching the growth rate lets you project a rough time-to-completion. For a more granular view, tailing the DR node’s own log — filtered specifically for sync-related lines, not general query traffic — surfaces individual collection-clone events as they complete.</p><p>One easy mistake here: tailing mongod.log on a <strong>primary-site</strong> node during this phase shows regular operational noise (client authentications, slow-query warnings) that has nothing to do with sync progress. The log worth watching is on the DR node itself.</p><h3>What this comes down to</h3><p>Neither phase of this migration needed downtime, and neither needed anything exotic — just two habits applied consistently:</p><ol><li><strong>One node at a time, always verify before moving on.</strong> rs.reconfig() is powerful enough to hurt you if you get impatient with it.</li><li><strong>Understand what a config field actually does before working around it.</strong> A bindIp of 0.0.0.0 turned a restart-every-node migration into a reconfig-only exercise. A votes: 0 setting on DR nodes turned a quorum hazard into a safe, fully-replicated standby.</li></ol><p>The replica set never dropped below majority, never lost a write, and came out the other side with a wider footprint across two sites — which, at the end of the day, is the entire point of running a replica set in the first place.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6153a39c5962" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When GitHub Actions Runs Out of Build Minutes Right Before Your Midnight Production Deploy]]></title>
            <link>https://medium.com/@gayan.dissanayake/when-github-actions-runs-out-of-build-minutes-right-before-your-midnight-production-deploy-72f640b51def?source=rss-5016ec278afa------2</link>
            <guid isPermaLink="false">https://medium.com/p/72f640b51def</guid>
            <category><![CDATA[github-actions]]></category>
            <dc:creator><![CDATA[Gayan Dissanayake]]></dc:creator>
            <pubDate>Mon, 22 Jun 2026 06:49:56 GMT</pubDate>
            <atom:updated>2026-06-22T06:49:56.822Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9olOBG6iPC0YntGvsMgXrQ.png" /></figure><p>Picture this: it’s 11:45 PM, your team has scheduled a production release window during low-traffic hours, and the deployment pipeline you’ve tested a dozen times suddenly fails — not because of a bug in your code, but because your GitHub Actions build minutes for the month have run out.</p><p>This is a more common problem than people expect, especially for teams that:</p><ul><li>Run CI on every push and pull request across multiple repositories</li><li>Have heavy test suites, Docker image builds, or SonarQube quality gates</li><li>Schedule production deploys during off-hours (when minutes often reset at unpredictable times relative to your billing cycle)</li><li>Are on GitHub’s free or lower-tier plans with limited included minutes</li></ul><p>When this happens at the worst possible time — right before a production release — you basically have two practical paths forward. Let’s walk through both.</p><h3>Option 1: Upgrade Your GitHub Plan for More Included Minutes</h3><p>The simplest short-term fix is to move to a higher GitHub plan or purchase additional Actions minutes. GitHub ties Actions minutes to your plan tier (Free, Pro, Team, Enterprise), and each tier comes with a different monthly allowance of included minutes for private repositories (public repositories get unlimited minutes on standard runners).</p><p>If your organization is consistently bumping against the ceiling, upgrading the plan — or enabling pay-as-you-go spending limits for Actions — gives you breathing room without any infrastructure work. This is the right call when:</p><ul><li>The overage is occasional and the extra cost is small compared to engineering time</li><li>You don’t want to maintain additional infrastructure</li><li>Your team is small and the GitHub-hosted runner experience (zero maintenance, automatic OS updates, ephemeral environments) is valuable to you</li></ul><p>The downside is that this is purely a financial lever. If your usage keeps growing — more repos, more contributors, more frequent deploys — you’ll keep hitting higher ceilings, and the cost scales linearly with usage. For teams running Docker builds, integration tests, and quality gates across multiple repositories every day, this can add up quickly.</p><h3>Option 2: Set Up Self-Hosted Runners</h3><p>The more sustainable long-term solution is to run your own GitHub Actions runners on infrastructure you control — for example, a virtual machine on Google Cloud Platform (GCP), AWS, or even on-prem hardware. Self-hosted runners don’t count against your GitHub Actions minutes at all, so as long as your VM is up and configured correctly, your pipelines keep running regardless of GitHub’s billing cycle.</p><p>Here’s a high-level walkthrough of setting this up on GCP, which generalizes to most cloud providers.</p><h3>Step 1 — Create a VM</h3><p>Spin up a small VM (something like a 2 vCPU / 8GB RAM instance is usually enough for Node.js and Docker-based builds; go larger if your Docker builds are slow). Use a standard Linux image such as Ubuntu 22.04.</p><h3>Step 2 — Lock Down the Firewall</h3><p>Self-hosted runners only need outbound access to reach GitHub’s servers — no inbound ports are required. Configure your firewall rules to allow outbound HTTPS (port 443) only, and avoid opening any inbound traffic to the runner.</p><h3>Step 3 — Install Dependencies</h3><p>SSH into the VM and install whatever your build pipeline needs:</p><ul><li>Docker (for containerized builds and image publishing)</li><li>Node.js (or whatever language runtime your project uses)</li><li>Cloud CLI tools (gcloud, aws-cli, etc., if your pipeline interacts with cloud resources)</li><li>Add your runner user to the docker group so builds can run Docker commands without sudo</li></ul><h3>Step 4 — Register the Runner with GitHub</h3><p>From your repository (or organization) settings under Actions → Runners, generate a registration token. Then on the VM, download the GitHub Actions runner package, extract it, and run the configuration script with that token, giving it a name and labels (for example: gcp,linux,docker) so your workflows can target it specifically.</p><h3>Step 5 — Install as a System Service</h3><p>Install the runner as a systemd service so it automatically starts on VM reboot and keeps running in the background without manual intervention.</p><h3>Step 6 — Update Your Workflow YAML</h3><p>Change the runs-on field in your workflow files from ubuntu-latest to self-hosted, or be more specific using the labels you assigned:</p><pre>jobs:<br>  build-and-deploy:<br>    runs-on: [self-hosted, gcp, linux]</pre><h3>Step 7 — Grant Cloud Permissions</h3><p>If your pipeline pushes Docker images to a container registry (like Artifact Registry on GCP, ECR on AWS, etc.), make sure the VM’s service account or credentials have the right IAM permissions, and configure Docker authentication accordingly.</p><h3>Step 8 — Scale Across Multiple Repositories</h3><p>Here’s where self-hosted runners really shine. Instead of duplicating infrastructure for every repository:</p><ul><li><strong>Per-repo runners</strong>: register a separate runner instance (in its own directory) for each repository, each running as its own systemd service on the same VM. You end up with multiple runner services sharing the same Docker, Node, and CLI tooling — zero duplication of setup.</li><li><strong>Org-level runners</strong>: if you have many repositories under one GitHub organization, register the runner at the organization level instead. One runner (or runner pool) serves all repositories without needing to repeat the registration process for each one. This is configured under your organization’s Settings → Actions → Runners.</li></ul><h3>Step 9 — Verify</h3><p>Push a test PR or trigger a workflow manually and confirm the job picks up your self-hosted runner via its label.</p><h3>Cost Considerations</h3><p>A modest VM (2 vCPU / 8GB RAM) typically costs somewhere in the range of $40–50/month if left running 24/7 — often cheaper if you only run it during your CI/CD windows, or if you automate start/stop schedules using something like Cloud Scheduler. Compare that to the cost of repeatedly purchasing extra Actions minutes as your team and pipeline complexity grow, and self-hosting frequently wins for active engineering teams.</p><h3>So Which Should You Choose?</h3><p>If your minute overages are rare and small, upgrading your plan or buying extra minutes is the fastest fix — no infrastructure to maintain, and GitHub-hosted runners are fully managed. But if you’re hitting limits regularly, especially with Docker builds, multiple repositories, and frequent production deploys, setting up self-hosted runners pays for itself quickly, gives you predictable costs, and removes the risk of a midnight deploy failing simply because you ran out of minutes.</p><p>Many teams end up doing both: keeping GitHub-hosted runners for lightweight jobs and occasional bursts, while routing heavier or more frequent builds to self-hosted infrastructure they control.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72f640b51def" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Host a Full-Stack App with Node.js and Supabase]]></title>
            <link>https://medium.com/@gayan.dissanayake/how-to-host-a-full-stack-app-with-node-js-and-supabase-167a5520ff3b?source=rss-5016ec278afa------2</link>
            <guid isPermaLink="false">https://medium.com/p/167a5520ff3b</guid>
            <category><![CDATA[vercel]]></category>
            <category><![CDATA[full-stack]]></category>
            <category><![CDATA[superbase]]></category>
            <category><![CDATA[serverless]]></category>
            <dc:creator><![CDATA[Gayan Dissanayake]]></dc:creator>
            <pubDate>Sun, 07 Jun 2026 15:51:20 GMT</pubDate>
            <atom:updated>2026-06-07T15:51:20.249Z</atom:updated>
            <content:encoded><![CDATA[<h3>From local dev to production — database, API, frontend, and CI/CD.</h3><p>You do not need a VPS, a Docker cluster, or a dedicated DBA to ship a production web app in 2026.</p><p>A modern stack — <strong>Node.js</strong> on the frontend and build side, <strong>Supabase</strong> on the backend — gets you from idea to live URL in an afternoon. No ops headaches. No surprise invoices. Just clean architecture you can actually maintain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vptuk9AvAF5Lfm5BtvxDCg.png" /></figure><p>This guide walks through the exact pattern used in production for <a href="https://opex.sasapp.biz/">Income &amp; Expense Tracker</a>: a React app built with Node.js tooling, PostgreSQL on Supabase, a serverless API on Supabase Edge Functions, and static hosting on Vercel.</p><p>Whether you are building a SaaS dashboard, an internal tool, or a startup MVP, the same architecture applies.</p><h3>Why Node.js + Supabase?</h3><p>Before we write a single line of code, let us understand why this combination works so well.</p><p><strong>Supabase</strong> gives you a managed PostgreSQL database, connection pooling, SQL migrations, row-level security, built-in auth, and optional file storage — without running your own database server. It is Firebase for people who want a real relational database.</p><p><strong>Node.js</strong> powers your development workflow (npm run dev, npm run build) and, optionally, your API layer if you prefer Express over Supabase&#39;s Edge Functions.</p><p>The result is low ops overhead, predictable cost, and a stack built on tools the JavaScript ecosystem already knows deeply.</p><p>Layer Tool What it does UI React + Vite (Node.js ecosystem) Fast dev, TypeScript, modern components Database Supabase PostgreSQL Relational data, migrations, SQL functions API Supabase Edge Functions or Node.js (Express/Fastify) Business logic, auth, validation Hosting Vercel / Netlify / Railway Serve the built frontend globally Secrets Supabase secrets + platform env vars JWT keys, admin passwords, API keys</p><h3>Architecture at a Glance</h3><p>Here is how all the pieces connect:</p><pre>┌─────────────────┐     HTTPS      ┌──────────────────────────────┐<br>│  Browser        │ ──────────────▶│  Vercel (static React build) │<br>│  (user)         │                │  Node.js builds → static files│<br>└────────┬────────┘                └──────────────────────────────┘<br>         │<br>         │  API calls (axios/fetch)<br>         ▼<br>┌─────────────────────────────────────────────────────────────────┐<br>│  Supabase                                                        │<br>│  ┌─────────────────────┐    ┌─────────────────────────────────┐ │<br>│  │ Edge Function: api  │───▶│ PostgreSQL (migrations, RPC)   │ │<br>│  │ (Deno / TypeScript) │    │ users, orders, reports, etc.   │ │<br>│  └─────────────────────┘    └─────────────────────────────────┘ │<br>└─────────────────────────────────────────────────────────────────┘</pre><p><strong>The request flow in plain English:</strong></p><ol><li>A user opens your app on Vercel (or any static host).</li><li>The React app calls https://&lt;project&gt;.supabase.co/functions/v1/api/....</li><li>The Edge Function runs your API logic and talks to Postgres.</li><li>JSON comes back and the UI updates.</li></ol><blockquote><strong><em>Alternative:</em></strong><em> Run a Node.js Express API on Railway or Render instead of Edge Functions. Supabase stays your database; only the API runtime changes. Both patterns are completely valid — pick the one your team is most comfortable with.</em></blockquote><h3>Step 1 — Create a Supabase Project</h3><p>Start by creating your cloud database.</p><ol><li>Go to <a href="https://supabase.com/">supabase.com</a> and create a free project.</li><li>Note your <strong>Project URL</strong> and <strong>anon key</strong> (Settings → API).</li><li>Install the Supabase CLI:</li></ol><pre>npm install -g supabase<br>supabase login</pre><ol><li>Link your local repo to the remote project:</li></ol><pre>supabase link --project-ref YOUR_PROJECT_REF</pre><p>You now have a remote PostgreSQL database ready for schema migrations. Everything from here is code you can commit to git.</p><h3>Step 2 — Define Your Database with Migrations</h3><p>Keep your schema under version control in supabase/migrations/. This is the habit that separates maintainable apps from ones that break every time someone clicks the wrong thing in a GUI.</p><pre>-- supabase/migrations/001_schema.sql<br>CREATE TABLE users (<br>  id SERIAL PRIMARY KEY,<br>  username VARCHAR(255) UNIQUE NOT NULL,<br>  password_hash VARCHAR(255) NOT NULL,<br>  role VARCHAR(20) NOT NULL,<br>  active BOOLEAN DEFAULT true<br>);</pre><pre>CREATE TABLE branches (<br>  id SERIAL PRIMARY KEY,<br>  name VARCHAR(255) NOT NULL,<br>  admin_user_id INTEGER REFERENCES users(id),<br>  created_at TIMESTAMPTZ DEFAULT NOW()<br>);</pre><pre>CREATE TABLE transactions (<br>  id SERIAL PRIMARY KEY,<br>  branch_id INTEGER REFERENCES branches(id),<br>  type VARCHAR(10) NOT NULL CHECK (type IN (&#39;income&#39;, &#39;expense&#39;)),<br>  amount NUMERIC(12, 2) NOT NULL,<br>  description TEXT,<br>  created_at TIMESTAMPTZ DEFAULT NOW()<br>);</pre><p>Apply these migrations to your production database with a single command:</p><pre>supabase db push --yes</pre><p><strong>Why migrations matter:</strong> You can reproduce the exact same schema on staging and production, roll forward safely, and review database changes in pull requests — just like application code. No more “what did someone change in prod last Tuesday?”</p><h3>Step 3 — Build the API</h3><p>You have two main approaches depending on your preference and use case.</p><h3>Option A — Supabase Edge Functions (Recommended)</h3><p>Edge Functions run on Deno at the edge, close to your users. One function can expose your entire REST API, keeping deployment simple early on.</p><pre>// supabase/functions/api/index.ts<br>import { createClient } from &#39;https://esm.sh/@supabase/supabase-js@2&#39;;</pre><pre>const corsHeaders = {<br>  &#39;Access-Control-Allow-Origin&#39;: &#39;*&#39;,<br>  &#39;Access-Control-Allow-Headers&#39;: &#39;authorization, x-client-info, apikey, content-type&#39;,<br>};</pre><pre>Deno.serve(async (req) =&gt; {<br>  // Handle CORS preflight<br>  if (req.method === &#39;OPTIONS&#39;) {<br>    return new Response(&#39;ok&#39;, { headers: corsHeaders });<br>  }</pre><pre>  const supabase = createClient(<br>    Deno.env.get(&#39;SUPABASE_URL&#39;) ?? &#39;&#39;,<br>    Deno.env.get(&#39;SUPABASE_SERVICE_ROLE_KEY&#39;) ?? &#39;&#39;<br>  );</pre><pre>  const url = new URL(req.url);</pre><pre>  // Health check endpoint — always build this first<br>  if (req.method === &#39;GET&#39; &amp;&amp; url.pathname.endsWith(&#39;/health&#39;)) {<br>    return new Response(<br>      JSON.stringify({ ok: true, timestamp: new Date().toISOString() }),<br>      { headers: { ...corsHeaders, &#39;Content-Type&#39;: &#39;application/json&#39; }, status: 200 }<br>    );<br>  }</pre><pre>  // GET /branches<br>  if (req.method === &#39;GET&#39; &amp;&amp; url.pathname.endsWith(&#39;/branches&#39;)) {<br>    const { data, error } = await supabase.from(&#39;branches&#39;).select(&#39;*&#39;);<br>    if (error) return new Response(JSON.stringify({ error: error.message }), { status: 500 });<br>    return new Response(JSON.stringify(data), {<br>      headers: { ...corsHeaders, &#39;Content-Type&#39;: &#39;application/json&#39; },<br>    });<br>  }</pre><pre>  return new Response(JSON.stringify({ error: &#39;Not found&#39; }), { status: 404 });<br>});</pre><p>Deploy the function with:</p><pre>supabase functions deploy api --no-verify-jwt --project-ref YOUR_PROJECT_REF</pre><p>Set environment secrets (never hardcode these):</p><pre>supabase secrets set JWT_SECRET=&quot;your-long-random-secret&quot; --project-ref YOUR_PROJECT_REF</pre><h3>Option B — Node.js Express API</h3><p>If your team prefers Node.js for the backend, or you need WebSockets, long-running processes, or the full npm ecosystem:</p><pre>// server.js<br>import express from &#39;express&#39;;<br>import postgres from &#39;postgres&#39;;<br>import cors from &#39;cors&#39;;</pre><pre>const app = express();<br>const sql = postgres(process.env.DATABASE_URL); // Supabase connection string</pre><pre>app.use(cors());<br>app.use(express.json());</pre><pre>app.get(&#39;/health&#39;, async (req, res) =&gt; {<br>  await sql`SELECT 1`;<br>  res.json({ ok: true });<br>});</pre><pre>app.get(&#39;/branches&#39;, async (req, res) =&gt; {<br>  try {<br>    const branches = await sql`SELECT * FROM branches ORDER BY created_at DESC`;<br>    res.json(branches);<br>  } catch (err) {<br>    res.status(500).json({ error: err.message });<br>  }<br>});</pre><pre>app.listen(process.env.PORT || 3000, () =&gt; {<br>  console.log(&#39;API running on port&#39;, process.env.PORT || 3000);<br>});</pre><p>Host this on <strong>Railway</strong>, <strong>Render</strong>, or <strong>Fly.io</strong>. Point DATABASE_URL at Supabase&#39;s connection string, which you will find under Settings → Database → Connection string.</p><p><strong>When to pick which:</strong></p><p>Edge Functions Node.js API Serverless, pay per invocation Long-running process, WebSockets Deno / TypeScript at the edge Full npm ecosystem Tight Supabase integration Familiar Express patterns Global distribution automatically More control over runtime</p><h3>Step 4 — Build the Frontend</h3><p>Initialize your React app with Vite. Node.js powers the build, but the final output is just static files — no Node server needed in production.</p><pre>npm create vite@latest my-app -- --template react-ts<br>cd my-app<br>npm install axios</pre><p>Create an API client that reads configuration from environment variables:</p><pre>// src/api/client.ts<br>import axios from &#39;axios&#39;;</pre><pre>const supabaseUrl = import.meta.env.VITE_SUPABASE_URL;<br>const anonKey = import.meta.env.VITE_SUPABASE_ANON_KEY;</pre><pre>export const api = axios.create({<br>  baseURL: `${supabaseUrl}/functions/v1/api`,<br>  headers: {<br>    apikey: anonKey,<br>    Authorization: `Bearer ${anonKey}`,<br>  },<br>});</pre><p>Create a local .env file (this file must never be committed to git):</p><pre>VITE_SUPABASE_URL=https://YOUR_PROJECT_REF.supabase.co<br>VITE_SUPABASE_ANON_KEY=your-anon-key</pre><p>Then use the API client in your components:</p><pre>// src/components/BranchList.tsx<br>import { useEffect, useState } from &#39;react&#39;;<br>import { api } from &#39;../api/client&#39;;</pre><pre>export default function BranchList() {<br>  const [branches, setBranches] = useState([]);</pre><pre>  useEffect(() =&gt; {<br>    api.get(&#39;/branches&#39;).then(res =&gt; setBranches(res.data));<br>  }, []);</pre><pre>  return (<br>    &lt;ul&gt;<br>      {branches.map((b: any) =&gt; (<br>        &lt;li key={b.id}&gt;{b.name}&lt;/li&gt;<br>      ))}<br>    &lt;/ul&gt;<br>  );<br>}</pre><p>Build for production:</p><pre>npm run build   # outputs static files to dist/</pre><h3>Step 5 — Deploy the Frontend to Vercel</h3><p>Vercel turns your dist/ folder into a globally distributed static site in about 30 seconds.</p><ol><li>Push your repo to GitHub.</li><li>Import the project at <a href="https://vercel.com/">vercel.com</a>.</li><li>Add your environment variables:</li></ol><ul><li>VITE_SUPABASE_URL</li><li>VITE_SUPABASE_ANON_KEY</li></ul><ol><li>Set build command: npm run build</li><li>Set output directory: dist</li></ol><p>Then deploy from your terminal:</p><pre>npx vercel deploy --prod --yes</pre><p>Add a custom domain (e.g. app.yourcompany.com) under Vercel → Domains. HTTPS is handled automatically.</p><h3>Step 6 — Automate Everything with GitHub Actions</h3><p>Manual deploys are fine for a side project. For anything used by real people, automate it. Push to main and everything deploys itself — database migrations first, then the API, then the frontend.</p><pre># .github/workflows/deploy.yml<br>name: Deploy</pre><pre>on:<br>  push:<br>    branches: [main]</pre><pre>jobs:<br>  deploy-supabase:<br>    runs-on: ubuntu-latest<br>    steps:<br>      - uses: actions/checkout@v4</pre><pre>      - uses: supabase/setup-cli@v1</pre><pre>      - name: Link Supabase project<br>        run: supabase link --project-ref ${{ secrets.SUPABASE_PROJECT_REF }} --yes<br>        env:<br>          SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}</pre><pre>      - name: Push database migrations<br>        run: supabase db push --yes</pre><pre>      - name: Deploy Edge Functions<br>        run: supabase functions deploy api --no-verify-jwt</pre><pre>  deploy-vercel:<br>    needs: deploy-supabase<br>    runs-on: ubuntu-latest<br>    steps:<br>      - uses: actions/checkout@v4</pre><pre>      - uses: actions/setup-node@v4<br>        with:<br>          node-version: &#39;20&#39;</pre><pre>      - name: Install and build<br>        run: npm ci &amp;&amp; npm run build<br>        env:<br>          VITE_SUPABASE_URL: <a href="https://${{/">https://${{</a> secrets.SUPABASE_PROJECT_REF }}.supabase.co<br>          VITE_SUPABASE_ANON_KEY: ${{ secrets.VITE_SUPABASE_ANON_KEY }}</pre><pre>      - name: Deploy to Vercel<br>        uses: amondnet/vercel-action@v25<br>        with:<br>          vercel-token: ${{ secrets.VERCEL_TOKEN }}<br>          vercel-args: &#39;--prod&#39;</pre><p><strong>Secrets to add in GitHub repository settings:</strong></p><ul><li>SUPABASE_ACCESS_TOKEN</li><li>SUPABASE_PROJECT_REF</li><li>VITE_SUPABASE_ANON_KEY</li><li>VERCEL_TOKEN</li></ul><p>The ordering matters: Supabase deploys before Vercel so the API and database are ready before the new frontend goes live. A new frontend hitting an old API is one of the most common causes of post-deploy bugs.</p><h3>Step 7 — One-Command Local Deploy Script</h3><p>For situations where you want to deploy everything from your machine without clicking through dashboards:</p><pre>#!/usr/bin/env bash<br>set -euo pipefail</pre><pre>PROJECT_REF=&quot;your-project-ref&quot;</pre><pre>echo &quot;→ Linking Supabase project...&quot;<br>supabase link --project-ref &quot;$PROJECT_REF&quot; --yes</pre><pre>echo &quot;→ Pushing database migrations...&quot;<br>supabase db push --yes</pre><pre>echo &quot;→ Deploying Edge Functions...&quot;<br>supabase functions deploy api --no-verify-jwt --project-ref &quot;$PROJECT_REF&quot;</pre><pre>echo &quot;→ Rotating JWT secret...&quot;<br>supabase secrets set JWT_SECRET=&quot;$(openssl rand -base64 32)&quot; --project-ref &quot;$PROJECT_REF&quot;</pre><pre>echo &quot;→ Deploying frontend to Vercel...&quot;<br>npx vercel deploy --prod --yes</pre><pre>echo &quot;✓ Full stack deployed.&quot;</pre><p>Save it as scripts/deploy-all.sh, run chmod +x scripts/deploy-all.sh, and you have a single command that ships your entire stack.</p><h3>Security Checklist</h3><p>Security is not an afterthought with this stack — it is built in. But you still need to follow a few rules:</p><ul><li><strong>Never</strong> put service-role keys in the frontend. Only the anon key goes in VITE_* environment variables. The service-role key bypasses row-level security entirely.</li><li>Store JWT_SECRET and database passwords in Supabase secrets or CI secrets, never in git — not even in a .env file you &quot;promise not to commit.&quot;</li><li>Validate all input on the <strong>server</strong>. Client-side validation is UX only. Anyone with curl can bypass it.</li><li>Use Row Level Security (RLS) if the browser talks directly to Supabase. With a custom API layer, enforce access control in your function code instead.</li><li>Enable HTTPS everywhere. Vercel and Supabase do this by default — do not turn it off.</li><li>Rotate secrets on a schedule. The one-liner openssl rand -base64 32 in the deploy script above makes this easy.</li></ul><h3>Cost Reality Check</h3><p>One of the best things about this stack is how affordable it is to start.</p><p>Service Free tier Typical small app Supabase 500 MB DB, 2 projects, 500K Edge invocations/month $0–25/month Vercel Hobby plan free for personal projects $0–20/month Domain — ~$10/year</p><p>For an internal tool or early-stage SaaS, you can run months at near-zero cost before scaling. When you do scale, both Supabase and Vercel have predictable pricing — no surprise bills because a database connection pool wasn’t closed properly.</p><h3>What We Learned Shipping to Production</h3><p>Building <a href="https://opex.sasapp.biz/">opex.sasapp.biz</a> — a branch-wise income and expense tracker for factories and plants — taught us several things that are worth sharing:</p><p><strong>1. Migrations first, always.</strong> Schema in git beats clicking in a SQL editor every single time. The day you need to reproduce your database on a staging environment, you will be grateful for every migration file.</p><p><strong>2. One API function to start.</strong> A single Edge Function with internal route parsing is far easier to deploy and debug than many micro-functions. Split it up later when you have a clear reason to.</p><p><strong>3. Node for build, static for serve.</strong> Vite plus Vercel is fast and cheap. You do not need Node.js running in production to serve a React SPA. Build once, serve everywhere.</p><p><strong>4. Deploy Supabase before Vercel in CI.</strong> The API and database must be ready before the new frontend goes live. Build your pipeline in that order and you will avoid an entire class of deployment bugs.</p><p><strong>5. Build the health endpoint on day one.</strong> GET /health costs nothing and saves enormous time debugging deployments. If your health check fails, you know immediately whether the problem is the API or the database.</p><p><strong>6. Use connection pooling.</strong> Supabase’s built-in PgBouncer connection pooler is available for free. Enable it under Settings → Database → Connection pooling. Without it, serverless functions can exhaust Postgres connection limits under load.</p><h3>Conclusion</h3><p>Node.js + Supabase is not a toy stack for demos. It is a production-grade architecture used by real applications serving real users — with the simplicity of a weekend project.</p><ul><li><strong>Node.js</strong> — develop, test, and build with the world’s largest package ecosystem.</li><li><strong>Supabase</strong> — managed PostgreSQL, migrations, secrets, and serverless API hosting.</li><li><strong>Vercel</strong> — global CDN for your static frontend at near-zero cost.</li></ul><p>You get relational data, real SQL, typed APIs, and automated deploys — without managing servers or database backups yourself.</p><p>If you are starting a new project this week: create the Supabase project, write one migration, build one Edge Function with a /health route, and create one Vite page that calls it. Deploy both. You will have a live, full-stack application before lunch.</p><p><em>Enjoyed this guide? Follow me here on Medium for more practical full-stack content. Questions or feedback? Reach out at </em><strong><em>sasappbiz@gmail.com</em></strong></p><p><em>Live example: </em><a href="https://opex.sasapp.biz/"><em>opex.sasapp.biz</em></a><em> — Income &amp; Expense Tracker for branches and plants, built on this exact stack.</em></p><p><strong>Tags:</strong> Node.js · Supabase · React · Vercel · Full Stack · Web Development · PostgreSQL · Serverless · DevOps · SaaS</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=167a5520ff3b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>