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

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy ADMIN Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Native serverless computing in Kubernetes
    Knative transfers serverless workloads to Kubernetes and provides all the container components you need to build serverless applications and PaaS and FaaS services.
  • Secure and seamless server access
    The powerful Cloudflare Tunnel provides secure and seamless access to servers and applications, making it a convenient alternative to VPN for any modern IT infrastructure.
  • Users speak on Kubernetes in business practice
    Users in corporate and government agencies that have successfully switched to Kubernetes share their positive experiences and the stumbling blocks to be avoided.
  • Secure Kubernetes with Kubescape
    Kubescape checks Kubernetes container setups for security and compliance issues, making life easier for administrators.
  • Nested Kubernetes with Loft
    Kubernetes has limited support for multitenancy, so many admins prefer to build multiple standalone Kubernetes clusters that eat up resources and complicate management. As a solution, Loft launches any number of clusters within the same control plane.
comments powered by Disqus
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs



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.

Learn More”>
	</a>

<hr>		    
			</div>
		    		</div>

		<div class=