Argo CD-1: Understanding, Installing, and Using Argo CD as a GitOps Continuous Delivery Tool

In this article series, we will learn detailed information about Argo CD, and we will install Argo CD on the Google Cloud GKE Kubernetes cluster with different methods. We will connect and use Argo CD via CLI and UI. We will change the admin password by using ArgoCD UI and CLI. Finally, we will see how a Microservice application can be deployed to the Kubernetes cluster with various versions via Argo CD. We will do all of these step-by-step and practically.

Cumhur Akkaya
12 min readJan 1, 2024

Topics we will cover:

1. What is The Argo CD
2. Installing The Argo CD
2. 1. Connecting GKE Kubernetes Cluster
2. 2. Installing Argo CD into Kubernetes Cluster
2. 2. 1. By Using kubectl Command-Line Tool
2. 2. 2. By Using Helm
3. Accessing The Argo CD API Server
4. Logining to The Argo CD
4. 1. Installing Argo CD CLI
4. 2. Getting Argo CD Admin Password
4. 3. Logging to Argo CD By Using UI
4. 4. Logging to Argo CD By Using The CLI
5. Changing the Admin Password Via Argo CD UI and CLI
6. As a result
7. Next post: “Argo CD-2: Deploying a Microservice App into Google GKE Cluster Using Argo CD
8. References

If you like the article, I will be happy if you click the Medium Follow button to encourage me to write more, and not miss future articles.

Your clapping 👏, following, or subscribing helps my articles to reach a broader audience. Thank you in advance for them.

When we complete the steps mentioned in this article, we will reach the results shown in the gif below.

1. What is Argo CD

Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes.

With Argo CD, applications are automatically and continuously distributed to the target environments. It provides ease of deployment and management to multiple Kubernetes Clusters. User definitions and authorization procedures can be performed. SSO integration is possible. Rollback can be made to any commit in the Git repo. Kubernetes objects can be synchronized manually or automatically to the desired state specified in the Git repo. Also included is the Argo CD CLI for Continuous Integration automation.

We can easily do these with argo CD;

  • Application definitions, configurations, and environments; It is done in a declarative and version-controlled manner.
  • Application deployment and lifecycle management; It is automated, auditable, and easily understandable.

Argo CD is composed of three main components as seen in the picture below; (1)

  • API Server: Exposes the API for the WebUI / CLI / CICD Systems
  • Repository Server: Internal service that maintains a local cache of the git repository holding the application manifests
  • Application Controller: Kubernetes controller which controls and monitors applications continuously and compares that current live state with the desired target state (specified in the repository). If a OutOfSync is detected, it will take corrective actions.

Features (2)

  • Automated deployment of applications to specified target environments
  • Support for multiple config management/templating tools (Kustomize, Helm, Jsonnet, plain-YAML)
  • Ability to manage and deploy to multiple clusters
  • SSO Integration (OIDC, OAuth2, LDAP, SAML 2.0, GitHub, GitLab, Microsoft, LinkedIn)
  • Multi-tenancy and RBAC policies for authorization
  • Rollback/Roll-anywhere to any application configuration committed in the Git repository
  • Health status analysis of application resources
  • Automated configuration drift detection and visualization
  • Automated or manual syncing of applications to its desired state
  • Web UI which provides a real-time view of application activity
  • CLI for automation and CI integration
  • Webhook integration (GitHub, BitBucket, GitLab)
  • Access tokens for automation
  • PreSync, Sync, PostSync hooks to support complex application rollouts (e.g.blue/green & canary upgrades)
  • Audit trails for application events and API calls
  • Prometheus metrics
  • Parameter overrides for overriding helm parameters in Git

I also added a question from one of the readers of the article here:

Question: Why add some containers(the argoCD containers) that will take some CPU, RAM, and effort to configure and deploy when you have a git strategy that deploys changes on merges or pull requests or whatever strategy you decided on? Why add ArgoCD when you can do this with a pipeline?

Reply: The decision to use ArgoCD or a CI/CD pipeline (as Jenkins) depends on various factors and the specific requirements of your project.
If you are working in Kubernetes environments and using YAML files for your application deployment, ArgoCD can manage this process more effectively and simplify the deployment process for Kubernetes clusters. While CI/CD pipeline tools like Jenkins offer a broader range of automation (to build and test your code etc.), ArgoCD’s focus is specifically on application deployment processes on Kubernetes.
The choice between ArgoCD and a CI/CD pipeline depends on your project’s specific requirements, team preferences, and the infrastructure you are working with.
Some projects might benefit from a combination of both approaches, using ArgoCD for Kubernetes deployments and a CI/CD pipeline for other aspects of the development and release process. I will explain such an approach practically in the second article of this article series, perhaps the best answer to your question will be in this article.

2. Installing The Argo CD

Requirements:

You need a Kubernetes cluster. If you don’t have a Kubernetes cluster, you can install it using any of the links below;

To create a Kubernetes cluster by using Rancher;

To create a Kubernetes cluster by using “eksctl” command in AWS EKS;

For AWS EKS; https://docs.aws.amazon.com/eks/latest/userguide/create-cluster.html

For GCP GKE; https://cloud.google.com/kubernetes-engine/docs/deploy-app-cluster

For Azure AKS; https://learn.microsoft.com/en-us/azure/aks/tutorial-kubernetes-deploy-cluster

Installing Kubernetes with deployment tools; https://kubernetes.io/docs/setup/production-environment/tools/

2. 1. Connecting GKE Kubernetes cluster

I have a Google Cloud GKE cluster. First, I connected to my Google GKE Kubernetes cluster using the following command.

My Worker Nodes are ready and I can connect them as seen in the picture below;

2. 2. Installing Argo CD into Kubernetes cluster

2. 2. 1. By Using kubectl command-line tool

We will install the Argo CD application on the Namespace we will create below. A new namespace, argocd, where Argo CD services and application resources will live.

Requirements: kubectl command-line tool must be installed.

kubectl create namespace argocd

We install Argo CD with the following command. This command installs the latest stable version of Argo CD.

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

2. 2. 2. By Using Helm

The Argo CD can be installed using Helm. The Helm chart is currently community maintained and available at argo-helm/charts/argo-cd.

You can install Argo CD with the following commands;

helm repo add argo https://argoproj.github.io/argo-helm
helm repo update
helm uninstall my-argocd-release argo/argo-cd

We can see our running pods and services for the Argo CD with the following command as shown in the figure below;

kubectl get po,svc

If we want a slightly more customized installation of Helm, we can use the following commands;

helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
kubectl create ns argocd

Do not forget to change the parts below such as Hostname and ServerAdminPassword according to your needs. (3) (4)

helm upgrade --install argocd \
--set config.secret.argocdServerAdminPassword=P12345. \
--set server.ingress.enabled=true \
--set server.ingress.ingressClassName=nginx \
--set server.service.type=ClusterIP \
--set server.ingress.pathType=Prefix \
--set server.ingress.hostname=argocd-gcp.akkaya.link \
bitnami/argo-cd --namespace argocd

We can see our running pods and services on the argocd namespace for the Argo CD with the following command as shown in the figure below;

3. Accessing The Argo CD API Server

By default, the Argo CD API server is not exposed with an external IP. To access the API server, choose one of the following techniques to expose the Argo CD API server.

I recommend installing the Load Balancer service type because it is easier and more convenient. This will create a Load Balancer for your Argo Cd server.

Service Type Load Balancer

Change the argocd-server service type to LoadBalancer:

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

Get the load balancer URL by using the following command in order to connect Argo CD server.

kubectl get svc -n argocd

Ingress

Argo CD serves multiple protocols (gRPC/HTTPS) on the same port (443), this provides a challenge when attempting to define a single nginx ingress object and rule for the “argocd-service”.

The below rule terminates TLS at the Argo CD API server, which detects the protocol being used, and responds appropriately. (5)

For SSL-Passthrough yaml file;

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: argocd-server-ingress
namespace: argocd
annotations:
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
nginx.ingress.kubernetes.io/ssl-passthrough: "true"
spec:
ingressClassName: nginx
rules:
- host: argocd.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: argocd-server
port:
name: https

For HTTP/HTTPS Ingress yaml file;

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: argocd-server-http-ingress
namespace: argocd
annotations:
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
nginx.ingress.kubernetes.io/backend-protocol: "HTTP"
spec:
ingressClassName: nginx
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: argocd-server
port:
name: http
host: argocd.example.com
tls:
- hosts:
- argocd.example.com
secretName: argocd-ingress-http

Port Forwarding

Kubectl port-forwarding can also be used to connect to the API server without exposing the service. The below command will forward port 8080 and map it with the argocd-server service’s 443 port.

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

You can check the UI of Argo CD by visiting https://localhost:8080 or ip-of-server:8080

4. Logining to The Argo CD

4. 1. Installing Argo CD CLI

To interact with the API Server we need to deploy the Argo CD CLI. In new versions, Argo CD CLI is automatically installed. Argo CD CLI is automatically installed in the v.2.9.3 version we are currently using. You can check this in the following command as shown in the image below;

If you are using an old version, you can install Argo CD CLI with the command below;

curl -sSL -o argocd-linux-amd64 https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
sudo install -m 555 argocd-linux-amd64 /usr/local/bin/argocd
rm argocd-linux-amd64

4. 2. Getting Argo CD Admin Password

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

argocd admin initial-password -n argocd

Methot 2: You can also learn your password using the kubectl commands below;

cumhur-gcp-key@development-server:~$ export ARGO_PWD=`kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d`
cumhur-gcp-key@development-server:~$ echo $ARGO_PWD
akX9BeszCLtr57QG

4. 3. Logging to Argo CD By Using UI

We enter the username “admin” and the password we obtained above, as shown in the image below;

We will see the Argo CD start page as shown in the image below;

4. 4. Logging to Argo CD By Using The CLI

To log in to Argo CD from CLI, the following commands are used;

argocd login <hostname> --username admin
OR
argocd login <hostname> --username admin --insecure

argocd login argocd-gcp.akkaya.link --username admin
argocd login 34.67.172.177 --username admin

You should get this as output:

By using a domain name;

By using an IP address;

5. Changing the admin password from Argo CD UI

We can change the Argo CD admin password by following the steps below; First, click on the “Update password” button.

Enter the admin password we learned in “Steps 4–2" to “Current password” section and then enter the values you want to change. Then, click on the “Save new password” button.

And now our password has changed to the value we want.

The following commands are used to change the admin password of the Argo CD using the command line interface (CLI);

argocd account update-password

5. As a result

In this article, we learned detailed information about Argo CD.
Then, we installed Argo CD to the Kubernetes cluster by using kubectl and Helm. Then, we logged in to the Argo CD by using Argo CD UI and CLI. Finally, we changed the admin password by using Argo CD UI and CLI.

To learn more about Argo CD go to the complete documentation.

Check the live demo at https://cd.apps.argoproj.io/.

Argo CD links: https://github.com/argoproj/argo-cd?tab=readme-ov-file

If you liked the article, I would be happy if you clicked on the clap 👏 button and the Medium Following button to encourage me to write and not miss future articles.

Your clapping, following, or subscribing, they help my articles to reach a broader audience. Thank you in advance for them.

For more info and questions, don’t hesitate to get in touch with me on Linkedin or Medium.

6. Next post

In the next post, “Argo CD-2: Deploying a Microservice App into Google GKE Cluster Using Argo CD”. See sample images below taken from this article.

First, We will connect to the GitHub Repository by using the Argo CD UI console. We will create a “New app” in the Argo CD and deploy a microservice app into the Google GKE cluster using Argo CD “New app”. Then, we will change the source code of the microservice app and push this new version to the GitHub repository. Argo CD will automatically start the deployment when you change anything in your repository or the files. We will see and examine the automatic deployment into the Kubernetes cluster in the Argo CD menus and Google Cloud GKE console. We will do them practically and step by step.

To learn more about Argo CD; I recommend you my articleArgo CD and GitHub Action-1 and 2: Running Together Them To Create The CI/CD Pipelineas well.

If you liked the article, I would be happy if you clicked on the clap 👏 button and the Medium Following button to encourage me to write and not miss future articles.

.

Happy Clouding…

Don’t forget to follow my LinkedIn or Medium account to be informed about new articles.

--

--

Cumhur Akkaya

✦ DevOps/Cloud Engineer, ✦ Believes in learning by doing, ✦ Dedication To Lifelong Learning, ✦ Tea and Coffee Drinker. ✦ Linkedin: linkedin.com/in/cumhurakkaya