Gitops with Argo CD & Kyma, Multi-cluster management
2023-11-5 09:21:53 Author: blogs.sap.com(查看原文) 阅读量:14 收藏

Hi all,

In my previous blog I shared my experience creating a simple and single app deployed in a single cluster, but what if you need to manage hundreds of apps in a large and dynamic environments deployed in different SAP Kyma clusters, do you need to maintain all of them in every cluster?, let me try to answer it 🙂

real%20life%20scenario

SAP Kyma Cluster per environment

First of all Argo CD can deploy applications in multiple SAP Kyma clusters from one unique SAP Kyma cluster:

Argo%20CD%20Agents

Argo CD Agents

The only thing that you need is to install the Argo CD agents in the other clusters that you want to manage.

Second, Argo CD provides a controller ( that need to be installed apart of the main installation ) that allow the creation of “ApplicationSet”, unlike with an Argo CD Application resource, which deploys resources from a single Git repository to a single destination cluster/namespace, “ApplicationSet” uses templated automation to create, modify, and manage multiple Argo CD applications simultaneously, targeting multiple destination clusters/namespaces.

ApplicationSet

ApplicationSet

As you can start to imagine, this controller is very useful to generate dynamic environments, with dynamic applications that needs to be deployed in dynamic SAP Kyma clusters, let’s try to use the following repository structure to handle the our scenario:

IaC%20-%20repository

Infrastructure as Code – repository

We can see :

  • Folder called “envs” that contains all environments
  • Folder called “dev”:
    • That contains :
      • Folder “argocd” –> Contains the “ApplicationSet” for this environment
      • Folder “test3” –> SAP CAP application
      • Folder “test4” –> SAP CAP application
  • Folder called “qas” & “prd”: they are equals from structure point of view
  • File called “envs-generator.yml” representing the “ApplicationSet” for this repository

The main idea of this repository is to create one unique “Argo CD application” ( called “app-generator-envs” ) for the “Argo CD ApplicationSet” that will create automatically & dynamically “Argo CD applications” per environments using the folder “envs” ( called “app-generator-<environment>” ) where those applications will create automatically & dynamically “Argo CD applications” per application to deploy using the folder “envs/<environment>” ( called “app-generated-<environment>-<app>”).

Let’s see it in action:

app-generator-envs%28%20definition%20%29

app-generator-envs( definition )

app-generator-envs%28%20result%20%29

app-generator-envs( result )

appset-generator-envs%28%20definition%20%29

appset-generator-envs( definition )

app-generator-dev%28%20result%20%29

app-generator-dev( result )

appset-generator-dev

appset-generator-dev( definition )

app-generated-dev-test3%28%20result%20%29

app-generated-dev-test3( result )

So, after deploying one unique “Argo CD Application” all the SAP CAP applications were deployed as desired in the IaC repository ( for the sake of this blog only one cluster was used, but it could be specified in the “appset-generator-<environment>” file).

We can classify the “Argo CD Applications ” as “generator” & “generated”:

Generator%20apps

Generator Argo CD Applications

Generated%20Argo%20CD%20Applications%20%28%20SAP%20CAP%20apps%20%29

Generated Argo CD Applications ( SAP CAP apps )

So, the following questions could raise in your mind:

  • How to add a new SAP CAP application in “dev” environment? –> just add the app folder under “envs/dev” and it will automatically sync by the “appset-generator-dev”
  • How to promote a new SAP CAP application from “dev” to “qas”?, just copy & paste your app folder from “dev” folder to “qas” folder and it will automatically sync by the “appset-generator-qas”
  • How to add a new environment ? –> just add the new environment folder under “envs” and the corresponding “appset-generator-<environment>” and it will automatically sync by the “appset-generator-envs”

It’s really easy to deploy multiples SAP CAP applications in different SAP Kyma clusters using Argo CD 😉


文章来源: https://blogs.sap.com/2023/11/05/gitops-with-argo-cd-kyma-multi-cluster-management/
如有侵权请联系:admin#unsafe.sh