1. Answers
  2. Deploy a Kubernetes argoproj.io Application

How Do I Deploy a Kubernetes Argoproj.io Application?

Introduction

In this guide, we will explore how to deploy a Kubernetes application using ArgoCD, a part of the argoproj.io suite, with Pulumi. ArgoCD is a powerful declarative GitOps continuous delivery tool for Kubernetes that enables automated deployment and management of applications. Our objective is to create a Kubernetes namespace, deploy ArgoCD, and use it to manage a sample application, thereby demonstrating a practical approach to GitOps.

Step-by-Step Deployment Process

  1. Create a Kubernetes Namespace for ArgoCD: Begin by establishing a dedicated Kubernetes namespace where ArgoCD will be deployed. This isolation helps manage resources effectively.

  2. Deploy ArgoCD Using a Helm Chart: Utilize Helm, a package manager for Kubernetes, to deploy ArgoCD. This step involves fetching the ArgoCD Helm chart and installing it in the namespace created earlier.

  3. Configure ArgoCD to Manage a Sample Application: Set up ArgoCD to manage a sample application by defining an ArgoCD Application resource. This configuration specifies the source repository, target revision, and the destination namespace where the application will be deployed.

import * as pulumi from "@pulumi/pulumi";
import * as k8s from "@pulumi/kubernetes";

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

// Deploy ArgoCD using Helm chart
const argoCdChart = new k8s.helm.v3.Chart("argo-cd", {
    chart: "argo-cd",
    version: "3.23.0",
    fetchOpts: { repo: "https://argoproj.github.io/argo-helm" },
    namespace: argocdNamespace.metadata.name,
    values: {
        server: {
            service: {
                type: "LoadBalancer",
            },
        },
    },
});

// Create a Kubernetes namespace for the sample application
const appNamespace = new k8s.core.v1.Namespace("app-namespace", {
    metadata: { name: "sample-app" },
});

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

export const argoCdUrl = argoCdChart.getResource("v1/Service", "argocd/argocd-server").status.loadBalancer.ingress[0].hostname;

Key Points

  • Namespace Isolation: Establish distinct namespaces for ArgoCD and the application to streamline resource management.
  • Helm Utilization: Deploy ArgoCD efficiently using Helm charts, leveraging its robust package management capabilities.
  • GitOps Configuration: Configure ArgoCD to automate the deployment and management of a sample application, enabling continuous delivery practices.

Conclusion

In this guide, we successfully deployed a Kubernetes application using ArgoCD with Pulumi. By creating separate namespaces, deploying ArgoCD via Helm, and configuring it to manage a sample application, we demonstrated a practical application of GitOps principles. This setup provides a scalable and automated approach to managing Kubernetes applications, reinforcing the importance of infrastructure as code and continuous delivery in modern cloud environments.

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