Skip to content

ArgoCD Deployment

Version 2: 25/04/2024

Version 2.0.1 14/05/2024
Changelog:
prRootFolder for changing folder in bank-deployment in Step 3. Needed for non Minority apps.
Added step 5

Version 2.0.2 15/05/2024
Changelog:
Add dbNameOverride option to enable non minority app db to fit in template. Step 3.
Version 2.0.3 19/06
Changelog:
Add regressionFilter parameter to deploy and additionalRegressions

STEP 1

Create the values files in the bank-deployment git project

Assuming a deployment is being made in all 3 environments, the following files must be created as per the project structure:

Repo > Minority > appArea > appProject > {env}-values.yaml

Example: For the 2 projects above the files would look like this

Project 1: SendTab API

Repo > Minority > Minority.SendTab > Minority.SendTab.Api > dev-values.yaml
Repo > Minority > Minority.SendTab > Minority.SendTab.Api > stage-values.yaml
Repo > Minority > Minority.SendTab > Minority.SendTab.Api > prod-values.yaml

Project 2: SendTab Service

Repo > Minority > Minority.SendTab > Minority.SendTab.Service > dev-values.yaml
Repo > Minority > Minority.SendTab > Minority.SendTab.Service > stage-values.yaml
Repo > Minority > Minority.SendTab > Minority.SendTab.Service > prod-values.yaml

The following values are required

FIELD
DESCRIPTION
name (required)
Name of the project. Example minority-sendtab-api. The format of the name must be minority-{area}-{api/service/job}
imageTag (optional)
imageTag will be the field that is updated by the build pipeline.
environment (required)
The environment expected by the .net app. Possible values Test, Staging, Production
replicaCount (optional)
The number of replicas required. If you omit the values, it will take the replicaCount from your projects values file. If you omit the replicaCount in the projects values file, it will default to 1 replica.
ingress (optional for service and api. Required for job)
Default is true. Must be set to false for job
service (optional for service and api. Required for job)
Default is true. Must be set to false for job

EXAMPLE PR

https://dev.azure.com/MAJORITY/Bank/_git/bank-deployments/pullrequest/29512

STEP 2

Create a new ArgoCD App in bank-azure-infrastructure

Following are the fields required in an app block in the above file

FIELD
DESCRIPTION
name
Name of the deployment. Keep this consistent with name of repo.
appProjects
Name of the projects to be deployed in the area. This could be a service or an api or a job. The repo structure we follow is as follows: Repo > Minority > Minority.appArea > Minority.appProject > charts. For example for deploying the service nonpersonalizedcard, the appProjects will be [Minority.NonPersonalizedCard.Service]
appArea
Name of the area to be deployed inside the repo. The repo structure we follow is as follows: Repo > Minority > Minority.appArea > Minority.appProject > charts. For example for deploying the service nonpersonalizedcard, the appArea will be Minority.NonPersonalizedCard
project
Name of the project in ArgoCD to deploy the app in.
repoURL
Repository of the project
namespace
The Kubernetes namespace to deploy the app
targetRevision
The target revision to deploy
env
Available options: dev, stage, prod

A sample area app would look like this.

NOTE: It is advisable to first create the app only for dev. Once you are satisfied with the deployment, you can add apps for stage and prod.

Project: SendTab API

EXAMPLE PR

https://dev.azure.com/MAJORITY/Bank/_git/bank-azure-infrastructure/pullrequest/29472?_a=files

STEP 3

Modify your build pipeline to add the deployment stage as follows.

Please note the following changes from the old pipeline

Change 1: Change the build stage template from build.yaml to buildApp.yaml

Reason: buildApp.yaml removes the helm package and publish stage which will now be handled by ArgoCD.

Change 2: Add Deployment stage template

Reason: This will replace the release pipeline.

projects: [] : Array of projects to be deployed.
area: The area of the deployment. Usually Minority.areaName.
app: The argocd app to deploy to.
dbDeploy: true if the area has a database.
prRootFolder: Required for 'Risk' or 'MoneyFlow'. If not specified, defaults to Minority.
additionalRegressions: This is an array of any additional regressions that want to be run. Must have 3 fields - name, pipeline and project.
dbNameOverride: Required for non Minority apps. The name that replaces the variable in prod-{0}-use2-sqlDb

BUILD AND DEPLOYMENT WITHOUT DB:

stages:
- template: Pipelines/BuildTemplate/buildApp.yml@cicdtemplate
parameters:
PROJECTNAMES: ["Minority.SendTab.Api","Minority.SendTab.Service"]

  • template: Pipelines/ArgoCD/deploy.yaml@cicdtemplate
    parameters:
    projects: ["Minority.SendTab.Api","Minority.SendTab.Service"]
    area: 'Minority.SendTab'
    app: 'bank-sendtab'
    prRootFolder: 'Risk' (For non Minority apps only - Risk, MoneyFlow etc)
    dbNameOverride: 'risk'
    regressionFilter: "TestCategory!='Risk'"
    additionalRegressions:
    - name: Transactions
    project: Bank
    regressionFilter: "TestCategory!='Risk'"
    pipeline: Minority Transactions

BUILD AND DEPLOYMENT STAGE WITH DB

stages:
- template: Pipelines/BuildTemplate/dbbuild.yml@cicdtemplate
parameters:
dbprojectname: 'Minority.Locations.Db'

  • template: Pipelines/BuildTemplate/buildApp.yml@cicdtemplate
    parameters:
    PROJECTNAMES: ["Minority.Locations.Api","Minority.Locations.Service"]
  • template: Pipelines/ArgoCD/deploy.yaml@cicdtemplate
    parameters:
    projects: ["Minority.Locations.Api","Minority.Locations.Service"]
    dbDeploy: true
    area: 'Minority.Locations'
    app: 'bank-locations'
    prRootFolder: 'Risk' (For non Minority apps only - Risk, MoneyFlow etc)
    dbNameOverride: 'risk'
    regressionFilter: "TestCategory!='Risk'"
    additionalRegressions:
    - name: Transactions
    project: Bank
    regressionFilter: "TestCategory!='Risk'"
    pipeline: Minority Transactions

STEP 4

Once you have done the above steps, the argo app will be created. However, when you go to the console, the app will show as out of sync.

This is because the service/api/job manifests still have the annotations/labels from the older argo apps (migration) or do not have annotations/labels at all (new deployments). Click on the "DIFF" button to see the difference.

Now you need to "SYNC" the application. ArgoCD will then add to/change the manifests. Please note that for the "SYNC" to work, you need to FORCE sync it. Force sync is only required the first time during setup. Please see important instruction below

WARNING: BEFORE you force sync, you need to ensure that the deployment values file has an imageTag. If it doe s not, please run the build pipeline once and ensure that your values files have the imageTag field.

STEP 5

No step 5. Have fun :)