How to Deploy 100 Microservices into 1 Cluster with ArgoCD

Concentrated answer: create an individual folder for each service containing the configuration file and use application set to generate application.

Let’s first describe the problem. The problem is that you have more than 100 micro-services that have been deployed to your cluster or you are planning to do so

Therefore

  • You always want to deploy to your K8s with up-to-date manifests.

  • Apply security patches as soon as possible

  • Introduce configurations changes

  • Add new Kubernetes manifests (pdb, hpa etc)

  • Deploy new applications

  • Better visibility for deployed versions

  • Maintenance of Kubernetes manifests or helm charts

My assumption is that all 100 Microservices more or less similar and it can be deployed to Kubernetes cluster using similar configuration. Basically MS are consists of 1 container image and manifests.

Q&A: Helm vs. Native Kubernetes Yaml Manifest?

I prefer using the Helm Chart for its advantages in terms of DRY (Don’t Repeat Yourself) and the ability to pass parameters, even though I won’t delve into its specific details and explanation.

Q&A: Where Can I Store Kubernetes Manifest?

I would like to store it in the OCI registry otherwise I need to give ArgoCD access to the 100 source code repository. I can store the Charts in the same repository but this time if I want to change or add anything to the application then I have to do it for 100 folders. Therefore the best way is to store the Helm Chart in the OCI registry so that ArgoCD can be configured to get the chart.

Store the Helm Chart files in a repository and implement a pipeline to push the chart to the OCI registry. Here is an example:

name: Helm Charts

on:
  push:
    branches:
      - main
jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2      - name: Publish Microservice Chart
        run: | 
          helm package microservice
          echo ${{ secrets.GIT_PAT }} | docker login ghcr.io -u argo-universe --password-stdin
          export CHART_VERSION=$(grep 'version:' ./microservice/Chart.yaml | tail -n1 | awk '{ print $2 }')
          helm push microservice-${CHART_VERSION}.tgz oci://ghcr.io/argo-universe

Q&A: How Can I Deploy MS with ArgoCD?

The fundamental basis of the ArgoCD is that we deploy an ArgoCD CRD Application and ArgoCD applies the instruction in the Application. So this is the definition of deploying one MS:

We need to deploy 100 MSs which means we need to configure 100 Application Manifest.

However, there is a better way called “ApplicationSet”. What does it is very simple. It creates an “Application” based on your template and your generators

So we will use “ApplicationSet” to generate 100 “Application” based on our Application template.

“ApplicationSet” solves our manual creation of 100 ArgoCD “Application”.

Q&A: Where Can I store the “ApplicationSet”?

I would like to store my ApplicationSet.yaml file in a root or base repository that I like to call Bingbang repo since this ApplicationSet will create 100s of applications it is like a starting point of a Universe of applications.

I would like to create another “Application” called Bigbang to deploy “ApplicationSet” so that I can see the “ApplicationSet” at ArgoCD UI.

Q&A: Where Can I store the Helm Value files?

We need a place to store the Helm Value files. We will use the value files to generate our final manifest.

We will use the benefit of Helm dependency

## Chart.yaml
apiVersion: v2
name: backend-app
description: backend microservice using argouniverse helm chart
type: application
version: v1
appVersion: v1
dependencies:
  - name: microservice
    version: "0.1.1"
    repository: oci://ghcr.io/argo-universe
## values.yaml
microservice:
  image:
    repository: "argouniverse/backend-app" 
    imageTag: dev-6
  serviceAccount:
    create: false
  service:
    port: 3000

Therefore all we need to do is the configuration of values.yaml file

Here is what gonna happen:

1- “ApplicationSet” will generate “Application”

2- Based on the configuration of the “Application” ArgoCD will pull the Chart.yaml and values.yaml from the app1 folder

3- ArgocdCD will pull the “microservice” chart from the OCI registry and generate manifest

4- ArgoCD will apply the manifest to the cluster.

Q&A: How Can I deploy the Bigbang “Application”?

You can either deploy it manually or with a Pipeline but I believe nowadays pipelines are the best way to do it.

Below you can see the entire setup all together. Let’s describe each of the steps once again:

1 — Pipeline will deploy Bigbang “Application”

2 — Bigbang Application will deploy the “ApplicationSet”

3 — “ApplicationSet” will create “Application”s and deploy them

4 — ArgoCD will pull the files from the Repository and Registry

5 — ArgoCD will generate a Kubernetes manifest and apply it

The source code for the tutorial can be found here:

https://github.com/kushwahvishal939/argo-bigbang.git

Did you find this article valuable?

Support Vishal Kushwah Blog by becoming a sponsor. Any amount is appreciated!