DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Smart Deployment Strategies for Modern Applications
  • Optimizing Java Applications for Arm64 in the Cloud
  • Flux and ArgoCD: A Guide to Kubernetes Deployment Automation
  • Modernizing Mainframe Applications by Harnessing Specialty Processors and the Power of the Cloud

Trending

  • Chaos Engineering Has a Blind Spot. Agentic AI Lives in It.
  • Stateless JWT Auth Microservice Architecture With Spring Boot 3 and Redis Sentinel
  • Event-Driven Pipelines With Apache Pulsar and Go
  • Slopsquatting: Building a Scanner That Catches AI-Hallucinated Packages Before They Reach Production
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Deploying Applications in Kubernetes With Argo CD for Beginners

Deploying Applications in Kubernetes With Argo CD for Beginners

Learn how to deploy applications seamlessly in Kubernetes using Argo CD, from installation to securing and automating deployments with GitOps principles.

By 
Sai Sandeep Ogety user avatar
Sai Sandeep Ogety
DZone Core CORE ·
Nov. 19, 24 · Tutorial
Likes (27)
Comment
Save
Tweet
Share
3.5K Views

Join the DZone community and get the full member experience.

Join For Free

Deploying applications in Kubernetes can be complex, especially for newcomers. Enter Argo CD, a GitOps-powered, declarative tool designed to automate Kubernetes application deployments. In this workshop, you’ll learn how to set up and use Argo CD to deploy applications seamlessly, with a step-by-step crafted for complete beginners.

What You’ll Learn

  • Installing and configuring Argo CD.
  • Deploying applications using GitOps principles.
  • Monitoring deployments and troubleshooting.
  • Rolling back and managing application versions.
  • Securing Argo CD for production use.

Why Argo CD?

Argo CD simplifies application management in Kubernetes by continuously syncing your cluster with manifests defined in Git repositories. Benefits include:

  • Declarative Management: Define the desired cluster state in Git.
  • Continuous Delivery: Automate deployments with real-time sync.
  • Version Control: Roll back to previous versions with ease.

Prerequisites

Before diving in, ensure you have:

  1. A Kubernetes cluster (use Minikube, Kind, or a managed service like GKE, EKS, AKS).
  2. kubectl installed and configured to connect to your cluster.
  3. A GitHub or GitLab account to host your Kubernetes manifests.
  4. Basic familiarity with YAML syntax (covered in this workshop if you’re new).

Step-by-Step Guide

1. Setting Up a Kubernetes Cluster

Step 1: Install Minikube

If you don’t have a cluster, use Minikube:

Shell
 
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
chmod +x minikube-linux-amd64
sudo mv minikube-linux-amd64 /usr/local/bin/minikube


Step 2: Start Minikube

Run the command minikube start after installing Minikube on your system:

Shell
 
minikube start


Step 3: Verify Cluster

Confirm the cluster is running:

Shell
 
kubectl cluster-info
kubectl get nodes


2. Installing Argo CD

Step 1: Create Namespace

Argo CD runs in its own namespace for isolation:

Shell
 
kubectl create namespace argocd


Step 2: Install Argo CD

Apply the official manifests to install Argo CD:

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


Step 3: Verify Installation

Check the Argo CD pods:

Shell
 
kubectl get pods -n argocd


3. Accessing the Argo CD UI

Step 1: Expose Argo CD

Expose the argocd-server to your local machine:

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


Step 2: Retrieve Admin Credentials

Fetch the default admin password:

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


Step 3: Login to UI

  1. Open https://localhost:8080 in your browser.
  2. Log in with:
    • Username: admin
    • Password: Retrieved in the previous step.

4. Connecting Argo CD to Your Git Repository

Step 1: Prepare a Git Repository

  1. Create a Git repository (e.g., on GitHub).
  2. Add your Kubernetes manifests to the repository. Use this sample deployment.yaml:
YAML
 
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.19
        ports:
        - containerPort: 80


Step 2: Add Repository to Argo CD

From the UI:

  1. Navigate to Settings > Repositories.
  2. Add your Git repository URL and authentication details (SSH or HTTPS).

Or, use the CLI:

Shell
 
argocd repo add <REPO_URL> --username <USERNAME> --password <PASSWORD>


5. Deploying Your First Application

Step 1: Create an Application

In the Argo CD UI:

  1. Click New App.
  2. Fill in the following:
    • App Name: nginx-app
    • Project: default
    • Repository URL: Your Git repo URL
    • Path: Path to deployment.yaml
    • Cluster URL: https://kubernetes.default.svc
    • Namespace: default

Step 2: Sync the Application

After creating the app:

  1. Click Sync in the Argo CD UI.
  2. Watch as the app deploys to your Kubernetes cluster.

6. Automating Deployments

Step 1: Enable Auto-Sync

Enable continuous synchronization:

Shell
 
argocd app set nginx-app --sync-policy automated


Step 2: Test Changes

  1. Modify the deployment.yaml in Git.
  2. Push changes to the repository.
  3. Argo CD will detect the changes and automatically sync them to the cluster.

7. Monitoring and Troubleshooting

Step 1: Monitor Application Health

In the UI, check:

  • Health: Indicates if the application is running as expected.
  • Sync Status: Ensures the cluster state matches Git.

Step 2: View Logs

If something goes wrong:

Shell
 
kubectl logs -n argocd <POD_NAME>


Step 3: Roll Back Changes

Roll back to a previous state:

Shell
 
argocd app rollback nginx-app <REVISION>


8. Securing Argo CD

Step 1: Change Default Admin Password

Change the default admin password using the command argocd account update-password:

Shell
 
argocd account update-password


Step 2: Integrate SSO

For production environments, integrate with Single Sign-On (SSO) solutions like GitHub or LDAP.

GitOps Best Practices

  1. Branch Strategies: Use separate branches for development, staging, and production.
  2. Code Reviews: Enforce peer reviews for manifest changes.
  3. Audit Logs: Regularly review Argo CD logs for compliance and debugging.

Conclusion

Argo CD offers a beginner-friendly yet powerful way to manage Kubernetes deployments using GitOps principles. This workshop equips you with the skills to deploy, monitor, and manage applications efficiently. By adhering to these practices, you’re well on your way to mastering Kubernetes continuous delivery.

Git Kubernetes applications

Opinions expressed by DZone contributors are their own.

Related

  • Smart Deployment Strategies for Modern Applications
  • Optimizing Java Applications for Arm64 in the Cloud
  • Flux and ArgoCD: A Guide to Kubernetes Deployment Automation
  • Modernizing Mainframe Applications by Harnessing Specialty Processors and the Power of the Cloud

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook