Skip to content

Commit

Permalink
feat: support health check on ClusterIssuer (#12000)
Browse files Browse the repository at this point in the history
Signed-off-by: ChangZhuo Chen (陳昌倬) <czchen@czchen.org>
  • Loading branch information
czchen authored May 4, 2023
1 parent e8331b4 commit 86926d7
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 0 deletions.
21 changes: 21 additions & 0 deletions resource_customizations/cert-manager.io/ClusterIssuer/health.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
hs = {}
if obj.status ~= nil then
if obj.status.conditions ~= nil then
for i, condition in ipairs(obj.status.conditions) do
if condition.type == "Ready" and condition.status == "False" then
hs.status = "Degraded"
hs.message = condition.message
return hs
end
if condition.type == "Ready" and condition.status == "True" then
hs.status = "Healthy"
hs.message = condition.message
return hs
end
end
end
end

hs.status = "Progressing"
hs.message = "Initializing ClusterIssuer"
return hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
tests:
- healthStatus:
status: Progressing
message: Initializing ClusterIssuer
inputPath: testdata/progressing_noStatus.yaml
- healthStatus:
status: Healthy
message: The ACME account was registered with the ACME server
inputPath: testdata/healthy_registered.yaml
- healthStatus:
status: Degraded
message: "Failed to verify ACME account: acme: : 404 page not found\n"
inputPath: testdata/degraded_acmeFailed.yaml

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
creationTimestamp: "2019-02-15T19:23:48Z"
generation: 1
name: test-issuer
resourceVersion: "68352438"
uid: 37f408e3-3157-11e9-be3f-42010a800011
spec:
acme:
email: myemail@test.com
http01: {}
privateKeySecretRef:
key: ""
name: letsencrypt
server: https://acme-v02.api.letsencrypt.org/directory124
status:
acme:
uri: ""
conditions:
- lastTransitionTime: "2019-02-15T19:23:53Z"
message: |
Failed to verify ACME account: acme: : 404 page not found
reason: ErrRegisterACMEAccount
status: "False"
type: Ready
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
creationTimestamp: "2018-11-06T23:14:18Z"
generation: 1
name: test-issuer
resourceVersion: "48889060"
uid: b0045219-e219-11e8-9f93-42010a80021d
spec:
acme:
email: myemail@test.com
http01: {}
privateKeySecretRef:
key: ""
name: letsencrypt
server: https://acme-v02.api.letsencrypt.org/directory
status:
acme:
uri: https://acme-v02.api.letsencrypt.org/acme/acct/45250083
conditions:
- lastTransitionTime: "2018-12-06T06:42:59Z"
message: The ACME account was registered with the ACME server
reason: ACMEAccountRegistered
status: "True"
type: Ready
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
creationTimestamp: "2018-11-06T23:14:18Z"
generation: 1
name: test-issuer
resourceVersion: "48889060"
uid: b0045219-e219-11e8-9f93-42010a80021d
spec:
acme:
email: myemail@test.com
http01: {}
privateKeySecretRef:
key: ""
name: letsencrypt
server: https://acme-v02.api.letsencrypt.org/directory

0 comments on commit 86926d7

Please sign in to comment.