Using kubernetes argoproj.io with node-group
TypeScriptTo accomplish your goal of using Kubernetes with an Argo Project (argoproj.io) in combination with managing node groups, you might use Pulumi with Kubernetes to deploy ArgoCD, a component of the Argo project, along with configuring a specific node group for it.
Firstly, you'll need Pulumi and Kubernetes set up. You'll also need
kubectl
configured to interact with your Kubernetes cluster, and Pulumi configured with access to your cluster.We will start with the following steps:
- Define the Kubernetes resources using Pulumi's Kubernetes Provider.
- Install ArgoCD, the declarative and GitOps continuous delivery tool from Argo.
- Configure a node group specifically for ArgoCD, allowing it to have specified resources such as taints, labels, and compute resources.
Below is a Pulumi program written in TypeScript that you can use to deploy ArgoCD and configure a node group for it.
import * as k8s from '@pulumi/kubernetes'; import * as eks from '@pulumi/eks'; // Create an EKS cluster. const cluster = new eks.Cluster('eks-cluster', {}); // Define the ArgoCD namespace resource. const ns = new k8s.core.v1.Namespace('argocd', { metadata: { name: 'argocd' }, }, { provider: cluster.provider }); // Install ArgoCD using the Helm chart. const argocdChart = new k8s.helm.v3.Chart('argocd-chart', { namespace: ns.metadata.name, chart: 'argo-cd', fetchOpts: { repo: 'https://argoproj.github.io/argo-helm' }, }, { provider: cluster.provider }); // Define a Kubernetes NodeGroup specifically for ArgoCD. const argocdNodeGroup = new eks.NodeGroup('argocd-nodegroup', { cluster: cluster, nodeGroupName: 'argocd-nodes', nodeRole: cluster.instanceRoles[0], subnetIds: cluster.core.subnetIds, scalingConfig: { desiredSize: 2, minSize: 1, maxSize: 3, }, labels: { 'workload-type': 'argocd' }, taints: [{ key: 'dedicated', value: 'argocd', effect: 'NoSchedule', }], instanceTypes: ['t3.medium'], }, { provider: cluster.provider }); // Export the cluster's kubeconfig. export const kubeconfig = cluster.kubeconfig;
Explanation
- We import the necessary Pulumi libraries for Kubernetes and EKS.
- A new EKS cluster is created using Pulumi's EKS package. This is where our ArgoCD will be deployed.
- The ArgoCD namespace is defined using Kubernetes'
Namespace
resource to isolate the ArgoCD resources. - We then install ArgoCD on our cluster using the
Chart
resource from the@pulumi/kubernetes/helm
package. We specify the repository URL where the ArgoCD Helm chart is located. - We define a
NodeGroup
specifically for ArgoCD within our EKS cluster. This allows us to assign specific nodes for ArgoCD deployment, giving us the ability to:- Label these nodes with
'workload-type': 'argocd'
for easier identification. - Taint the nodes with
'dedicated': 'argocd'
and'NoSchedule'
. The taint prevents other workloads from being scheduled on these nodes unless they tolerate the taint. - Specify the desired size, min size, and max size for scalability.
- Set the instance type to be used for these nodes.
- Label these nodes with
- Finally, we export the cluster's kubeconfig which can be used to interact with the cluster via
kubectl
.
This program sets up an EKS cluster, installs ArgoCD in its own namespace, and configures a dedicated node group specifically for ArgoCD. With this setup, you have fine-grained control over the resources that the ArgoCD pods can use. The taints and labels ensure that the workloads are appropriately segregated to maintain organized resource management and security practices.