What Is Argo CD?
Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes. It manages deployment and synchronization of application definitions from Git repositories to Kubernetes clusters, ensuring the desired state is maintained. By comparing Git state with live cluster resources, Argo CD detects drift and automatically or manually reconciles, enabling consistent deployments. The use of Git as the central source of truth ensures versioning, review, and rollback capabilities, which enhance deployment reliability and traceability.
Argo CD offers an intuitive UI and CLI, which streamline management and visualization of application states. Integration with external tools like Helm, Kustomize, and Jenkins provides flexibility in managing complex Kubernetes environments. With its automated workflows and synchronization capabilities, Argo CD can handle dynamic cluster changes, allowing organizations to adopt a GitOps approach.
What Is Jenkins?
Jenkins is a widely used open-source automation server that facilitates continuous integration and delivery (CI/CD). Central to its functionality is the ability to automate parts of software development related to building, testing, and deploying applications. Jenkins supports thousands of plugins, enabling its integration into nearly any software environment. It has become a staple in the industry due to its extensibility, flexibility, and thriving ecosystem.
Despite its popularity, Jenkins has certain limitations in handling modern cloud-native environments as effectively as newer tools like Argo CD. It requires additional scripting for Kubernetes application management, and its monolithic architecture can present challenges with scalability and performance in large-scale deployments. However, Jenkins can be combined with Argo CD to provide more value in Kubernetes environments.
Argo CD vs. Jenkins: The Key Differences
1. Focus Area
Argo CD is specifically for Kubernetes environments, providing automated synchronization and management directly linked to Git repositories. This focus allows it to excel in environments where cloud-native practices are a priority. Jenkins is more general-purpose, capable of being adapted through extensive plugin support to fit various workflows. While Jenkins can be customized to work with Kubernetes, it doesn’t offer the out-of-the-box synchronization features that Argo CD does.
While Argo CD ensures operations in Kubernetes-centric environments with its declarative approach and GitOps principles. Jenkins provides versatility across diverse CI/CD tasks, suiting organizations that operate in mixed or non-cloud-native environments.
2. Architecture and Integration
Argo CD’s architecture is inherently built around Kubernetes, leveraging namespaces, custom resources, and controllers for integration with K8s clusters. This allows it to manage configurations and deployments effectively within the Kubernetes ecosystem. Jenkins uses a master-agent architecture, with the flexibility to distribute workload across multiple nodes. However, integrating Jenkins with Kubernetes requires additional configurations for appropriate management and scaling.
The direct Kubernetes integration in Argo CD simplifies deployments and enhances resource management. In contrast, Jenkins needs plugins and potentially complex setups for similar tasks. Argo CD fits naturally in cloud environments, offering easier management through Git-based workflows, while Jenkins provides a more traditional approach suited for a variety of software environments.
3. Deployment Strategies
In Argo CD, deployments are handled through GitOps principles, emphasizing Git as the source of truth. This methodology allows for automatic synchronization and rollbacks, simplifying the deployment process. Jenkins uses traditional build and deploy methods where pipelines need to be scripted and maintained manually. While Jenkins offers flexibility in deployment strategies through scripting, it lacks the native GitOps capabilities Argo CD provides.
The deployment process in Argo CD is more streamlined, focusing on ensuring clusters match the desired Git state. Jenkins requires a more manual approach, with each deployment potentially needing unique scripting. Argo CD’s approach is beneficial in environments where consistency, reliability, and quick recovery are paramount.
4. Configuration and Management
Argo CD’s configuration management revolves around its GitOps core, making it easy to track changes, manage access, and revert configurations as needed. This Git-centric approach enables a clear trail of changes and makes configuration management more transparent. Jenkins uses a mix of Groovy scripts and configuration files, which may become complex to manage over time, especially in large-scale environments with multiple plugins and custom scripts.
Argo CD’s management aligns efficiently with cloud-native practices, facilitating easier collaboration through version control systems. Jenkins requires careful management of scripts and plugin configurations to avoid conflicts and maintain stability. While Jenkins provides a more flexible scripting option, it can lead to intricate setups and potential management difficulties.
5. Community and Support
Argo CD benefits from an active open-source community and strong support from the Cloud Native Computing Foundation (CNCF). Continuous contributions keep it at the forefront of GitOps and Kubernetes innovations. Its community-driven model ensures regular updates and integration features that align with the latest cloud-native practices. Jenkins also has a substantial community, being one of the oldest and most mature CI/CD tools available. This maturity provides it with a wealth of plugins and extensive documentation.
While both tools have robust communities, Argo CD’s focus on modern cloud-native practices ensures it remains relevant in fast-evolving environments. Jenkins offers stability and comprehensive resources, appealing to those who value longevity and extensive documentation.
Learn more in our detailed guide to Argo support
TIPS FROM THE EXPERT
In my experience, here are tips that can help you better understand and leverage Argo CD and Jenkins together:
- Use Jenkins for complex build orchestration and Argo CD for deployment: Use Jenkins where it excels—complex build workflows, testing, and orchestrating multi-step CI processes. Once the build is complete, hand over deployment responsibilities to Argo CD. This separation of concerns reduces complexity and leverages each tool’s strengths effectively.
- Leverage Argo CD’s ApplicationSets for multi-cluster deployments: ApplicationSets in Argo CD can be used to manage applications across multiple clusters using a single configuration file. This approach is highly efficient for managing large-scale deployments across multiple environments, something that Jenkins would struggle with due to its more centralized architecture.
- Use Argo CD’s sync waves for controlled, phased deployments: Sync waves in Argo CD allow you to define the order in which resources are applied during a deployment, enabling phased rollouts that reduce risk and improve reliability. This feature can be used to apply specific resources like CRDs before deploying the main application components.
- Use Argo CD’s resource health checks to enhance deployment confidence: Define custom health checks for your resources in Argo CD to get more granular feedback on the status of your deployments. This feature helps ensure that specific resources are functioning as expected before considering a deployment successful.
- Integrate Argo CD with policy engines like Open Policy Agent (OPA): Enforce policies and governance directly within your deployment workflows by integrating OPA with Argo CD. This integration helps maintain compliance, enforce security standards, and ensure that only approved configurations are applied.
Using Jenkins and Argo CD Together
Jenkins and Argo CD can be integrated to combine the strengths of both tools: Jenkins excels at building and testing code, while Argo CD specializes in deploying and managing Kubernetes applications through GitOps. By integrating these tools, teams can streamline their CI/CD pipeline, ensuring smooth transitions from code commits to deployments in Kubernetes clusters.
Here’s an example of how to set up a Jenkins pipeline that triggers Argo CD to deploy updated Kubernetes resources.
1. Install the Argo CD CLI in a Jenkins Worker
The first step is ensuring the Jenkins worker has the argocd
CLI installed. This CLI allows Jenkins to interact with the Argo CD API for triggering deployments.
curl -LO https://github.com/argoproj/argo-cd/releases/download/v.2.8,15/argocd-linux-amd64 sudo mv argocd-linux-amd64 /usr/local/bin/argocd sudo chmod 755 /usr/local/bin/argocd
Verify the installation using:
argocd version
2. Create a Jenkins Role in Argo CD
In Argo CD, create a role for Jenkins with the necessary permissions to deploy applications. This role can be created via the UI or the CLI:
argocd proj role create default deployment-role
Now we can create the token using the following command
argocd proj role create-token default deployment-role
This token is saved and added to Jenkins as a credential for use in pipelines.
Note: If you get an error like: FATA[0000] Argo CD server address unspecified
, use the following command to add the cluster,
argocd cluster add <cluster-name> --server <ClusterIP>
3. Configure Jenkins Pipeline
Below is a Jenkins pipeline script (Jenkinsfile
) that builds a Docker image, pushes it to a container registry (e.g., AWS ECR), and triggers Argo CD to deploy the application using the updated image.
Note: Editing the image via the CLI is done for simplicity in this tutorial. In a real setup, the Jenkins pipeline should modify images via a Git repo only.
pipeline { agent any environment { IMAGE_NAME = 'financial-insights' IMAGE_TAG = 'latest' KUBE_CONFIG = ‘/var/lib/jenkins/.kube/config' } stages { stage('Checkout Code') { steps { script { echo 'Checking out code from Git repository...' } checkout([$class: 'GitSCM', branches: [[name: 'main']], userRemoteConfigs: [[url: 'https://XXXXXX@github.com/XXXXX/Financial-Insights.git']] ]) } } stage('Build Docker Image Locally') { steps { script { echo 'Building Docker image locally...' } sh ''' set -e # Build the Docker image locally docker build -t ${IMAGE_NAME}:${IMAGE_TAG} . ''' } } stage('Deploy to Kubernetes') { steps { script { echo 'Deploying to Kubernetes cluster...' } withCredentials([string(credentialsId: 'kube-push-token', variable: 'AUTH_TOKEN_FOR_ARGCD')]) { sh ''' # Set the image for the application in Argo CD using Kustomize argocd app set financial-insights --kustomize-image $(IMAGE_NAME):latest # Sync the application with Kubernetes argocd app sync financial-insights # Wait for the deployment to finish argocd app wait financial-insights --timeout 600 ''' } } } post { success { echo 'Pipeline completed successfully.' } failure { echo 'Pipeline failed. Please check the logs for details.' } } }
The above pipeline has the following key elements:
- Code Checkout: Code is checked out from the repository.
- Docker build and push: Jenkins builds the application’s Docker image and pushes it to the local kubernetes cluster
- Argo CD deployment: The Jenkins pipeline uses the
argocd app set
command to update the image in the Kubernetes manifests managed by Argo CD. This is not recommended for a production setup. For this example we have set this tofinancial-insights:latest
. After updating the image, it triggers the application sync usingargocd app sync
, ensuring the Kubernetes cluster deploys the new version of the application. - Waiting for completion: The
argocd app wait
command ensures that Jenkins waits for the deployment to complete before continuing, providing feedback on the success or failure of the deployment.
4. Monitoring and Rollbacks
Argo CD’s integration with Jenkins also enables monitoring of the deployment process. Argo CD’s dashboard provides a visual representation of Kubernetes resources, showing real-time updates on the deployment status. If any issues arise, rollbacks can easily be performed using Argo CD’s UI, making it simpler to revert to previous application states.
Here is how to perform a rollback:
# List all revisions of the application to find the desired version argocd app history financial-insights # Roll back to a specific revision (replace <REVISION_ID> with the desired revision number) argocd app rollback financial-insights <REVISION_ID> # Wait for the rollback to complete and ensure the application is in a healthy state argocd app wait financial-insights --timeout 600
Note: Rolling back an app using CLI commands is done here for simplicity. It is not recommended in production environments and should only be done using git revert, reset, or commit commands.
After initiating the rollback, the argocd app wait ensures the process completes successfully before Jenkins proceeds, providing visibility into the deployment status.
Codefresh: A Modern Alternative to Jenkins Based on Argo CD
You can’t get to continuous delivery or deployment without first solving continuous integration. Codefresh automatically creates a Delivery Pipeline, which is a workflow along with the events that trigger it. We’ve added a pipeline creation wizard that will create all the component configurations so you can spend less time with YAML and more time getting work done.
At the end of the pipeline creation wizard, Codefresh commits the configuration to git and allows its built-in Argo CD instance to deploy them to Kubernetes.
The Delivery pipeline model also allows the creation of a single reusable pipeline that lets DevOps teams build once and use everywhere. Each step in a workflow operates in its own container and pod. This allows pipelines to take advantage of the distributed architecture of Kubernetes to easily scale both on the number of running workflows and within each workflow itself.
Teams that adopt Codefresh deploy more often, with greater confidence, and are able to resolve issues in production much more quickly. This is because we unlock the full potential of Argo to create a single cohesive software supply chain. For users of traditional CI/CD tooling, the fresh approach to software delivery is dramatically easier to adopt, more scalable, and much easier to manage with the unique hybrid model.
Learn more about Codefresh.
The World’s Most Modern CI/CD Platform
A next generation CI/CD platform designed for cloud-native applications, offering dynamic builds, progressive delivery, and much more.
Check It Out