GitOps: Example of a GitOps workflow using Argo CD
86%
Argo CD: The Declarative Way
The commands we have explored so far are useful, but they are imperative. In a world of "everything-as-code," it's often better to use the declarative way of doing things.
# Example of an imperative command to create an application
argocd app create flask-app \
--repo https://github.com/eon01/argocd-examples/ \
--path flask-app \
--dest-server https://kubernetes.default.svc \
--dest-namespace flask-app \
--revision main \
--sync-policy automated \
--self-heal \
--auto-prune \
--allow-empty
Using the declarative approach means that we can define the application in a representative YAML
manifest file that describes the desired state of the Application resource, and then apply it and reapply it as needed.
Let's delete the previous application:
argocd app delete flask-app -y
Then, let's recreate it using this YAML:
kubectl apply -f - <
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: flask-app
namespace: argocd 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.
