Skip to content

Commit c5acbef

Browse files
authored
Merge pull request #742 from allamand/feat/argocd-lua-health-checks
feat: add ArgoCD Lua health checks addon for kro and Crossplane
2 parents 9185dec + b4f4e9d commit c5acbef

2 files changed

Lines changed: 59 additions & 0 deletions

File tree

gitops/addons/bootstrap/default/addons.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,21 @@ kro-manifests-hub:
639639
operator: In
640640
values: ['true']
641641

642+
argocd-health-checks:
643+
enabled: false
644+
type: manifest
645+
namespace: argocd
646+
annotationsAppSet:
647+
argocd.argoproj.io/sync-wave: '-3' # Before kro RGDs so health checks are ready
648+
path: '{{.metadata.annotations.addons_repo_basepath}}charts/argocd-health-checks'
649+
directory:
650+
recurse: false
651+
selector:
652+
matchExpressions:
653+
- key: enable_argocd_health_checks
654+
operator: In
655+
values: ['true']
656+
642657
multi-acct:
643658
enabled: false
644659
namespace: kro
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# ArgoCD custom Lua health check for kro resources.
2+
# Deployed by the argocd-health-checks addon (enable_argocd_health_checks label).
3+
#
4+
# Uses the resource.customizations wildcard format so a single entry covers
5+
# all kro.run/* kinds (any RGD-generated CRD + ResourceGraphDefinition itself).
6+
#
7+
# Note: Crossplane (*.upbound.io) health checks are already built-in to OSS ArgoCD.
8+
# See: https://github.com/argoproj/argo-cd/blob/master/resource_customizations/_.upbound.io/_/health.lua
9+
#
10+
# Ref: https://argo-cd.readthedocs.io/en/latest/operator-manual/health/#way-1-define-a-custom-health-check-in-argocd-cm-configmap
11+
apiVersion: v1
12+
kind: ConfigMap
13+
metadata:
14+
name: argocd-cm
15+
namespace: argocd
16+
labels:
17+
app.kubernetes.io/part-of: argocd
18+
data:
19+
resource.customizations: |
20+
kro.run/*:
21+
health.lua: |
22+
local hs = {}
23+
if obj.status == nil or obj.status.conditions == nil then
24+
hs.status = "Progressing"
25+
hs.message = "Waiting for KRO to report status"
26+
return hs
27+
end
28+
if obj.status.state == "ERROR" or obj.status.state == "FAILED" then
29+
hs.status = "Degraded"
30+
hs.message = obj.status.conditions[#obj.status.conditions].message or "Instance has errors"
31+
return hs
32+
end
33+
for _, condition in ipairs(obj.status.conditions) do
34+
if condition.type == "Ready" then
35+
if condition.status == "True" then
36+
hs.status = "Healthy"
37+
hs.message = condition.message or "Ready"
38+
return hs
39+
end
40+
end
41+
end
42+
hs.status = "Progressing"
43+
hs.message = "Waiting for Ready condition"
44+
return hs

0 commit comments

Comments
 (0)