1. Answers
  2. Using Kubernetes Apps with Argo CD

How do I use Kubernetes apps with Argo CD?

In this tutorial, we will deploy and manage Kubernetes applications using Argo CD with Pulumi. Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes. It allows you to deploy applications from Git repositories and manage them using a GitOps workflow.

We will:

  1. Install Argo CD in a Kubernetes cluster.
  2. Create an Argo CD application that syncs with a Git repository.
  3. Deploy a sample Kubernetes application using Argo CD.
import * as pulumi from "@pulumi/pulumi";
import * as k8s from "@pulumi/kubernetes";

// Create a Kubernetes namespace for Argo CD
const argoNamespace = new k8s.core.v1.Namespace("argo-namespace", {
    metadata: {
        name: "argocd",
    },
});

// Install Argo CD using its official Helm chart
const argoCd = new k8s.helm.v3.Chart("argo-cd", {
    chart: "argo-cd",
    version: "4.5.2",
    fetchOpts: {
        repo: "https://argoproj.github.io/argo-helm",
    },
    namespace: argoNamespace.metadata.name,
});

// Define the Argo CD application
const argoApp = new k8s.apiextensions.CustomResource("argo-app", {
    apiVersion: "argoproj.io/v1alpha1",
    kind: "Application",
    metadata: {
        name: "sample-app",
        namespace: argoNamespace.metadata.name,
    },
    spec: {
        project: "default",
        source: {
            repoURL: "https://github.com/argoproj/argocd-example-apps",
            targetRevision: "HEAD",
            path: "guestbook",
        },
        destination: {
            server: "https://kubernetes.default.svc",
            namespace: "default",
        },
        syncPolicy: {
            automated: {
                prune: true,
                selfHeal: true,
            },
        },
    },
}, { dependsOn: argoCd });

export const argoCdUrl = pulumi.interpolate`http://${argoCd.getResource("v1/Service", "argocd-server").status.loadBalancer.ingress[0].ip}`;

Key Points:

  • Argo CD Installation: We installed Argo CD in a Kubernetes cluster using the official Helm chart.
  • Namespace Creation: A dedicated namespace for Argo CD was created.
  • Argo CD Application: An Argo CD application was defined to sync with a Git repository and deploy a sample Kubernetes application.

Summary

We successfully deployed and managed a Kubernetes application using Argo CD with Pulumi. Argo CD allows you to implement GitOps workflows, making application deployment and management more efficient and reliable.

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