DevOps & GitOps··2 min read

Eliminating Production Server Drift with Ansible Bare-Metal Provisioning and ArgoCD GitOps

Shafikul Islam

Shafikul Islam

Backend & Cloud Infrastructure Engineer · Infrastructure & Cloud Team Lead

Eliminating Production Server Drift with Ansible Bare-Metal Provisioning and ArgoCD GitOps

Why Manual SSH Changes Destroy Cluster Reliability

Every undocumented kubectl edit or manual SSH config tweak on a production Linux node creates a ticking time bomb. Two weeks later, when a worker node is replaced or a pod restarts, the hotfix vanishes and triggers an incident that nobody can reproduce in staging.

When I took ownership of cloud infrastructure at Cansoft Technologies, we enforced a strict rule: zero human SSH mutations in production. Every OS kernel parameter, K3s node binary, and Kubernetes workload must be reconciled from Git.


1. Layer 1: Deterministic Node Provisioning with Ansible

Before Kubernetes even starts, underlying Linux worker nodes need identical sysctl networking limits, WireGuard mesh interfaces, and containerd log rotation rules.

We codified node bootstrapping into idempotent Ansible roles:

- name: Harden Linux Kernel & Sysctl for High-Concurrency K3s Nodes
  hosts: k3s_cluster
  become: true
  tasks:
    - name: Configure sysctl network & file descriptor bounds
      ansible.posix.sysctl:
        name: "{{ item.key }}"
        value: "{{ item.value }}"
        state: present
        reload: true
      loop:
        - { key: "net.core.somaxconn", value: "32768" }
        - { key: "net.ipv4.ip_local_port_range", value: "1024 65000" }
        - { key: "fs.file-max", value: "2097152" }
        - { key: "vm.max_map_count", value: "262144" }

2. Layer 2: Pull-Based GitOps with ArgoCD and Helm

In traditional push-based CI pipelines, GitHub Actions holds cluster-admin credentials and runs helm upgrade directly. If a manual change happens inside the cluster afterward, CI has no idea the cluster drifted.

With ArgoCD running inside the cluster:

  1. CI builds the container image, runs Trivy security scans, and commits the new immutable image SHA digest to our GitOps repository.
  2. ArgoCD detects the Git commit within seconds and reconciles the live Kubernetes state to match Git.
  3. Self-Heal Enabled (selfHeal: true): If anyone manually edits a Service or Deployment in the cluster, ArgoCD immediately overwrites the manual edit back to the Git state.
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: emmai-core-api
  namespace: argocd
spec:
  project: production
  source:
    repoURL: https://github.com/org/infra-gitops.git
    targetRevision: main
    path: charts/emmai-core-api
    helm:
      valueFiles:
        - values-prod.yaml
  destination:
    server: https://kubernetes.default.svc
    namespace: emmai-prod
  syncPolicy:
    automated:
      prune: true
      selfHeal: true

3. Zero-Downtime Rolling Updates with Readiness Gates

By combining maxUnavailable: 0, maxSurge: 1, and strict HTTP /healthz/ready database-ping probes, a broken container image never receives live ingress traffic and halts the rollout automatically before affecting active users.

Infrastructure & PostgreSQL Advisory

Scaling Infrastructure or Diagnosing P95 Latency?

I help engineering teams diagnose PostgreSQL indexing bottlenecks, concurrency limits, and K3s/Docker deployments. Book a 20-minute call with me to review your setup.

Related Technical Articles