Deploy the argocd-operator helm chart on AWS EKS
TypeScriptTo deploy the Argo CD operator Helm chart on AWS Elastic Kubernetes Service (EKS), you would need to follow these steps:
- Set up an AWS EKS cluster.
- Configure
kubectl
to interact with the EKS cluster. - Install the Helm CLI tool to manage Helm chart deployments.
- Use Pulumi to deploy the Helm chart for Argo CD operator to the EKS cluster.
First, let's set up an EKS cluster using Pulumi. We will utilize the
awsx
package which provides a higher-level abstraction to provision an EKS cluster conveniently. Additionally, we'll configure the necessary roles and instance profiles for our EKS cluster to function correctly.Here's a Pulumi program written in TypeScript that creates an EKS cluster and deploys the Argo CD operator Helm chart:
import * as awsx from "@pulumi/awsx"; import * as eks from "@pulumi/eks"; import * as k8s from "@pulumi/kubernetes"; // Create an EKS cluster with the default configuration. const cluster = new eks.Cluster("my-cluster", { desiredCapacity: 2, minSize: 1, maxSize: 3, storageClasses: "gp2", deployDashboard: false, }); // Export the clusters' kubeconfig. export const kubeconfig = cluster.kubeconfig; // K8s provider to use the cluster's kubeconfig. const provider = new k8s.Provider("provider", { kubeconfig: cluster.kubeconfig, }); // Deploy the argocd-operator Helm chart to the EKS cluster. const argocdChart = new k8s.helm.v3.Chart("argocd-operator", { chart: "argocd-operator", version: "0.0.15", // Replace with the version of Argo CD operator you want to deploy namespace: "argocd", fetchOpts:{ repo: "https://argoproj.github.io/argo-helm", // The Helm repository for Argo CD }, }, { provider }); // Export the Argo CD server URL (After it gets a LoadBalancer IP assigned). export const argoCdServerUrl = argocdChart.getResourceProperty("v1/Service", "argocd-operator-argocd-server", "status").apply(status => `http://${status.loadBalancer.ingress[0].hostname}`);
Let's walk through the code:
-
We import the required Pulumi packages --
awsx
for AWS resources,eks
for Elastic Kubernetes Service resources, andkubernetes
for resources related to Kubernetes. -
We define an EKS cluster using the
eks.Cluster
class provided by the@pulumi/eks
package. We set the desired capacity, minimum size, and maximum size for the cluster. ThestorageClasses
specify the type of storage to be used, anddeployDashboard
is set to false because we don't need the Kubernetes dashboard. -
We then export the kubeconfig of the cluster so that it can be used by
kubectl
outside of Pulumi if needed. -
We create a Kubernetes provider using the kubeconfig from the EKS cluster. This provider will be used to deploy Kubernetes resources, ensuring that they're targeting the correct cluster.
-
We deploy the Argo CD operator Helm chart using
k8s.helm.v3.Chart
. We specify the chart name, chart version, and namespace where Argo CD should be installed. We ensure that this Helm chart is deployed to our EKS cluster by specifying the provider. -
Finally, we export an endpoint for the Argo CD server. This may take a while to resolve since it relies on the external IP address assigned by the LoadBalancer service of Argo CD.
To run this Pulumi program, you will need to:
- Install Pulumi and configure it with your AWS credentials.
- Ensure you have Node.js and NPM installed.
- Create a new directory and initialize a Pulumi project in TypeScript.
- Install the necessary dependencies by running
npm install @pulumi/awsx @pulumi/eks @pulumi/kubernetes
. - Place the TypeScript code into a file named
index.ts
. - Run
pulumi up
to deploy the resources. - Use the exported
kubeconfig
to configure your localkubectl
to interact with the cluster.
Keep in mind that EKS costs and resource provisioning times might vary, and the external IP for the LoadBalancer service could take a few minutes to become available. After the deployment is complete and the LoadBalancer has an external IP, you should be able to access the Argo CD dashboard using the provided URL.