BootStrap K8s with ArgoCD

Table of Contents

  1. Introduction
  2. Clone the Repository
  3. Provision EKS Cluster
  4. Update EKS Configuration
  5. Apply Manifest Files
  6. Bootstrapping with ArgoCD
  7. Conclusion

Introduction

In this article, we will learn how to bootstrap our Kubernetes cluster with ArgoCD. To achieve this, we need a running cluster which can either be EKS, GKS, or AKS, our manifest files which are inside our GitHub repository, and an ArgoCD account.

Clone the repository

git clone https://github.com/Victoria-OA/manifests.git

cd into the eks folder which contains the Terraform files to provision your cluster on AWS:

terraform init
terraform plan
terraform apply

Update EKS Configuration

After our EKS configuration has been successfully applied to AWS, update it using the following command so our manifest files can be applied to the cluster:

aws eks --region <region> update-kubeconfig --name <cluster-name>

Apply Manifest Files

After updating your cluster to receive manifests configuration, apply the files in the manifest folder with:

kubectl apply -f a.yaml

Bootstrapping with ArgoCD

Once your manifest files have been applied, the next step is to bootstrap them to ArgoCD to enhance continuous delivery. Follow these steps:

  1. Add a namespace for ArgoCD:

    kubectl create namespace argocd
  2. Install ArgoCD:

    kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
  3. Confirm ArgoCD Pods:

    After installation, wait for a while for the pods to be ready and confirm it using:

    kubectl get pods -n argocd
  4. Map Port for ArgoCD Access:

    When the pods are ready, map your port to access ArgoCD in the browser:

    kubectl port-forward svc/argocd-server -n argocd 8080:443
  5. Retrieve ArgoCD Admin Password:

    Upon access, you will be required to log in with a username and a password. The username is admin, and the password can be retrieved using the following command:

    kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d
  6. Log in to ArgoCD:

    When the password has been retrieved, log in to ArgoCD with:

    argocd login localhost:8080
  7. Connect GitHub Repository to ArgoCD:

    Once logged in successfully, connect the GitHub repo that contains the manifest with the following command:

    argocd repo add https://github.com/username/repourl --username <your-github-username> --password <your-personal-access-token>

    Note: To get your GitHub password, use your GitHub token, which can be generated in developer’s settings.

  8. Add Your Cluster to ArgoCD:

    Once your repo has been connected successfully, add your cluster to the ArgoCD server using the following command:

    kubectl config get-contexts
    argocd cluster add <context-name>
  9. Create and Sync Your Application:

    Once the cluster has been added successfully, proceed to create your app and configure your ArgoCD using:

    argocd app create appname \
       --repo https://github.com/username/repourl \
       --path manifests/ \
       --dest-server https://kubernetes.default.svc \
       --dest-namespace argocd
  10. Sync Your Application:

    Finally, sync your app using the following command:

    argocd app sync newapp

Once the sync is successful, you can log in to your ArgoCD via the browser to check it out.

Conclusion

By following these steps, you have set up a Kubernetes cluster, applied your manifest files, and integrated ArgoCD for continuous delivery. This setup not only streamlines your deployment process but also enhances the manageability and scalability of your applications.