A GitOps continuous delivery tool for Kubernetes
Nothing but the Truth
Ready, Steady, …
After setting up Argo CD and the Argo CD CLI, you can register a cluster to deploy applications to and create an application from a Git repository. By default, Argo CD will deploy applications to the Kubernetes cluster on which it is installed. If you want to deploy applications to a different cluster, you need to register that cluster with Argo CD.
To register a cluster, use the command to add a cluster,
argocd cluster add <CONTEXT_NAME>
which requires the kubeconfig context name of the cluster you want to register.
A Simple Example
Now you can see how Argo CD leverages the power of Git to define your applications in a declarative manner and maintain version control. In other words, your application's desired state is described within your Git repository, and any changes to this state are tracked and version controlled.
For instance, consider a simple application defined by a Kubernetes Deployment (Listing 1) and Service (Listing 2). You can store the YAML manifests for these resources in a Git repository.
Listing 1
deployment.yaml
apiVersion: apps/v1 kind: Deployment metadata: name: my-app spec: replicas: 3 selector: matchLabels: app: my-app template: metadata: labels: app: my-app spec: containers: - name: my-app image: my-org/my-app:1.0.0 ports: - containerPort: 8080
Listing 2
service.yaml
apiVersion: v1 kind: Service metadata: name: my-app spec: selector: app: my-app ports: - protocol: TCP port: 80 targetPort: 8080
With Argo CD, you can create an application that tracks the state of these resources:
argocd app create my-app --repo https://github.com/my-org/my-repo.git --path /path/to/application/manifests --dest-namespace default --dest-serverhttps://kubernetes.default.svc --sync-policy automated
This command creates an Argo CD application that automatically synchronizes the state of your Kubernetes application with the desired state defined in your Git repository.
Configurations and Environments
Argo CD's support for declarative and version-controlled configurations extends to environments as well. You can manage different environments such as development, staging, and production with separate namespaces in your Kubernetes cluster or even separate clusters.
For example, you can create different Argo CD applications for different environments. In the command in Listing 3, the development environment is automatically synchronized with the Git repository, whereas the production environment requires manual synchronization, which allows you to control when changes are deployed to production.
Listing 3
Environment Syncs
# Development environment sync policy argocd app create my-app-dev --repo https://github.com/my-org/my-repo.git --path /path/to/application/manifests --dest-namespace dev --dest-server https://kubernetes.default.svc --sync-policy automated # Production environment sync policy argocd app create my-app-prod --repo https://github.com/my-org/my-repo.git --path /path/to/application/manifests --dest-namespace prod --dest-server https://kubernetes.default.svc --sync-policy manual
Buy this article as PDF
(incl. VAT)
Buy ADMIN Magazine
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Most Popular
Support Our Work
ADMIN content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.