GitOps: Example of a GitOps workflow using Argo CD
Argo CD: Managing Different Environments
You can manage different clusters using the same instance of Argo CD. For example, you can have a development environment, a staging environment, and a production environment. Each environment can be represented by a different Kubernetes cluster.
To add a cluster, use the following commands:
export cluster=
argocd cluster add $cluster -y
If we have a production cluster called production and a staging cluster called staging, we can add them to Argo CD using the following commands:
export cluster=production
argocd cluster add $cluster -y
export cluster=staging
argocd cluster add $cluster -y
In the Argo CD UI, you can see the different clusters in the Settings tab. Otherwise, list your clusters using:
argocd cluster list
Export the name of the cluster you want to use, depending on the environment to which you wish to deploy the application.
export CLUSTER=
# Example if you want to deploy to the default cluster
# export CLUSTER=kubernetes.default.svc
Then, deploy the application to that cluster using the following command:
kubectl apply -f - <
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: flask-app
namespace: argocd
spec:
destination:
namespace: flask-app
# $CLUSTER is the name of the cluster
# you want to deploy the application to
server: $CLUSTER
project: default
source:
repoURL: https://github.com/eon01/argocd-examples
targetRevision: main
path: flask-app-helm
helm:
valueFiles Cloud-Native Microservices With Kubernetes - 2nd Edition
A Comprehensive Guide to Building, Scaling, Deploying, Observing, and Managing Highly-Available Microservices in KubernetesEnroll now to unlock all content and receive all future updates for free.
