We use optional first-party traffic analytics to improve the blog. You can accept or decline — nothing is measured before you choose.

Privacy policy

Skip to content
NyverraNyverra
⌘K
HomeArticlesCorporate site
🇺🇸
Nyverra

Editorial channel

Articles on technology, operations and partners — infrastructure, monitoring and critical environments.

Social media

Explore

  • Home
  • Articles
  • Categories
  • Tags
  • Authors
  • About
  • Contact
  • RSS
  • Corporate site

Nyverra

  • Our services
  • Case studies
  • Partners

Contact

Email[email protected]WhatsApp(62) 99309-1592Client portalITSM · tickets and SLA

Rua RB 18, S/N — Casa 01, Sala 01 · Residencial Buriti · Senador Canedo – GO, Brazil · ZIP 75260-459

Hours: Mon–Fri, 8am–6pm

© 2026 Nyverra. All rights reserved.

CNPJ: 61.571.209/0001-08 · State registration: 20.291.265-5 · D-U-N-S®: 57-323-5796

blog.nyverra.com.br

Terms of usePrivacyCookies
Back to top
  1. Home
  2. Kubernetes
  3. Kubernetes Course 22 — GitOps with ArgoCD
Kubernetes
#Curso Kubernetes#K8S#Kubernetes

Kubernetes Course 22 — GitOps with ArgoCD

Wedson LopesWedson Lopes
31 de outubro de 20264 min de leitura

The question that defines GitOps: if someone deletes a Deployment at 3 a.m., does the cluster recover automatically?

If the answer is "no", you have CI with kubectl apply, not GitOps. The difference is who controls the desired state.

Course seal: tested on Kubernetes 1.35 with ArgoCD 2.x.

The model

Git (estado desejado) ──► ArgoCD (comparação) ──► Cluster (estado real)
                              ▲                        │
                              └──── drift detectado ───┘
  • Source of truth: Git repository.
  • Agent: ArgoCD runs in the cluster and compares continuously.
  • Result: Synced/OutOfSync and Healthy/Degraded.

Nobody applies with kubectl in production. If you do, ArgoCD reverts — and that is the correct behavior.

Installation

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

Access:

kubectl -n argocd port-forward svc/argocd-server 8080:443
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath='{.data.password}' | base64 -d

In production: Ingress with TLS, SSO (OIDC), and ArgoCD RBAC. Local admin is only for bootstrap.

An Application

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: portal-homolog
  namespace: argocd
spec:
  project: default
  source:
    repoURL: https://github.com/example/portal-gitops.git
    targetRevision: main
    path: apps/portal/overlays/homolog
  destination:
    server: https://kubernetes.default.svc
    namespace: portal
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
    syncOptions:
      - CreateNamespace=true
      - ApplyOutOfSyncOnly=true
    retry:
      limit: 3
      backoff:
        duration: 10s
        factor: 2
        maxDuration: 3m

Points that matter:

  • prune: true removes what left Git.
  • selfHeal: true corrects manual changes.
  • retry avoids staying Degraded due to a transient image error.

App-of-apps

One repository, many Applications:

gitops/
  bootstrap/
    root-app.yaml
  apps/
    portal/
      base/
      overlays/homolog
      overlays/prod
    observability/
    operators/

The root-app points to apps/ and ArgoCD discovers the rest. Adding a new environment = opening a PR.

Synchronization: manual or automatic

Mode When to use
Manual (syncPolicy empty) regulated production, approved window
Automated homolog, staging, internal services
Automated + selfHeal everything that needs to resist manual change
Automated + prune disposable environments and mature GitOps

prune in production requires care: a path error in the PR can remove resources. Use Prune=false annotation on critical objects and protect the repository with mandatory review.

Drift: the silent enemy

Drift happens when someone:

  • edits the Deployment in the dashboard;
  • runs kubectl set image;
  • applies a stray manifest;
  • changes an HPA that changes replicas (replicas managed by HPA should not be in Git).
