TExcelTAD
Home › GitOps: Argo CD & Flux › Health Checks

Health Checks

"Applied" is not "working". After a sync, Argo CD asks a second question about every object: is it healthy? The answers roll up into the Application's health, drive sync waves (the next wave waits for health), PostSync hooks and notifications, and decide whether a promotion should go ahead.

Health statuses

Status Meaning Typical cause
Healthy working as intended Deployment rolled out, all replicas available
Progressing not healthy yet, may still get there rollout in progress, LoadBalancer waiting for an IP
Degraded failed, or can't make progress ProgressDeadlineExceeded, crash-looping Pods, a failed Job
Suspended paused on purpose suspended CronJob, paused rollout
Missing in Git but not in the cluster not synced yet, or deleted
Unknown the health check failed to run a broken custom check

Only some kinds have checks. Built-in ones cover Deployments, StatefulSets, DaemonSets, ReplicaSets, Pods, Jobs, PVCs (Bound), Services of type LoadBalancer, Ingresses, HPAs, APIServices and several popular CRDs (Argo Rollouts, cert-manager Certificates and many more, maintained in the Argo CD repository as Lua scripts). Objects without a check (ConfigMaps, Secrets, plain Services) have no health and don't affect the app.

How a Deployment is judged

A Deployment's check is based on the same fields kubectl rollout status reads. Modelled:

python · try it yourself
def deployment_health(spec, status):
    if spec.get("paused"):
        return "Suspended", "Deployment is paused"
    if status.get("observedGeneration", 0) < spec["generation"]:
        return "Progressing", "Waiting for rollout to finish: observed generation is old"
    for cond in status.get("conditions", []):
        if cond["type"] == "Progressing" and cond.get("reason") == "ProgressDeadlineExceeded":
            return "Degraded", f'Deployment "linkly" exceeded its progress deadline'
    want = spec["replicas"]
    if status.get("updatedReplicas", 0) < want:
        return "Progressing", f"{status.get('updatedReplicas', 0)} of {want} updated replicas are available..."
    if status.get("availableReplicas", 0) < want:
        return "Progressing", f"{status.get('availableReplicas', 0)} of {want} updated replicas are available..."
    return "Healthy", ""

spec = {"generation": 7, "replicas": 3}
snapshots = [
    {"observedGeneration": 6},
    {"observedGeneration": 7, "updatedReplicas": 1, "availableReplicas": 3},
    {"observedGeneration": 7, "updatedReplicas": 3, "availableReplicas": 2},
    {"observedGeneration": 7, "updatedReplicas": 3, "availableReplicas": 3},
    {"observedGeneration": 7, "updatedReplicas": 1, "availableReplicas": 2,
     "conditions": [{"type": "Progressing", "reason": "ProgressDeadlineExceeded"}]},
]
for i, status in enumerate(snapshots):
    print(i, *deployment_health(spec, status))
0 Progressing Waiting for rollout to finish: observed generation is old
1 Progressing 1 of 3 updated replicas are available...
2 Progressing 2 of 3 updated replicas are available...
3 Healthy
4 Degraded Deployment "linkly" exceeded its progress deadline

The last case is why progressDeadlineSeconds (600 s by default) matters in GitOps: a bad image that never becomes ready turns the app Degraded after the deadline, which is the signal your notifications and promotion gates wait for. Without it, a broken rollout would sit in Progressing forever.

From objects to the application

The Application's health is the worst health among its objects, in this order (best to worst): Healthy, Suspended, Progressing, Missing, Degraded, Unknown.

python · try it yourself
ORDER = ["Healthy", "Suspended", "Progressing", "Missing", "Degraded", "Unknown"]

def app_health(resources):
    statuses = [h for _, h in resources if h is not None]      # objects without a check don't count
    return max(statuses, key=ORDER.index) if statuses else "Healthy"

resources = [
    ("ConfigMap/linkly-config", None),
    ("Service/linkly", "Healthy"),
    ("Deployment/linkly", "Progressing"),
    ("HorizontalPodAutoscaler/linkly", "Healthy"),
]
print("during rollout:", app_health(resources))
resources[2] = ("Deployment/linkly", "Degraded")
print("after deadline:", app_health(resources))
resources[2] = ("Deployment/linkly", "Healthy")
print("fixed:         ", app_health(resources))
during rollout: Progressing
after deadline: Degraded
fixed:          Healthy

Custom health checks in Lua

For a CRD Argo CD doesn't know, or to change how a kind is judged, add a Lua script to argocd-cm under resource.customizations.health.<group>_<kind>. The script receives the live object as obj and returns a table with status and message. Here is a check for Gateway API HTTPRoutes: healthy when every parent Gateway has accepted the route and all backends resolved.

yaml
apiVersion: v1
kind: ConfigMap
metadata: {name: argocd-cm, namespace: argocd}
data:
  resource.customizations.health.gateway.networking.k8s.io_HTTPRoute: |
    hs = {status = "Progressing", message = "Waiting for the Gateway to accept the route"}
    if obj.status == nil or obj.status.parents == nil then
      return hs
    end
    for _, parent in ipairs(obj.status.parents) do
      for _, c in ipairs(parent.conditions or {}) do
        if c.type == "Accepted" and c.status == "False" then
          return {status = "Degraded", message = c.reason .. ": " .. (c.message or "")}
        end
        if c.type == "ResolvedRefs" and c.status == "False" then
          return {status = "Degraded", message = "Backend not resolved: " .. c.reason}
        end
      end
    end
    return {status = "Healthy", message = "Accepted by all parent Gateways"}

Test custom checks before shipping them: the Argo CD repo keeps each built-in check with YAML fixtures and expected results, and you can do the same with a small lua test harness in CI. A check that throws makes the object Unknown, which makes the whole application Unknown.

Note: Since Argo CD 3.0, resource health is no longer stored in the Application object by default (it is computed and served by the API). Read it with argocd app get <app> -o json or the API, not by reading .status.resources[].health with kubectl.

Test yourself

An Application has a healthy Service, a Progressing Deployment and a ConfigMap. What is the app's health?

  1. Healthy
  2. Progressing
  3. Degraded
  4. Unknown

Why does progressDeadlineSeconds matter for GitOps health?

  1. It speeds up syncs
  2. It turns a rollout that never becomes ready into Degraded, a clear failure signal instead of endless Progressing
  3. It retries failed syncs
  4. It sets the polling interval

Where do you define a custom health check for a CRD in Argo CD?

  1. In the CRD itself
  2. As a Lua script in argocd-cm under resource.customizations.health.<group>_<kind>
  3. In the Application's syncPolicy
  4. In a Helm hook