-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement MachineHealthCheck CRD health check
Signed-off-by: Jellyfrog <Jellyfrog@users.noreply.github.com>
- Loading branch information
Showing
4 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
resource_customizations/cluster.x-k8s.io/MachineHealthCheck/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,14 @@ | ||
hs = {} | ||
|
||
hs.status = "Progressing" | ||
hs.message = "" | ||
|
||
if obj.status ~= nil and obj.status.currentHealthy ~= nil then | ||
if obj.status.expectedMachines == obj.status.currentHealthy then | ||
hs.status = "Healthy" | ||
else | ||
hs.status = "Degraded" | ||
end | ||
end | ||
|
||
return hs |
9 changes: 9 additions & 0 deletions
9
resource_customizations/cluster.x-k8s.io/MachineHealthCheck/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,9 @@ | ||
tests: | ||
- healthStatus: | ||
status: Degraded | ||
message: '' | ||
inputPath: testdata/degraded_expectedMachines.yaml | ||
- healthStatus: | ||
status: Healthy | ||
message: '' | ||
inputPath: testdata/healthy.yaml |
33 changes: 33 additions & 0 deletions
33
...ustomizations/cluster.x-k8s.io/MachineHealthCheck/testdata/degraded_expectedMachines.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,33 @@ | ||
apiVersion: cluster.x-k8s.io/v1beta1 | ||
kind: MachineHealthCheck | ||
metadata: | ||
labels: | ||
cluster.x-k8s.io/cluster-name: test | ||
name: test-node-unhealthy-5m | ||
spec: | ||
clusterName: test | ||
maxUnhealthy: 100% | ||
nodeStartupTimeout: 10m0s | ||
selector: | ||
matchLabels: | ||
cluster.x-k8s.io/deployment-name: test-md-workers-0 | ||
unhealthyConditions: | ||
- status: Unknown | ||
timeout: 5m | ||
type: Ready | ||
- status: "False" | ||
timeout: 5m | ||
type: Ready | ||
status: | ||
conditions: | ||
- lastTransitionTime: "2022-10-07T10:33:46Z" | ||
status: "True" | ||
type: RemediationAllowed | ||
currentHealthy: 1 | ||
expectedMachines: 3 | ||
observedGeneration: 3 | ||
remediationsAllowed: 1 | ||
targets: | ||
- test-md-workers-0-76f7db5786-8nl6m | ||
- test-md-workers-0-76f7db5786-jjzvf | ||
- test-md-workers-0-76f7db5786-l4vfb |
33 changes: 33 additions & 0 deletions
33
resource_customizations/cluster.x-k8s.io/MachineHealthCheck/testdata/healthy.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,33 @@ | ||
apiVersion: cluster.x-k8s.io/v1beta1 | ||
kind: MachineHealthCheck | ||
metadata: | ||
labels: | ||
cluster.x-k8s.io/cluster-name: test | ||
name: test-node-unhealthy-5m | ||
spec: | ||
clusterName: test | ||
maxUnhealthy: 100% | ||
nodeStartupTimeout: 10m0s | ||
selector: | ||
matchLabels: | ||
cluster.x-k8s.io/deployment-name: test-md-workers-0 | ||
unhealthyConditions: | ||
- status: Unknown | ||
timeout: 5m | ||
type: Ready | ||
- status: "False" | ||
timeout: 5m | ||
type: Ready | ||
status: | ||
conditions: | ||
- lastTransitionTime: "2022-10-07T10:33:46Z" | ||
status: "True" | ||
type: RemediationAllowed | ||
currentHealthy: 3 | ||
expectedMachines: 3 | ||
observedGeneration: 3 | ||
remediationsAllowed: 1 | ||
targets: | ||
- test-md-workers-0-76f7db5786-8nl6m | ||
- test-md-workers-0-76f7db5786-jjzvf | ||
- test-md-workers-0-76f7db5786-l4vfb |