How do you write a custom health check in Lua?
IntermediateConceptSync Waves, Hooks, Health & Diffing
Answer
Add a key in argocd-cm named resource.customizations.health.<group>_<kind>. The script receives obj and returns a table with status and message:
resource.customizations.health.example.com_Database: |
hs = { status = "Progressing", message = "Provisioning" }
if obj.status ~= nil and obj.status.phase == "Ready" then
hs.status = "Healthy"; hs.message = "Database ready"
elseif obj.status ~= nil and obj.status.phase == "Failed" then
hs.status = "Degraded"; hs.message = obj.status.reason or "Failed"
end
return hs
Test offline with argocd admin settings resource-overrides health obj.yaml --argocd-cm-path argocd-cm.yaml.