ArgoCD+Terraform=EKS

CI/CD - Continues Deployment using ArgoCD, Terraform to AWS EKS cluster

Prerequisites

Before deploying ArgoCD, you must have the following:

  • An AWS account with permissions to create EKS clusters and associated resources

  • kubectl and aws CLI tools installed and configured

  • A domain name and SSL certificate for the ArgoCD server (optional)

  • eksctl installed NOTE! eksctl created a kubectl config file in ~/.kube or added the new cluster's configuration within an existing config file in ~/.kube.

Create a EKS using file "eks_cluster_dev.yaml"

eksctl create cluster -f eks_cluster_dev.yaml

Repeat tasks for PROD claster when ready:

eksctl create cluster -f eks_cluster_prod.yaml

Deployment Steps

  1. Go to the "cluster_conf" folder and run eksctl commands to create EKS clusters:

Create EKS clusters in the desired environment (dev, stage, or prod)

cd cluster_conf
eksctl create cluster -f eks_cluster_dev.yaml

it takes 5-10 mins to get it ready.

  1. Configure kubectl to use the new cluster. To switch to another cluster use the corresponding cluster name

aws eks update-kubeconfig --name dev
  1. Deploy the ArgoCD server and API components

cd terraform
terraform init
terraform plan
terraform apply
  1. Once deployed go to get Password for ArgoCD (repeat it for DEV, STAGE and PROD env)

kubectl get secret -n argocd argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d

In output: v7zsMfACEB6TBllN #example KfeEDzCCv4-BBLLq

  1. Configure the ArgoCD server with the desired settings (SSH keys generating)

cd terraform 
mkdir keys
cd keys && ssh-keygen

<output: > Generating public/private rsa key pair.
Enter file in which to save the key (/Users/serg/.ssh/id_rsa): argocd
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in argocd
Your public key has been saved in argocd.pub
......

Then copy PUBLIC KEY to GitHub repo in Settings / Deploy keys

cd keys && cat argocd.pub

And PRIVATE KEY to ArgoCD Settings/Repository/Connect (for ALL environments will be set up the SAME Private Key)

  1. (Optional) Set up a domain name and SSL certificate for the ArgoCD server

Last updated