Stage 4 · Provision
GitOps Workflows
GitOps Observability
Sync status, drift detection, and deployment metrics — visibility into GitOps operations.
Sync Status
Both ArgoCD and Flux expose sync status through Kubernetes resources and APIs. Sync status tells you whether the cluster state matches the Git state. Out-of-sync status indicates drift or a pending deployment.
$ argocd app get my-app
Name: my-app
Project: default
Server: https://kubernetes.default.svc
Namespace: my-app
Status: Synced
Health: Healthy
Repo: https://github.com/org/k8s-manifests.git
Path: apps/my-app
Target: main
Sync Policy: Automated (Prune, Self-Heal)
Operations: application sync, deferred, manual
App sync status: SyncedThe sync status shows whether the application matches the Git state. Synced means everything is in sync. OutOfSync means changes are pending or drift has been detected. Health shows the readiness of resources.
$ flux get kustomizations
NAME READY STATUS AGE
webapp True Applied revision: main/abc123 5m
api True Applied revision: main/def456 3m
# Detailed status
$ flux describe kustomization webappFlux kustomizations show reconciliation status. True means the desired state is applied. The status includes the revision that was applied. flux describe provides detailed information about the last reconciliation.
Drift Visibility
Drift occurs when the cluster state diverges from Git. Both ArgoCD and Flux detect drift and report it. The key is knowing what changed, when, and by whom.
# ArgoCD Application status shows drift
status:
sync:
status: OutOfSync
comparedTo:
source:
repoURL: https://github.com/org/k8s-manifests.git
path: apps/my-app
destination:
server: https://kubernetes.default.svc
namespace: my-app
resources:
- kind: Deployment
name: my-app
status: OutOfSync
message: "Different from desired state"The ArgoCD Application status shows exactly which resources are out of sync. The comparedTo block shows the source and destination. The resources list shows individual resource sync status.
Deployment Metrics
GitOps controllers expose Prometheus metrics for monitoring deployment activity. These metrics feed into dashboards and alerts for operational visibility.
# Prometheus metrics from ArgoCD
argocd_app_info{dest_server,dest_namespace,src_repo,status,health}
argocd_app_reconcile{namespace,phase} # Reconciliation duration
argocd_app_sync{namespace,phase} # Sync operation duration
argocd_app_sync_total{namespace,phase} # Total sync operations
# Prometheus metrics from Flux
flux_reconcile_duration_seconds{controller,kind,name,namespace}
flux_reconcile_conditions{controller,kind,name,namespace,type,status}
flux_source_artifact_revision{controller,kind,name,namespace}These metrics show application status, reconciliation performance, and sync history. Use them to build dashboards showing deployment frequency, sync success rate, and reconciliation latency.
Monitoring Dashboards
apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-dashboard
labels:
grafana_dashboard: "1"
data:
argocd.json: |
{
"panels": [
{
"title": "Application Sync Status",
"type": "stat",
"targets": [
{
"expr": "argocd_app_info",
"legendFormat": "{{name}} - {{status}}"
}
]
}
]
}Grafana dashboards visualize GitOps metrics. The ConfigMap with the grafana_dashboard label is auto-discovered by the Grafana sidecar. The dashboard shows sync status, reconciliation metrics, and deployment history.
Alerting on GitOps
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: gitops-alerts
spec:
groups:
- name: gitops
rules:
- alert: ApplicationOutOfSync
expr: argocd_app_info{status="OutOfSync"} == 1
for: 30m
labels:
severity: warning
annotations:
summary: "Application {{ $labels.name }} is out of sync"
- alert: ReconciliationFailed
expr: flux_reconcile_result{result="error"} == 1
for: 10m
labels:
severity: critical
annotations:
summary: "Flux reconciliation failing for {{ $labels.name }}"These alerts fire when applications are out of sync for too long or when reconciliation fails. The for duration prevents alerting on transient issues. Critical alerts indicate broken deployments that need immediate attention.
Audit Trail
- Git history provides a complete audit trail of all changes.
- ArgoCD application history tracks every sync operation.
- Flux events show reconciliation activity in Kubernetes events.
- Kubernetes audit logs record API server access for compliance.
- Git commit messages link to tickets, changes, and authors.
Write descriptive commit messages for infrastructure changes. They become the deployment record. Include ticket numbers, change descriptions, and rollback instructions in the commit message.
In traditional CI/CD, auditing requires separate logging infrastructure. In GitOps, Git history is the audit trail. Every change has an author, timestamp, and message. No additional tooling is needed for basic audit requirements.
Mark this lesson complete to store local progress and unlock a cleaner resume path the next time you visit.