Photo by Tingey Injury Law Firm on Unsplash

Photo by Tingey Injury Law Firm on Unsplash

A GitOps continuous delivery tool for Kubernetes

Nothing but the Truth

Article from ADMIN 76/2023
By
Argo CD uses Git repositories as the source of truth for defining a desired application state and automates the deployment in target environments.

GitOps is a paradigm or a set of practices that empowers developers to perform tasks that typically are done by the operations team. GitOps requires code to be declarative and uses Git as the single source of truth for the system's desired state. The Git repository, in this case, becomes the core element for version control, code review, and automated deployment.

Argo CD, a project of the Cloud Native Computing Foundation (CNCF), is a declarative, GitOps continuous delivery tool for Kubernetes. It leverages the Git repository as the source of truth for Kubernetes resources and applications' desired state.

GitOps is a way of implementing continuous deployment (CD) for cloud-native applications. It focuses on a developer-centric experience when operating infrastructure with the use of tools with which developers are already familiar, including Git and continuous deployment tools.

The "Ops" in GitOps does not mean that developers become responsible for operations. It means that operational procedures are encoded in software and become part of the codebase. For some reason or another, today's GitOps are most often associated with Kubernetes, but in principle, it can be used in conjunction with any other environment.

Why Argo CD?

Argo CD is designed to solve the complexities around Kubernetes deployment. It follows the GitOps pattern of using Git repositories as the source of truth for defining the desired application state. Kubernetes manifests can be specified in several ways, such as Kustomize applications, Helm charts, Jsonnet files, plain YAML and JSON manifest directories, and any custom management tool configured as a config management plugin. As a GitOps tool, Argo CD brings several benefits to the table. It allows for easy tracking of all changes, automatic application deployments, and quick rollbacks if necessary. It also ensures consistency and stability of applications by maintaining the desired state of the system as defined in Git.

The Argo CD implementation of GitOps is straightforward yet powerful. It continuously monitors the Git repository to ensure that the state of the deployed applications matches the state defined in the repository. If a discrepancy is detected, Argo CD takes action to align the actual state with the desired state, which could mean deploying a new version of an application, scaling the number of pods, or even changing a configuration setting.

In essence, Argo CD takes the manual effort out of deployment and operations, allowing teams to focus on what matters most: building great applications. By treating infrastructure as code and using Git as a single source of truth, Argo CD brings predictability, transparency, and efficiency to application delivery.

Before I go further, you might start to wonder: If Argo CD is such a fantastic tool, why isn't everyone using it? Well, for starters, many organization do. However, you have to take into consideration certain things before you make the decision to use the tool.

First, Argo CD is designed to work with Kubernetes (sometimes called K8s). If you are not using K8s, it makes little sense to consider Argo CD, at least at present. Second, you need to invest considerable time in learning the new environment and the GitOps paradigm – you won't become proficient overnight, because of the sheer complexity of the project. Also, Argo CD is not a Swiss army knife; it takes care of the delivery aspect, and it does it well, but it won't manage application dependencies for you, for example. That said, if you are already using Kubernetes and are looking for a more efficient way to control the deployments of your applications – or are just curious about what GitOps is – read on.

Installation

For the sake of brevity, I assume you have your K8s cluster already set up and running, and the kubectl tool is available. Installing Kubernetes is outside the scope of this article, but you can find resources on the subject in a previous issue of this magazine [1].

Before installing Argo CD, you need to create a namespace where Argo CD services and application resources will live:

kubectl create namespace argocd

Next, you install Argo CD in the argocd namespace you created by applying the Argo CD installation manifests:

kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

If you are installing Argo CD into a different namespace, make sure to update the namespace reference in the ClusterRoleBinding resources included in the installation manifests.

By default, the Argo CD API server is not exposed with an external IP. To access the API server, you can use one of the usual techniques. The first is to change the argocd-server service type to LoadBalancer:

kubectl patch svc argocd-server -n argocd-p '{"spec": {"type": "LoadBalancer"}}'

If you're just experimenting, use the kubectl port-forwarding feature:

kubectl port-forward svc/argocd-server -n argocd 8080:443

The API server can then be accessed from https://localhost:8080 .

ArgoCD CLI

Once Argo CD is installed, you'll need to set up the Argo CD command-line interface (CLI) and log in to Argo CD. The latest version of the Argo CD CLI is on the Argo CD GitHub releases page [2]. If your operating system is macOS, Linux, or Windows Subsystem for Linux (WSL), you can also install the CLI with Homebrew:

brew install argocd

The initial password for the admin account is auto-generated and stored as clear text in the password field of a secret named argocd-initial-admin-secret in your Argo CD installation namespace. You can retrieve this password from the Argo CD CLI:

argocd admin initial-password -n argocd

With the username admin and the password from the previous command, log in to the Argo CD IP or hostname:

argocd login <ARGOCD_SERVER>

If the Argo CD API server isn't directly accessible, you can access it from the CLI with port forwarding by setting the ARGOCD_OPTS environment variable,

export ARGOCD_OPTS='--port-forward-namespace argocd'
argocd account update-password

or by adding the --port-forward-namespace argocd flag to every CLI command.

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=