argocd app diff portal-homolog
argocd app history portal-homolog

HPA + replicas in Git is an eternal fight: ArgoCD wants 2, HPA wants 6. Remove replicas from the managed manifest when there is an HPA.

Secrets in GitOps

Do not commit Secret. Options:

  • Sealed Secrets: encrypts and can go to Git.
  • External Secrets Operator: fetches from Vault/secret manager.
  • SOPS + age: encryption in the repository.

ArgoCD only needs to see the final resource; the secret origin stays outside.

Lab

  1. Install ArgoCD and access the UI.
  2. Create a GitOps repository with a simple Deployment.
  3. Create the Application and synchronize.
  4. Change the Deployment by hand (kubectl scale) and see selfHeal return to the Git value.
  5. Delete the Deployment and confirm recreation.
  6. Make a commit with replicas: 3 and follow the automatic sync.
  7. Remove the resource from Git and see prune act.
  8. Provoke an error (non-existent image) and observe Degraded + retry.

Common errors

Symptom Cause
Eternal OutOfSync field managed by another controller (HPA, webhook)
ComparisonError wrong repo/path/branch or credential
Degraded after sync image pull, quota, PVC pending
Orphan resource prune: false
Sync overwrites HPA replicas in manifest
Secret in Git lack of Sealed/External Secrets
Sync loop cluster default differs from manifest (ignoreDifferences)

ignoreDifferences is palliative: use when the field is really managed by another component, not to hide real drift.

Checklist

  • [ ] ArgoCD with SSO and RBAC (local admin only at bootstrap).
  • [ ] GitOps repository separate from application code.
  • [ ] selfHeal and prune conscious per environment.
  • [ ] replicas outside manifest where there is HPA.
  • [ ] Secrets via Sealed/External Secrets.
  • [ ] argocd app diff part of the PR process.
  • [ ] Alerts for Degraded and OutOfSync.
  • [ ] Backup of the GitOps repository.

Glossary

  • Application: CRD that links repo/path to a destination.
  • sync: apply the desired state.
  • prune: remove resources absent from Git.
  • selfHeal: automatically revert drift.
  • drift: divergence between Git and cluster.
  • app-of-apps: pattern of Applications that manage Applications.

Next

With versioned and reconciled deploy, the detail that the user feels is missing: zero downtime. Probes, rolling update, PDB, and HPA in the next chapter.

Next: Kubernetes Course 23 — Deploy without downtime: probes, rolling update, and HPA

Share

Keep reading

Read also

  • Kubernetes Course 23 — Zero-downtime deploy: probes, rolling update, and HPA
    Kubernetes

    Kubernetes Course 23 — Zero-downtime deploy: probes, rolling update, and HPA

    Readiness, liveness, startup, maxSurge, maxUnavailable, PDB and HPA: what really decides whether the user sees errors during deployment.

    31 de outubro de 20265 min de leitura
  • Kubernetes Course 21 — Helm: Packaging the Application
    Kubernetes

    Kubernetes Course 21 — Helm: Packaging the Application

    Charts, values, templating, and hooks: how to move away from kubectl apply -f and version the application deployment as a real package.

    31 de outubro de 20264 min de leitura
  • Kubernetes Course 24 — CI/CD: Immutable Images and SBOM
    Kubernetes

    Kubernetes Course 24 — CI/CD: Immutable Images and SBOM

    Pipeline that builds once, promotes by digest, signs the image and delivers SBOM: traceability from commit to pod.

    31 de outubro de 20264 min de leitura

Nyverra

Need specialist help?

  • Infrastructure services
  • Case studies
  • Partners

Comments

No comments yet

Be the first to share your thoughts on this article.

Leave a comment

Newsletter

Get new articles

Subscribe to receive Nyverra blog posts in your inbox. We will send a confirmation link.

​