-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support health check on ClusterIssuer (#12000)
Signed-off-by: ChangZhuo Chen (陳昌倬) <czchen@czchen.org>
- Loading branch information
Showing
5 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
resource_customizations/cert-manager.io/ClusterIssuer/health.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
14 changes: 14 additions & 0 deletions
14
resource_customizations/cert-manager.io/ClusterIssuer/health_test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
26 changes: 26 additions & 0 deletions
26
resource_customizations/cert-manager.io/ClusterIssuer/testdata/degraded_acmeFailed.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
25 changes: 25 additions & 0 deletions
25
resource_customizations/cert-manager.io/ClusterIssuer/testdata/healthy_registered.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
16 changes: 16 additions & 0 deletions
16
resource_customizations/cert-manager.io/ClusterIssuer/testdata/progressing_noStatus.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |