Skip to content

Commit b6d2bdb

Browse files
committed
Add ArgoCD CM for health status
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent cf46c83 commit b6d2bdb

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

docs/openfaas-pro/function-crd.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,58 @@ $ kubectl get function/env -n openfaas-fn -o jsonpath="{.status.conditions[?(@.t
130130
$ kubectl get function/env -n openfaas-fn -o jsonpath="{.status.conditions[?(@.type == 'Healthy')].status}"
131131
```
132132

133+
#### ArgoCD health status
134+
135+
Edit ArgoCD's configmap to add a custom health check for the Function CRD:
136+
137+
```bash
138+
kubectl edit configmap argocd-cm -n argocd
139+
```
140+
141+
```yaml
142+
data:
143+
resource.customizations: |
144+
openfaas.com/Function:
145+
health.lua: |
146+
hs = {}
147+
if obj.status ~= nil then
148+
if obj.status.conditions ~= nil then
149+
for i, condition in ipairs(obj.status.conditions) do
150+
if condition.type == "Ready" and condition.status == "False" then
151+
hs.status = "Degraded"
152+
hs.message = condition.message
153+
return hs
154+
end
155+
if condition.type == "Stalled" and condition.status == "True" then
156+
hs.status = "Degraded"
157+
hs.message = condition.message
158+
return hs
159+
end
160+
if condition.type == "Ready" and condition.status == "True" then
161+
if obj.status.replicas ~= nil and obj.status.replicas > 0 then
162+
hs.status = "Healthy"
163+
hs.message = condition.message
164+
else
165+
hs.status = "Suspended"
166+
hs.message = "No replicas available"
167+
end
168+
return hs
169+
end
170+
end
171+
end
172+
end
173+
174+
hs.status = "Progressing"
175+
hs.message = "Waiting for Function"
176+
return hs
177+
```
178+
179+
ArgoCD health status:
180+
181+
* Function can't become ready due to a missing secret => Argo status: degraded
182+
* Function is ready and can serve traffic to at least one Pod => Argo status: healthy
183+
* Function is ready (no changes need to be applied), but has been scaled down to zero replicas => Argo status: suspended
184+
133185
### How to generate a spec from a stack.yml
134186
135187
If you already have functions defined in a stack.yml file, you can generate the Function resources with:

0 commit comments

Comments
 (0)