Kubernetes Deployments: ArgoCD and GitHub Actions in Action

Listen to this Post

Featured Image
Using a GitOps approach for deployments on Kubernetes enables efficient management of infrastructure changes through Git repositories. ArgoCD, a popular GitOps tool, provides a user-friendly UI and integrates seamlessly with GitHub Actions for automation.

You Should Know:

1. Setting Up ArgoCD on K3s

Deploy ArgoCD on a lightweight K3s cluster:

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

Access the ArgoCD UI:

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

2. Configuring GitHub Actions for GitOps

Create a workflow (`.github/workflows/gitops.yml`) to sync changes automatically:

name: GitOps Sync 
on: 
push: 
branches: [ main ] 
jobs: 
deploy: 
runs-on: ubuntu-latest 
steps: 
- uses: actions/checkout@v3 
- name: Install kubectl 
uses: azure/setup-kubectl@v3 
- name: Sync ArgoCD App 
run: | 
kubectl patch app my-app -n argocd -p '{"spec": {"syncPolicy": {"automated": {}}}}' --type merge 

3. Defining ArgoCD Applications

Create an `application.yaml` in your Git repo:

apiVersion: argoproj.io/v1alpha1 
kind: Application 
metadata: 
name: my-app 
namespace: argocd 
spec: 
project: default 
source: 
repoURL: https://github.com/your-repo.git 
targetRevision: HEAD 
path: kubernetes-manifests 
destination: 
server: https://kubernetes.default.svc 
namespace: my-app 
syncPolicy: 
automated: 
prune: true 
selfHeal: true 

4. Rollback and Audit

Check deployment history:

argocd app history my-app 

Rollback to a previous version:

argocd app rollback my-app <REVISION_ID> 

What Undercode Say

GitOps with ArgoCD and GitHub Actions streamlines Kubernetes deployments, ensuring traceability and quick rollbacks. Automating deployments reduces human error while maintaining security.

Expected Output:

  • Automated sync between Git and Kubernetes.
  • Auditable changes via Git history.
  • Faster recovery with rollback capabilities.

Prediction

GitOps adoption will grow as more organizations seek automated, auditable, and secure deployment pipelines.

URL: Kubernetes Deployments: ArgoCD and GitHub Actions in Action

IT/Security Reporter URL:

Reported By: Darryl Ruggles – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅

Join Our Cyber World:

💬 Whatsapp | 💬 Telegram