Skip to main content
Contact our team to know more about our services
select webform
By submitting, you acknowledge that you've read and agree to our privacy policies, and Opcito may use the information provided for business purposes.
Become a part of our team
select webform
One file only.
1.5 GB limit.
Allowed types: gif, jpg, jpeg, png, bmp, eps, tif, pict, psd, txt, rtf, html, odf, pdf, doc, docx, ppt, pptx, xls, xlsx, xml, avi, mov, mp3, mp4, ogg, wav, bz2, dmg, gz, jar, rar, sit, svg, tar, zip.
By submitting, you acknowledge that you've read and agree to our privacy policies, and Opcito may use the information provided for business purposes.
Kubernetes GitOps simplified with Argo CD
16 Feb 2023

Kubernetes GitOps simplified with Argo CD

GitOps adoption is on the rise thanks to the way it improves the development and delivery of software applications. It modernizes software operations by letting dev teams manage code and infrastructure declaratively using a Git repository as the single source of truth. A key orchestration system like Kubernetes is an integral part of the overall setup and it helps GitOps work efficiently and to implement infrastructure-as-code (IaC). Also, managing applications on Kubernetes can be tiresome for many and may demand advanced skills. Deploying applications using the Kubernetes and Continuous Integration Continuous Deployment process (CI/CD) helps overcome this complexity by providing abstraction. The wider adoption of Kubernetes has influenced multiple GItOps implementation tools. One such project is Argo CD.

What is Argo CD?

Argo CD is a declarative and continuous delivery open-source GitOps tool for Kubernetes applications. Argo is a Cloud Native Computing Foundation (CNCF) hosted project. It works based on the GitOps model, where Git repositories are the single source of truth for the state of the Kubernetes infrastructure. It continuously monitors running applications, clusters, and declaratively defined infrastructure and verifies that the live and desired states match, as defined in Git. It resolves any differences between the two — effectively automating application deployment.

Why Argo CD?

Regarding a well-considered GitOps approach, Argo CD and Kubernetes work nicely together.

  • Easy GitOps style software delivery: Argo CD will automatically synchronize the application configuration to the current state as declared in Git. All the changes that happen in Git are tracked.

  • Automated Kubernetes deployment: Argo CD offers deployment into many clusters housed in an on-premises data center or a public cloud (AWS/GCP/Azure). 
  • Efficient deployment strategies: Roll back applications to any previous version quickly in Git. Integrating Argo CD with Spinnaker or Argo Rollouts enables you to implement efficient deployment strategies like Blue-Green and Canary.
  • Detect deployment issues: Potential to detect deployment issues and remediate configuration drift in the apps.
  • RBAC and multitenancy: You can manage authorization to specific clusters and services with role-based access control (RBAC). It is handy for DevOps teams that work on large clusters to apply read/write restrictions.
  • CLI: Configure and receive real-time updates on application deployments with a command-line interface (CLI) and web user interface.
  • Multi-support: Argo CD supports configuration management and templating tools like Helm charts, Kustomize, YAML, and Jsonnet. It also supports webhooks integration with BitBucket, GitHub, and GitLab.

Prerequisites of Argo CD

  • Install and set up kubectl command-line tool; to install, refer
  • kubeconfig file
  • Git repo
  • Install Argo CD; to install, refer
  • Setup the clusters on GKE or EKS (wherever you want)

Supported manifest formats

It supports different formats on your GitOps repository. Based on documentation, it can handle:

  • Kustomize applications
  • Helm charts
  • Ksonnet applications
  • A directory of YAML/JSON manifests, including Jsonnet
  • Any custom config management tool configured as a config management plugin

For this tutorial, the only prerequisite is access to a Kubernetes cluster. You can also use Minikube or Kind to get a one-node cluster.

1. First, create the namespace

$ kubectl create namespace argocd

2. Apply the manifest file to the namespace created

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

Manifest files Kubernetes namespace

3. Make sure all your pods are running properly inside the namespace

$ kubectl get pods -n argocd

Kubernetes pods

4. Expose the Argo CD server UI through port forwarding

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

You can use any random port to forward.

Once that’s done, the Argo CD UI can be seen on: https://localhost:8080/

Argo CD UI

5. A username and password will be needed to log in. The username is 'admin' by default. Generate the password using the following command:

$ kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo

The output will look something like this:

Argo CD password

Use it as your password. Login to Argo CD once you have the username (admin) and the password (vfPsBPevMPvOZUfL).

6. Deploying Application via Helm to Argo CD

https://github.com/argoproj/argocd-example-apps is a successful Argo CD example repo and you can use it to deploy a guestbook application via Helm.

7. Creating an application on Argo CD

$ argocd app create helm-guestbook --repo https://github.com/argoproj/argocd-example-apps.git --path helm-guestbook --dest-server https://kubernetes.default.svc --dest-namespace argocd

You will see the application getting created.

"application 'helm-guestbook' created"

8. You can check the status of the application created using the following command:

$ argocd app get helm-guestbook

This is what the UI dashboard will look like:

Argo CD helm Guestbook

As you can see both, service and deployment are in ‘OutOfSync’ status. So, sync the application.

Argo CD status

Sync Argo CD

Now the status reads - ‘Healthy’ and ‘Synced.’

9. At this point, ensure you can access the new deployment in a browser.

By setting up port-forward, you can easily access your deployed application.

To avoid conflict with anything that might be operating on your port 80 or on the port 8080 that you're using for Argo CD, forward the helm-guestbook app to port 9090:

$ kubectl port-forward svc/helm-guestbook 9090:80

You'll probably need to do this in another terminal because it will block that terminal until you press Ctrl+C to stop forwarding the port. You can then open localhost:9090 in a browser window to see your example guestbook app.

Guestbook

All future pushes to this GitHub repository will automatically reflect in Argo CD. Your Argo CD deployments will be updated accordingly, providing continuous availability.

This is it; your Argo CD has installed and deployed the application on Kubernetes. As Kubernetes needs multiple layers of abstraction, it is essential to ensure that deployments are as maintainable as possible and every change is tracked. This is exactly why Argo CD fits perfectly with the GitOps philosophy. Try this and let us know your experience.

Subscribe to our feed

select webform