Deploying Your First Application on Argo CD

Deploying Your First Application on Argo CD

ยท

4 min read

Introduction:

Argo CD is a powerful tool that simplifies the deployment and management of applications in Kubernetes clusters. It provides a declarative approach to application deployment and offers a user-friendly interface to monitor and control your deployments. In this blog post, we will walk you through the process of deploying your first application using Argo CD.

Prerequisites:

  • Kubernetes Cluster

  • Docker

  • Git Repository

Step 1 Set Up Argo CD:

Before we can start deploying applications with Argo CD, we need to set it up in our Kubernetes cluster. You can install Argo CD using Helm or by manually applying the YAML manifests. Refer to the official Argo CD documentation for detailed installation instructions.

Step 2:

Create a Git Repository for Your Application Argo CD uses Git repositories to store the declarative configuration files for your applications. Create a new Git repository or use an existing one to store the configuration for your application. Make sure you have the necessary permissions to push and pull from the repository.

I pushed three files in this application.yaml, deployment.yaml, service.yaml. The two files are basic and I told in previous that is First on k8s. Feel free to check that out.We will discus more about application.yaml further.

  1. deployment.yaml

     apiVersion: apps/v1
     kind: Deployment
     metadata:
       name: first-deployment
       labels:
         app: first
     spec:
       replicas: 3
       selector:
         matchLabels:
           app: first
       template:
         metadata:
           labels:
             app: first
         spec:
           containers:
           - name: first
             image: docker.io/vikash98yadav/githubtwin:latest
             imagePullPolicy: "Always"
             ports:
             - containerPort: 8000
    
  2. service.yaml

     apiVersion: v1
     kind: Service
     metadata:
       name: first-service
     spec:
       type: NodePort
       selector:
         app: first
       ports:
           # By default and for convenience, the `targetPort` is set to the same value as the `port` field.
         - port: 80
           targetPort: 8000
           # Optional field
           # By default and for convenience, the Kubernetes control plane will allocate a port from a range (default: 30000-32767)
           nodePort: 30007
    

Step 3 Define the Application Configuration:

In your Git repository, create a new YAML file to define the configuration for your application. This configuration file specifies details such as the deployment target, the source of the application manifests, and any desired customization. The Argo CD documentation provides comprehensive information about the available configuration options.With the help of this file the argocd will contact to Git repo.Below is the code I used for the application.yaml.

Step 4: Review and Sync Your Application Argo CD

it will automatically detect the changes in your Git repository and initiate a synchronization process. This process compares the desired state of your application defined in the configuration file with the current state in your Kubernetes cluster. If there are any differences, Argo CD will reconcile the state by applying the necessary changes.

Step 5: Monitor and Manage Your Application

Once your application is successfully deployed, you can monitor its status and manage it using the Argo CD interface. Argo CD provides a comprehensive overview of your applications, including their health status, revision history, and synchronization details. You can also perform actions like rolling back to a previous revision or scaling your application.

  1. Changes are done from the terminal

    1. I changes the replicas from 3 to 2 and it reverted back me again to the same replicas and undone my changes this shows that Git is the only source of truth. As shown below the changes are out OF Sync and argocd is updating the changes.

      After this, it created the two node replicas but it triggered that the changes are not from Git so it reverted back.

๐ŸŽ‰ Congratulations! ๐Ÿš€

You've successfully embarked on an empowering journey by deploying your first application with Argo CD. ๐Ÿ’ช By harnessing the power of Argo CD's declarative approach and user-friendly interface, you've streamlined your application deployment process and gained greater control over your Kubernetes clusters. ๐ŸŽฏ

With this step-by-step guide, you now have a rock-solid foundation to explore the limitless capabilities of Argo CD and confidently deploy even more complex applications in the future. ๐ŸŒŸ So, buckle up and get ready for a thrilling adventure in the world of continuous deployment with Argo CD! โœจ

Remember, happy deploying and may your applications always sail smoothly on the waves of success! ๐ŸŒŠ๐Ÿšข

Don't forget to check out the GitHub repo - https://github.com/Vikash-8090-Yadav/K8S-Argocd_Project

ย