ยท Product News ยท 3 min read

    Semaphore ArgoCD Integration: Complete Guide with Flux and Terraform

    Contents

    If you’re implementing Semaphore ArgoCD integration, you’re building a modern, GitOps-driven CI/CD pipeline for Kubernetes. This guide shows exactly how Semaphore works with ArgoCD, and how Flux and Terraform fit into the same workflow for scalable, production-ready delivery.

    Youโ€™ll learn:

    • How Semaphore ArgoCD integration works step by step
    • How to design a GitOps CI/CD pipeline
    • Where Flux and Terraform fit in
    • Best practices and common pitfalls

    What Is Semaphore ArgoCD Integration?

    Semaphore ArgoCD integration means using Semaphore for CI (build, test, validate) and ArgoCD for CD (deploy via GitOps).

    • Semaphore โ†’ CI and pipeline orchestration
    • ArgoCD โ†’ GitOps-based Kubernetes deployments
    • Flux (optional) โ†’ Alternative GitOps CD with automation
    • Terraform โ†’ Infrastructure provisioning (IaC)

    This separation ensures:

    • Git as the single source of truth
    • Safer deployments
    • Full auditability

    How Semaphore ArgoCD Integration Works

    In a GitOps model, Semaphore never deploys directly to Kubernetes.

    Instead, it updates a Git repository that ArgoCD continuously reconciles.

    Developer pushes code
       โ†“
    Semaphore (CI pipeline)
       โ†“
    Build + Test + Push Docker image
       โ†“
    Update Git (Kubernetes manifests)
       โ†“
    ArgoCD detects changes
       โ†“
    Deploy to Kubernetes

    This is the core of Semaphore ArgoCD integration.

    Semaphore ArgoCD Integration Workflow (Step-by-Step)

    1. Run tests in Semaphore
    2. Build and tag Docker image
    3. Push image to registry
    4. Update Kubernetes manifests in Git
    5. ArgoCD syncs and deploys automatically

    Example: Updating manifests from Semaphore

    git clone git@github.com:org/k8s-config.git
    cd k8s-config
    sed -i "s|image: app:.*|image: app:${SEMAPHORE_GIT_SHA}|" deployment.yaml
    
    git commit -am "Deploy ${SEMAPHORE_GIT_SHA}"
    git push

    Why this integration pattern works

    • Enforces GitOps principles
    • Keeps CI and CD cleanly separated
    • Enables easy rollback via Git
    • Improves security and traceability

    Semaphore ArgoCD Integration vs Flux (GitOps Alternative)

    Flux provides a similar GitOps approach with additional automation.

    Option 1: Semaphore updates manifests

    kustomize edit set image app=repo/app:${SEMAPHORE_GIT_SHA}
    git commit -am "Update image"
    git push

    Option 2: Flux Image Automation

    • Semaphore builds and pushes images
    • Flux automatically updates manifests

    When to use Flux instead of ArgoCD

    • You want automated image updates
    • You prefer controller-driven workflows

    Using Terraform with Semaphore ArgoCD Integration

    Terraform complements Semaphore ArgoCD integration by managing infrastructure.

    Typical Terraform workflow in Semaphore

    terraform init
    terraform plan -out=tfplan
    terraform apply -auto-approve tfplan

    Best practices

    • Use remote state
    • Add approval gates for production
    • Separate infra and app pipelines

    End-to-End Pipeline with Semaphore ArgoCD Integration

    1. Developer pushes code
    2. Semaphore runs CI pipeline
    3. Image is built and pushed
    4. GitOps repo is updated
    5. ArgoCD deploys to Kubernetes
    6. Terraform runs if needed

    Benefits

    • Fully Git-driven deployments
    • Clear separation of responsibilities
    • High scalability and observability

    Common Mistakes in Semaphore ArgoCD Integration

    โŒ Deploying directly from Semaphore

    Breaks GitOps and removes auditability.

    โŒ Mixing Terraform with app deployments

    Creates unnecessary coupling.

    โŒ Skipping approval gates

    Leads to unsafe production changes.

    Best Practices for Semaphore ArgoCD Integration

    • Use Git as the source of truth
    • Keep CI and CD separate
    • Automate builds, not deployments
    • Use Terraform only for infrastructure
    • Version everything

    Conclusion: When to Use Semaphore ArgoCD Integration

    Semaphore ArgoCD integration is ideal when you want a scalable, GitOps-based CI/CD pipeline for Kubernetes.

    • Semaphore handles CI and orchestration
    • ArgoCD handles deployments
    • Terraform manages infrastructure

    Together, they create a reliable, production-ready DevOps platform.

    Next Steps

    • Set up a Semaphore CI pipeline
    • Create a GitOps repository for ArgoCD
    • Structure Terraform modules and environments

    This setup gives you a strong foundation for modern DevOps.

    Want to discuss this article? Join our Discord.

    Pete Miloravac
    Writen by:
    Pete Miloravac is a software engineer and educator at Semaphore. He writes about CI/CD best practices, test automation, reproducible builds, and practical ways to help teams ship software faster and more reliably.
    Star us on GitHub