Skip to content

civo-learn/civo-dagger-engine-infra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dagger Engine on Civo Cloud Template

Civo Kubernetes Dagger Template

A template repository for deploying a Dagger Engine on Civo Cloud, providing distributed build caching and efficient CI/CD pipelines using Civo's managed Kubernetes and Object Storage services.

Features

  • 🚀 Managed Kubernetes cluster on Civo Cloud
  • 📦 Object Storage configuration for Dagger's build cache
  • 🔒 Secure network and firewall setup
  • ⚙️ Automated Helm deployment of the Dagger Engine
  • 💾 Persistent cache storage across builds

Prerequisites

Getting Started

  1. Use this template

    • Click the "Use this template" button above or click here
    • Clone your new repository
  2. Configure Civo credentials

The provider will use the credentials of the Civo CLI (stored in ~/.civo.json) if no other credentials have been set up. The provider will use credentials in the following order:

  1. Environment variable (CIVO_TOKEN).
  2. Token provided via a credentials file (See credentials_file input below).
  3. CLI configuration (~/.civo.json).

That means that if the CIVO_TOKEN variable is set, all other credentials will be ignored, and if the credentials_file is set, that will be used over the CLI credentials.

To set the CIVO_TOKEN environment variable:

export CIVO_TOKEN="your-api-token"
  1. Deploy the infrastructure
cd terraform
terraform init
terraform apply
  1. Configure kubectl
export KUBECONFIG=$(pwd)/kubeconfig
kubectl get nodes
  1. Connect to Dagger Engine
# Get the Dagger Engine pod name
DAGGER_ENGINE_POD_NAME="$(kubectl get pod \
    --selector=name=dagger-dagger-helm-engine \
    --namespace=dagger \
    --output=jsonpath='{.items[0].metadata.name}')"

# Configure Dagger runner
export _EXPERIMENTAL_DAGGER_RUNNER_HOST="kube-pod://$DAGGER_ENGINE_POD_NAME?namespace=dagger"
  1. Verify the setup
dagger query <<EOF
{
    container {
        from(address:"alpine") {
            withExec(args: ["uname", "-a"]) { stdout }
        }
    }
}
EOF

Customization

Modify terraform.tfvars or set variables during apply:

civo_region        = "LON1"          # Civo region
cluster_node_count = 3               # Number of K8s nodes
cluster_node_size  = "g4s.kube.medium" # Node size
object_store_size  = 500             # Cache storage in GB

Infrastructure Components

Infrastructure Components Here's an overview of the infrastructure deployed in Civo:

graph TB
    subgraph Civo["Civo Cloud"]
        subgraph Network["Dagger Network"]
            subgraph K8s["Kubernetes Cluster"]
                subgraph DaggerNS["Dagger Namespace"]
                    Engine["Dagger Engine Pod"]
                    Secret["Cache Config Secret"]
                end
                Nodes["Worker Nodes (x3)"]
            end
            FW["Firewall"]
        end
        
        subgraph Storage["Object Storage"]
            Bucket["Dagger Cache Bucket"]
            Creds["Object Store Credentials"]
        end
    end
    
    %% Connections
    Engine -->|"Read/Write Cache"| Bucket
    Engine -->|"Uses"| Secret
    Secret -.->|"References"| Creds
    FW -->|"Controls Access to"| K8s
    
    %% Styling
    classDef civoBox fill:#326CE5,stroke:#fff,stroke-width:2px,color:#fff
    classDef k8sBox fill:#326CE5,stroke:#fff,stroke-width:2px,color:#fff
    classDef storageBox fill:#FFA500,stroke:#fff,stroke-width:2px,color:#fff
    
    class Civo,Network civoBox
    class K8s,DaggerNS k8sBox
    class Storage,Bucket storageBox
Loading

The infrastructure consists of:

  • Kubernetes Cluster: Runs the Dagger Engine
  • Object Storage: Persistent cache for build artifacts
  • Firewall: Secure access control
  • Helm Release: Dagger Engine deployment
  • Kubernetes Secret: Cache configuration

Cache Monitoring

View your cache usage:

  1. Civo Console: Object Storage → Buckets
  2. Dagger CLI: dagger core engine local-cache entry-set

Cleanup

Remove all resources:

terraform destroy

Note

The Terraform state is stored locally by default. For production environments, it is recommended to store the state remotely using a backend such as a remote object storage. Modify the Terraform configuration to suit your production needs.

Support & Community

License

This template is available under the MIT License.

References

About

Deployment of a Dagger Engine onn Civo Kubernetes Clusters

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published