<?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 Rohith Dhamodharan S on Medium]]></title>
        <description><![CDATA[Stories by Rohith Dhamodharan S on Medium]]></description>
        <link>https://medium.com/@rohit.d_80345?source=rss-2c775528813f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*zVpImmZDIJ1kqe1r</url>
            <title>Stories by Rohith Dhamodharan S on Medium</title>
            <link>https://medium.com/@rohit.d_80345?source=rss-2c775528813f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 01:04:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rohit.d_80345/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[Building a Secure DevSecOps Pipeline: GCP, Terraform, GitHub Actions, Trivy & OPA Gatekeeper]]></title>
            <link>https://blog.thecloudside.com/building-a-secure-devsecops-pipeline-gcp-terraform-github-actions-trivy-opa-gatekeeper-903a6d574fd5?source=rss-2c775528813f------2</link>
            <guid isPermaLink="false">https://medium.com/p/903a6d574fd5</guid>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Rohith Dhamodharan S]]></dc:creator>
            <pubDate>Mon, 23 Feb 2026 06:30:48 GMT</pubDate>
            <atom:updated>2026-02-23T06:30:48.682Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qJceTEbR81dY2B58womUpw.png" /></figure><p>Modern cloud applications demand secure and automated CI/CD pipelines. Traditional approaches often rely on long-lived service account keys and lack runtime enforcement of security policies. In this post, we show how to build a fully secure DevSecOps pipeline on <strong>Google Kubernetes Engine (GKE)</strong> using:</p><ul><li>GitHub OIDC (no service account keys)</li><li>Trivy for vulnerability scanning</li><li>Artifact Registry</li><li>GKE</li><li>OPA Gatekeeper for policy enforcement</li></ul><p>Full Source Code: <a href="https://github.com/RohithDhamu/DevSecOps_pipeline.git">https://github.com/RohithDhamu/DevSecOps_pipeline.git</a></p><h4>Architecture Overview:</h4><p>Developer → GitHub → OIDC Authentication → GCP<br> → Build Docker Image<br> → Trivy Scan<br> → Push to Artifact Registry<br> → Deploy to GKE<br> → OPA Gatekeeper validates policies</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZyiaF5EZnbkgpEr5kj0DCQ.png" /></figure><ul><li>Developers commit code to GitHub</li><li>CI builds and scans container images</li><li>CD deploys to GKE using GitHub OIDC</li><li>Runtime policies enforced with Gatekeeper</li></ul><p>This ensures security at every stage of the delivery pipeline.</p><p><strong>Step 1: Provisioning Secure GKE Infrastructure using Terraform</strong><br>Instead of manually creating resources in the GCP console, we use Infrastructure as Code (IaC) with Terraform.</p><p>Using Terraform, we created:</p><ul><li>Standard GKE Cluster</li><li>Secure Node Pool</li><li>Workload Identity enabled Service Account</li></ul><p><strong>The complete Terraform implementation is available here:</strong><br><a href="https://github.com/RohithDhamu/DevSecOps_pipeline/tree/main/Terraform">https://github.com/RohithDhamu/DevSecOps_pipeline/tree/main/Terraform</a></p><p><strong>Step 2: Secure Authentication using GitHub OIDC (No Service Account Keys)<br></strong>Traditionally, CI/CD pipelines use <strong>Service Account JSON keys</strong> stored as GitHub Secrets but it has Key leakage risk so, we implemented Workload Identity Federation with GitHub OIDC.</p><p>OIDC (OpenID Connect) allows GitHub Actions to:</p><ul><li>Authenticate dynamically</li><li>Request short-lived access tokens</li><li>Avoid storing any static credentials</li></ul><pre>- name: Authenticate to Google Cloud<br>  uses: google-github-actions/auth@v2<br>  with:<br>    workload_identity_provider: &quot;projects/&lt;project-number&gt;/locations/global/workloadIdentityPools/&lt;pool-name&gt;/providers/&lt;provider-name&gt;&quot;<br>    service_account: &quot;&lt;service-account-name&gt;&quot;</pre><p><strong>Step 3: CI Pipeline Build, Scan &amp; Secure the Container Image<br></strong>Instead of just building and pushing a Docker image, we implemented security scanning before deployment. This is where DevSecOps begins.</p><p>CI Workflow: .github/workflows/ci.yml</p><pre>name: CI - Build &amp; Scan<br><br>on:<br>  push:<br>    branches:<br>      - main<br><br>permissions:<br>  contents: read<br>  id-token: write   # Required for OIDC authentication<br><br>env:<br>  PROJECT_ID: &lt;gcp-project-id&gt;<br>  REGION: &lt;artifact-region&gt;<br>  REPO_NAME: &lt;artifact-repository-name&gt;<br>  IMAGE_NAME: &lt;image-name&gt;<br><br>jobs:<br>  build:<br>    runs-on: ubuntu-latest<br><br>    steps:<br>      - name: Checkout Code<br>        uses: actions/checkout@v4<br><br>      # Authenticate to Google Cloud using OIDC<br>      - name: Authenticate to Google Cloud<br>        uses: google-github-actions/auth@v2<br>        with:<br>          workload_identity_provider: &quot;projects/&lt;project-number&gt;/locations/global/workloadIdentityPools/&lt;pool-name&gt;/providers/&lt;provider-name&gt;&quot;<br>          service_account: &quot;&lt;service-account&gt;@&lt;project-id&gt;.iam.gserviceaccount.com&quot;<br><br>      - name: Setup gcloud<br>        uses: google-github-actions/setup-gcloud@v2<br><br>      - name: Configure Docker for Artifact Registry<br>        run: |<br>          gcloud auth configure-docker $REGION-docker.pkg.dev<br><br>      # Build Docker Image<br>      - name: Build Docker Image<br>        run: |<br>          docker build -t $REGION-docker.pkg.dev/$PROJECT_ID/$REPO_NAME/$IMAGE_NAME:${{ github.sha }} .<br><br>      # Scan Image using Trivy<br>      - name: Scan Image with Trivy<br>        uses: aquasecurity/trivy-action@master<br>        with:<br>          image-ref: ${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPO_NAME }}/${{ env.IMAGE_NAME }}:${{ github.sha }}<br>          format: table<br>          exit-code: 1<br>          severity: HIGH,CRITICAL<br><br>      # Push Image only if Scan Passes<br>      - name: Push Docker Image<br>        run: |<br>          docker push $REGION-docker.pkg.dev/$PROJECT_ID/$REPO_NAME/$IMAGE_NAME:${{ github.sha }}</pre><p><strong>This CI pipeline:</strong></p><ul><li>Builds a Docker image</li><li>Scans it using Trivy</li><li>Fails if HIGH or CRITICAL vulnerabilities exist</li><li>Pushes the image only if security checks pass</li><li>Uses GitHub OIDC for password less authentication</li></ul><p>This ensures no vulnerable images are pushed to the registry.</p><p>To demonstrate real DevSecOps enforcement, I intentionally built and pushed a Docker image containing known critical vulnerabilities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MavFPp4PpDqWqR8Ti-Cwkg.png" /></figure><p>Trivy detected HIGH vulnerabilities, The CI job failed.</p><p><strong>We chose Trivy because:</strong></p><ul><li>Lightweight</li><li>Supports OS &amp; language package scanning</li><li>Detects HIGH &amp; CRITICAL vulnerabilities</li></ul><p><strong>If Trivy finds HIGH or CRITICAL vulnerabilities:</strong></p><ul><li>CI fails immediately</li><li>Image is NOT pushed</li><li>Deployment is blocked</li></ul><p><strong>Step 4 — CD (Deploy to GKE + OPA Gatekeeper Enforcement)<br></strong>Once the image is built and scanned, we deploy it to GKE.<br>We also enforce runtime security using OPA Gatekeeper before allowing workloads into the cluster.</p><p>CD Workflow: .github/workflows/cd.yml</p><pre>name: CD - Deploy to GKE<br><br>on:<br>  workflow_run:<br>    workflows: [&quot;CI - Build &amp; Scan&quot;]<br>    types:<br>      - completed<br><br>permissions:<br>  contents: read<br>  id-token: write<br><br>env:<br>  PROJECT_ID: &lt;gcp-project-id&gt;<br>  ARTIFACT_REGION: &lt;artifact-region&gt;<br>  GKE_ZONE: &lt;gke-zone&gt;<br>  REPO_NAME: &lt;artifact-repository-name&gt;<br>  IMAGE_NAME: &lt;image-name&gt;<br>  CLUSTER_NAME: &lt;gke-cluster-name&gt;<br><br>jobs:<br>  deploy:<br>    if: ${{ github.event.workflow_run.conclusion == &#39;success&#39; }}<br>    runs-on: ubuntu-latest<br><br>    steps:<br>      - name: Checkout Code<br>        uses: actions/checkout@v4<br><br>      # Authenticate to Google Cloud via OIDC<br>      - name: Authenticate to Google Cloud<br>        uses: google-github-actions/auth@v2<br>        with:<br>          workload_identity_provider: &quot;projects/&lt;project-number&gt;/locations/global/workloadIdentityPools/&lt;pool-name&gt;/providers/&lt;provider-name&gt;&quot;<br>          service_account: &quot;&lt;service-account&gt;@&lt;project-id&gt;.iam.gserviceaccount.com&quot;<br><br>      - name: Setup gcloud<br>        uses: google-github-actions/setup-gcloud@v2<br><br>      # Install GKE Auth Plugin<br>      - name: Install GKE Auth Plugin<br>        run: |<br>          gcloud components install gke-gcloud-auth-plugin --quiet<br>          echo &quot;USE_GKE_GCLOUD_AUTH_PLUGIN=True&quot; &gt;&gt; $GITHUB_ENV<br><br>      # Get Cluster Credentials<br>      - name: Get GKE Credentials<br>        run: |<br>          gcloud container clusters get-credentials $CLUSTER_NAME \<br>            --zone $GKE_ZONE \<br>            --project $PROJECT_ID<br><br>      # Install OPA Gatekeeper<br>      - name: Install Gatekeeper<br>        run: |<br>          kubectl apply -f https://raw.githubusercontent.com/open-policy-agent/gatekeeper/release-3.14/deploy/gatekeeper.yaml<br>          kubectl rollout status deployment/gatekeeper-controller-manager \<br>            -n gatekeeper-system --timeout=180s<br><br>      # Apply Templates<br>      - name: Apply Constraint Templates<br>        run: |<br>          kubectl apply -f policy-templates/<br><br>      # Wait for CRDs<br>      - name: Wait for CRDs<br>        run: |<br>          kubectl wait --for=condition=Established crd --all --timeout=90s<br><br>      # Apply Constraints<br>      - name: Apply Constraints<br>        run: |<br>          kubectl apply -f policy-constraints/<br><br>      # Deploy Application (Immutable SHA tag)<br>      - name: Deploy Application<br>        run: |<br>          IMAGE=$ARTIFACT_REGION-docker.pkg.dev/$PROJECT_ID/$REPO_NAME/$IMAGE_NAME:${{ github.event.workflow_run.head_sha }}<br><br>          kubectl set image deployment/&lt;deployment-name&gt; \<br>            &lt;container-name&gt;=$IMAGE --record || true<br><br>          kubectl apply -f k8s/<br><br>      # Verify Rollout<br>      - name: Verify Deployment<br>        run: |<br>          kubectl rollout status deployment/&lt;deployment-name&gt; --timeout=180s</pre><p>This CD Pipeline:</p><ul><li>Authenticates to GCP using OIDC</li><li>Connects to GKE</li><li>Installs OPA Gatekeeper</li><li>Applies security policies</li><li>Deploys the application using immutable image tags</li></ul><p><strong>Why Install Gatekeeper in CD?</strong></p><p>This ensures:</p><ul><li>Every deployment passes security validation</li><li>Policies are enforced automatically</li><li>No insecure workloads enter production</li><li>Security becomes part of deployment</li></ul><p><strong>What Happens During Deployment?</strong></p><p>When a deployment is applied:</p><ol><li>Kubernetes receives the request</li><li>Gatekeeper intercepts it</li><li>Policies validate the manifest</li><li>If it violates rules → Deployment is blocked</li><li>If it passes → Pods are created</li></ol><p><strong>Step 5: Runtime Security Enforcement using OPA Gatekeeper</strong></p><p>Even if CI passes, someone could still deploy:</p><ul><li>A privileged container</li><li>A pod without resource limits</li><li>An image using the latest tag</li></ul><p>To prevent this, we enforce <strong>runtime security policies inside Kubernetes</strong> using:</p><p><strong><em>OPA Gatekeeper</em></strong></p><p><strong>What is OPA Gatekeeper?</strong></p><p>OPA (Open Policy Agent) Gatekeeper is a Kubernetes admission controller that:</p><ul><li>Intercepts Kubernetes API requests</li><li>Validates them against defined policies</li><li>Blocks non-compliant workloads</li></ul><p>It acts as a security guard at the cluster entrance.</p><p>Gatekeeper uses two components:</p><p>ConstraintTemplate: Defines the policy logic<br><a href="https://github.com/RohithDhamu/DevSecOps_pipeline/tree/main/policy-templates">https://github.com/RohithDhamu/DevSecOps_pipeline/tree/main/policy-templates</a></p><p>Constraint: Applies the policy to specific Kubernetes resources<br><a href="https://github.com/RohithDhamu/DevSecOps_pipeline/tree/main/policy-constraints">https://github.com/RohithDhamu/DevSecOps_pipeline/tree/main/policy-constraints</a></p><p><strong>Privileged Container Blocked by Gatekeeper<br></strong>When we attempted to deploy a pod with Privileged container.</p><pre>securityContext:<br>  privileged: true</pre><p>The deployment was immediately rejected by OPA Gatekeeper.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xvWjf3uQlSGEN8gL5XYcVA.png" /></figure><p>we tested a pod without defining CPU and memory limits.</p><pre>resources: {}</pre><p>Upon applying the manifest, Kubernetes rejected the deployment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B8EFMgLstR1Q8gschVJeog.png" /></figure><p><strong>Deployment After Enforcing Policies:<br></strong>After enabling OPA Gatekeeper policies, I updated my Kubernetes deployment to comply with all enforced security rules</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: devsecops-app<br>spec:<br>  replicas: 1<br>  selector:<br>    matchLabels:<br>      app: devsecops-app<br>  template:<br>    metadata:<br>      labels:<br>        app: devsecops-app<br>    spec:<br>      containers:<br>        - name: devsecops-app<br>          image: IMAGE_PLACEHOLDER   # will be replaced by CD with commit SHA tag<br>          ports:<br>            - containerPort: 8080<br>          resources:<br>            requests:<br>              cpu: &quot;100m&quot;<br>              memory: &quot;128Mi&quot;<br>            limits:<br>              cpu: &quot;200m&quot;<br>              memory: &quot;256Mi&quot;</pre><p>The deployment was successfully created and the pod entered the Running state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rzooL2zts6RyG07yWqn3bQ.png" /></figure><p><strong>Conclusion: From CI/CD to True DevSecOps</strong></p><p>In this project, we didn’t just build a CI/CD pipeline. We built a <strong>secure, </strong>production-ready DevSecOps architecture on GCP. Instead of treating security as an afterthought, we embedded it into every stage of the pipeline.</p><h4>Source Code &amp; Resources</h4><p>You can explore the full working implementation here:<br><a href="https://github.com/RohithDhamu/DevSecOps_pipeline.git">https://github.com/RohithDhamu/DevSecOps_pipeline.git</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=903a6d574fd5" width="1" height="1" alt=""><hr><p><a href="https://blog.thecloudside.com/building-a-secure-devsecops-pipeline-gcp-terraform-github-actions-trivy-opa-gatekeeper-903a6d574fd5">Building a Secure DevSecOps Pipeline: GCP, Terraform, GitHub Actions, Trivy &amp; OPA Gatekeeper</a> was originally published in <a href="https://blog.thecloudside.com/">The Cloudside View</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>