Custom ArgoCD health checks

Patrick’s neat write-up of ArgoCD health checks does a pretty good explanation of how they work and where to find the default ones coming with ArgoCD out-of-the-box … and is quite worth a read!

To quickly summarize, resources’ health checks decide if your resources displayed in ArgoCD gui are either in state healthy, progressing or degraded (and there is also suspended, allthough that one is rather seldom used).

So what if you introduce a new resource (eg by CRD) or use one that ArgoCD does not provide a pre-packaged health check? Simply create or override your own copy of health check by adding it via the resource.customizations field into argocd-cm Configmap.

Override an existing health check

I myself was not too happy with ArgoCD’s version of operators.coreos.com/Subscription health check: Because most of my deployed operators are using manual update strategy, ArgoCD would put these operators in state Progressing, whenever a new version was released via OLM, and the operator’s subscription thus went into status InstallPlanPending.
Quite often ArgoCD was now in state progressing, which - at least to me - was confusing, and so I decided to change this.

Health checks are written in LUA and quite easy to adapt. In this configmap code snippet you can see that I added a single condition for the manual InstallPlanApproval strategy, and now my operators show up as degraded instead of progressing. One can easily change that to suspended which would fit even better in this case.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
    operators.coreos.com/Subscription:
      health.lua: |
      ...
            elseif numPending > 0 and numDegraded == 0 then
              -- start: added condition for `approval` --
              if obj.spec.installPlanApproval == "Manual" then
                health_status.status = "Degraded"
              -- end --
              else
                health_status.status = "Progressing"
              end
              health_status.message = "An install plan for a subscription is pending installation"
              return health_status
      ...
updatedupdated2022-10-202022-10-20