1. Answers
  2. Grouping Applications in Argo CD Project Setup Guide

How do I group related applications under a single project in Argo CD?

In this guide, we will demonstrate how to group related applications under a single project in Argo CD using Pulumi. This setup helps you manage multiple applications in a cohesive manner, making it easier to administer and maintain your deployments.

Key Points:

  • We will create an Argo CD project to group related applications.
  • We will define multiple applications and associate them with the created project.
import * as pulumi from "@pulumi/pulumi";
import * as k8s from "@pulumi/kubernetes";

// Define the Argo CD project
const argoCdProject = new k8s.apiextensions.CustomResource("argoCdProject", {
    apiVersion: "argoproj.io/v1alpha1",
    kind: "AppProject",
    metadata: {
        name: "example-project",
        namespace: "argocd",
    },
    spec: {
        description: "A project to group related applications",
        sourceRepos: ["*"],
        destinations: [
            {
                namespace: "*",
                server: "*",
            },
        ],
        clusterResourceWhitelist: [
            {
                group: "*",
                kind: "*",
            },
        ],
    },
});

// Define the first application
const app1 = new k8s.apiextensions.CustomResource("app1", {
    apiVersion: "argoproj.io/v1alpha1",
    kind: "Application",
    metadata: {
        name: "app1",
        namespace: "argocd",
    },
    spec: {
        project: argoCdProject.metadata.name,
        source: {
            repoURL: "https://github.com/example/repo1",
            targetRevision: "HEAD",
            path: "path/to/app1",
        },
        destination: {
            server: "https://kubernetes.default.svc",
            namespace: "default",
        },
        syncPolicy: {
            automated: {
                prune: true,
                selfHeal: true,
            },
        },
    },
});

// Define the second application
const app2 = new k8s.apiextensions.CustomResource("app2", {
    apiVersion: "argoproj.io/v1alpha1",
    kind: "Application",
    metadata: {
        name: "app2",
        namespace: "argocd",
    },
    spec: {
        project: argoCdProject.metadata.name,
        source: {
            repoURL: "https://github.com/example/repo2",
            targetRevision: "HEAD",
            path: "path/to/app2",
        },
        destination: {
            server: "https://kubernetes.default.svc",
            namespace: "default",
        },
        syncPolicy: {
            automated: {
                prune: true,
                selfHeal: true,
            },
        },
    },
});

// Export the URLs of the applications
export const app1Url = pulumi.interpolate`https://argocd.example.com/applications/${app1.metadata.name}`;
export const app2Url = pulumi.interpolate`https://argocd.example.com/applications/${app2.metadata.name}`;

Summary

In this guide, we created an Argo CD project to group related applications and defined two applications associated with this project. This setup allows for better organization and management of your applications in Argo CD.

Deploy this code

Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.

Sign up

New to Pulumi?

Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.

Sign up