Added Openkruise workload integration health check scripts (#16238)

Signed-off-by: Mahesh <maheshkasbe010@gmail.com>
Co-authored-by: Ishita Sequeira <46771830+ishitasequeira@users.noreply.github.com>
This commit is contained in:
Mahesh Kasbe
2024-01-10 07:35:07 +05:30
committed by GitHub
parent 9b27aeb1a4
commit d6da9f2a15
39 changed files with 1174 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
hs = { status = "Progressing", message = "AdvancedCronJobs has active jobs" }
-- Extract lastScheduleTime and convert to time objects
lastScheduleTime = nil
if obj.status.lastScheduleTime ~= nil then
local year, month, day, hour, min, sec = string.match(obj.status.lastScheduleTime, "(%d+)-(%d+)-(%d+)T(%d+):(%d+):(%d+)Z")
lastScheduleTime = os.time({year=year, month=month, day=day, hour=hour, min=min, sec=sec})
end
if lastScheduleTime == nil and obj.spec.paused == true then
hs.status = "Suspended"
hs.message = "AdvancedCronJob is Paused"
return hs
end
-- AdvancedCronJobs are progressing if they have any object in the "active" state
if obj.status.active ~= nil and #obj.status.active > 0 then
hs.status = "Progressing"
hs.message = "AdvancedCronJobs has active jobs"
return hs
end
-- AdvancedCronJobs are Degraded if they don't have lastScheduleTime
if lastScheduleTime == nil then
hs.status = "Degraded"
hs.message = "AdvancedCronJobs has not run successfully"
return hs
end
-- AdvancedCronJobs are healthy if they have lastScheduleTime
if lastScheduleTime ~= nil then
hs.status = "Healthy"
hs.message = "AdvancedCronJobs has run successfully"
return hs
end
return hs

View File

@@ -0,0 +1,17 @@
tests:
- healthStatus:
status: Healthy
message: AdvancedCronJobs has run successfully
inputPath: testdata/lastScheduleTime.yaml
- healthStatus:
status: Degraded
message: AdvancedCronJobs has not run successfully
inputPath: testdata/notScheduled.yaml
- healthStatus:
status: Progressing
message: AdvancedCronJobs has active jobs
inputPath: testdata/activeJobs.yaml
- healthStatus:
status: Suspended
message: AdvancedCronJob is Paused
inputPath: testdata/suspended.yaml

View File

@@ -0,0 +1,30 @@
apiVersion: apps.kruise.io/v1alpha1
kind: AdvancedCronJob
metadata:
name: acj-test
spec:
schedule: "*/1 * * * *"
template:
broadcastJobTemplate:
spec:
template:
spec:
containers:
- name: pi
image: perl
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
restartPolicy: Never
completionPolicy:
type: Always
ttlSecondsAfterFinished: 30
status:
active:
- apiVersion: apps.kruise.io/v1alpha1
kind: BroadcastJob
name: acj-test-1694882400
namespace: default
resourceVersion: '4012'
uid: 2b08a429-a43b-4382-8e5d-3db0c72b5b13
lastScheduleTime: '2023-09-16T16:40:00Z'
type: BroadcastJob

View File

@@ -0,0 +1,23 @@
apiVersion: apps.kruise.io/v1alpha1
kind: AdvancedCronJob
metadata:
name: acj-test
spec:
schedule: "*/1 * * * *"
template:
broadcastJobTemplate:
spec:
template:
spec:
containers:
- name: pi
image: perl
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
restartPolicy: Never
completionPolicy:
type: Always
ttlSecondsAfterFinished: 30
status:
lastScheduleTime: "2023-09-16T16:29:00Z"
type: BroadcastJob

View File

@@ -0,0 +1,22 @@
apiVersion: apps.kruise.io/v1alpha1
kind: AdvancedCronJob
metadata:
name: acj-test
spec:
schedule: "*/1 * * * *"
template:
broadcastJobTemplate:
spec:
template:
spec:
containers:
- name: pi
image: perl
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
restartPolicy: Never
completionPolicy:
type: Always
ttlSecondsAfterFinished: 30
status:
lastScheduleTime: null

View File

@@ -0,0 +1,23 @@
apiVersion: apps.kruise.io/v1alpha1
kind: AdvancedCronJob
metadata:
name: acj-test
spec:
schedule: "*/1 * * * *"
template:
broadcastJobTemplate:
spec:
template:
spec:
containers:
- name: pi
image: perl
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
restartPolicy: Never
completionPolicy:
type: Always
ttlSecondsAfterFinished: 30
paused: true
status:
type: BroadcastJob

View File

@@ -0,0 +1,32 @@
hs={ status= "Progressing", message= "BroadcastJob is still running" }
if obj.status ~= nil then
-- BroadcastJob are healthy if desired number and succeeded number is equal
if obj.status.desired == obj.status.succeeded and obj.status.phase == "completed" then
hs.status = "Healthy"
hs.message = "BroadcastJob is completed successfully"
return hs
end
-- BroadcastJob are progressing if active is not equal to 0
if obj.status.active ~= 0 and obj.status.phase == "running" then
hs.status = "Progressing"
hs.message = "BroadcastJob is still running"
return hs
end
-- BroadcastJob are progressing if failed is not equal to 0
if obj.status.failed ~= 0 and obj.status.phase == "failed" then
hs.status = "Degraded"
hs.message = "BroadcastJob failed"
return hs
end
if obj.status.phase == "paused" and obj.spec.paused == true then
hs.status = "Suspended"
hs.message = "BroadcastJob is Paused"
return hs
end
end
return hs

View File

@@ -0,0 +1,17 @@
tests:
- healthStatus:
status: Healthy
message: "BroadcastJob is completed successfully"
inputPath: testdata/succeeded.yaml
- healthStatus:
status: Degraded
message: "BroadcastJob failed"
inputPath: testdata/failed.yaml
- healthStatus:
status: Progressing
message: "BroadcastJob is still running"
inputPath: testdata/running.yaml
- healthStatus:
status: Suspended
message: "BroadcastJob is Paused"
inputPath: testdata/suspended.yaml

View File

@@ -0,0 +1,31 @@
apiVersion: apps.kruise.io/v1alpha1
kind: BroadcastJob
metadata:
name: failed-job
spec:
template:
spec:
containers:
- name: guestbook
image: openkruise/guestbook:v3
command: ["exit", "1"] # a dummy command to fail
restartPolicy: Never
completionPolicy:
type: Always
ttlSecondsAfterFinished: 60 # the job will be deleted after 60 seconds
status:
active: 0
completionTime: '2023-09-17T14:31:38Z'
conditions:
- lastProbeTime: '2023-09-17T14:31:38Z'
lastTransitionTime: '2023-09-17T14:31:38Z'
message: failure policy is FailurePolicyTypeFailFast and failed pod is found
reason: Failed
status: 'True'
type: Failed
desired: 1
failed: 1
phase: failed
startTime: '2023-09-17T14:31:32Z'
succeeded: 0

View File

@@ -0,0 +1,22 @@
apiVersion: apps.kruise.io/v1alpha1
kind: BroadcastJob
metadata:
name: download-image
spec:
template:
spec:
containers:
- name: guestbook
image: openkruise/guestbook:v3
command: ["echo", "started"] # a dummy command to do nothing
restartPolicy: Never
completionPolicy:
type: Always
ttlSecondsAfterFinished: 60 # the job will be deleted after 60 seconds
status:
active: 1
desired: 1
failed: 0
phase: running
startTime: '2023-09-17T14:43:30Z'
succeeded: 0

View File

@@ -0,0 +1,31 @@
apiVersion: apps.kruise.io/v1alpha1
kind: BroadcastJob
metadata:
name: download-image
spec:
template:
spec:
containers:
- name: guestbook
image: openkruise/guestbook:v3
command: ["echo", "started"] # a dummy command to do nothing
restartPolicy: Never
completionPolicy:
type: Always
ttlSecondsAfterFinished: 60 # the job will be deleted after 60 seconds
status:
active: 0
completionTime: '2023-09-17T14:35:14Z'
conditions:
- lastProbeTime: '2023-09-17T14:35:14Z'
lastTransitionTime: '2023-09-17T14:35:14Z'
message: Job completed, 1 pods succeeded, 0 pods failed
reason: Complete
status: 'True'
type: Complete
desired: 1
failed: 0
phase: completed
startTime: '2023-09-17T14:35:07Z'
succeeded: 1

View File

@@ -0,0 +1,31 @@
apiVersion: apps.kruise.io/v1alpha1
kind: BroadcastJob
metadata:
name: download-image
spec:
template:
spec:
containers:
- name: guestbook
image: openkruise/guestbook:v3
command: ["echo", "started"] # a dummy command to do nothing
restartPolicy: Never
paused: true
completionPolicy:
type: Always
ttlSecondsAfterFinished: 60 # the job will be deleted after 60 seconds
status:
active: 0
completionTime: '2023-09-17T14:35:14Z'
conditions:
- lastProbeTime: '2023-09-17T14:35:14Z'
lastTransitionTime: '2023-09-17T14:35:14Z'
message: Job completed, 1 pods succeeded, 0 pods failed
reason: Complete
status: 'True'
type: Complete
desired: 1
failed: 0
phase: paused
startTime: '2023-09-17T14:35:07Z'
succeeded: 0

View File

@@ -0,0 +1,33 @@
hs={ status = "Progressing", message = "Waiting for initialization" }
if obj.status ~= nil then
if obj.metadata.generation == obj.status.observedGeneration then
if obj.spec.updateStrategy.paused == true or not obj.status.updatedAvailableReplicas then
hs.status = "Suspended"
hs.message = "Cloneset is paused"
return hs
elseif obj.spec.updateStrategy.partition ~= 0 and obj.metadata.generation > 1 then
if obj.status.updatedReplicas >= obj.status.expectedUpdatedReplicas then
hs.status = "Suspended"
hs.message = "Cloneset needs manual intervention"
return hs
end
elseif obj.status.updatedAvailableReplicas == obj.status.replicas then
hs.status = "Healthy"
hs.message = "All Cloneset workloads are ready and updated"
return hs
else
if obj.status.updatedAvailableReplicas ~= obj.status.replicas then
hs.status = "Degraded"
hs.message = "Some replicas are not ready or available"
return hs
end
end
end
end
return hs

View File

@@ -0,0 +1,21 @@
tests:
- healthStatus:
status: Healthy
message: "All Cloneset workloads are ready and updated"
inputPath: testdata/healthy.yaml
- healthStatus:
status: Degraded
message: "Some replicas are not ready or available"
inputPath: testdata/degraded.yaml
- healthStatus:
status: Progressing
message: "Waiting for initialization"
inputPath: testdata/unknown.yaml
- healthStatus:
status: Suspended
message: "Cloneset is paused"
inputpath: testdata/suspended.yaml
- healthStatus:
status: Suspended
message: "Cloneset needs manual intervention"
inputpath: testdata/partition_suspended.yaml

View File

@@ -0,0 +1,35 @@
apiVersion: apps.kruise.io/v1alpha1
kind: CloneSet
metadata:
name: cloneset-test
namespace: kruise
generation: 1
labels:
app: sample
spec:
replicas: 2
selector:
matchLabels:
app: sample
template:
metadata:
labels:
app: sample
spec:
containers:
- name: nginx
image: nginx:alpine
updateStrategy:
paused: false
status:
observedGeneration: 1
replicas: 2
updatedReadyReplicas: 1
updatedAvailableReplicas: 1
conditions:
- lastTransitionTime: "2021-09-21T22:35:31Z"
message: Deployment has minimum availability.
reason: MinimumReplicasAvailable
status: 'True'
type: FailedScale

View File

@@ -0,0 +1,36 @@
apiVersion: apps.kruise.io/v1alpha1
kind: CloneSet
metadata:
name: cloneset-test
namespace: kruise
generation: 1
labels:
app: sample
spec:
replicas: 1
selector:
matchLabels:
app: sample
template:
metadata:
labels:
app: sample
spec:
containers:
- name: nginx
image: nginx:alpine
updateStrategy:
paused: false
status:
observedGeneration: 1
replicas: 2
updatedReadyReplicas: 2
updatedAvailableReplicas: 2
conditions:
- lastTransitionTime: "2021-09-21T22:35:31Z"
message: Deployment has minimum availability.
reason: MinimumReplicasAvailable
status: 'True'
type: FailedScale

View File

@@ -0,0 +1,31 @@
apiVersion: apps.kruise.io/v1alpha1
kind: CloneSet
metadata:
name: cloneset-test
namespace: kruise
generation: 2
labels:
app: sample
spec:
replicas: 5
selector:
matchLabels:
app: sample
template:
metadata:
labels:
app: sample
spec:
containers:
- name: nginx
image: nginx:alpine
updateStrategy:
partition: 3
status:
observedGeneration: 2
replicas: 5
expectedUpdatedReplicas: 2
updatedReadyReplicas: 1
updatedAvailableReplicas: 1
updatedReplicas: 3

View File

@@ -0,0 +1,35 @@
apiVersion: apps.kruise.io/v1alpha1
kind: CloneSet
metadata:
name: cloneset-test
namespace: kruise
generation: 2
labels:
app: sample
spec:
replicas: 1
selector:
matchLabels:
app: sample
template:
metadata:
labels:
app: sample
spec:
containers:
- name: nginx
image: nginx:alpine
updateStrategy:
paused: true
status:
observedGeneration: 2
replicas: 2
updatedReadyReplicas: 2
updatedAvailableReplicas: 2
conditions:
- lastTransitionTime: "2021-09-21T22:35:31Z"
message: Deployment has minimum availability.
reason: MinimumReplicasAvailable
status: 'True'
type: FailedScale

View File

@@ -0,0 +1,5 @@
apiVersion: apps.kruise.io/v1alpha1
kind: CloneSet
metadata:
name: cloneset-test
namespace: kruise

View File

@@ -0,0 +1,35 @@
hs={ status = "Progressing", message = "Waiting for initialization" }
if obj.status ~= nil then
if obj.metadata.generation == obj.status.observedGeneration then
if obj.spec.updateStrategy.rollingUpdate.paused == true or not obj.status.updatedNumberScheduled then
hs.status = "Suspended"
hs.message = "Daemonset is paused"
return hs
elseif obj.spec.updateStrategy.rollingUpdate.partition ~= 0 and obj.metadata.generation > 1 then
if obj.status.updatedNumberScheduled > (obj.status.desiredNumberScheduled - obj.spec.updateStrategy.rollingUpdate.partition) then
hs.status = "Suspended"
hs.message = "Daemonset needs manual intervention"
return hs
end
elseif (obj.status.updatedNumberScheduled == obj.status.desiredNumberScheduled) and (obj.status.numberAvailable == obj.status.desiredNumberScheduled) then
hs.status = "Healthy"
hs.message = "All Daemonset workloads are ready and updated"
return hs
else
if (obj.status.updatedNumberScheduled == obj.status.desiredNumberScheduled) and (obj.status.numberUnavailable == obj.status.desiredNumberScheduled) then
hs.status = "Degraded"
hs.message = "Some pods are not ready or available"
return hs
end
end
end
end
return hs

View File

@@ -0,0 +1,21 @@
tests:
- healthStatus:
status: Healthy
message: "All Daemonset workloads are ready and updated"
inputPath: testdata/healthy.yaml
- healthStatus:
status: Degraded
message: "Some pods are not ready or available"
inputPath: testdata/degraded.yaml
- healthStatus:
status: Progressing
message: "Waiting for initialization"
inputPath: testdata/unknown.yaml
- healthStatus:
status: Suspended
message: "Daemonset is paused"
inputPath: testdata/suspended.yaml
- healthStatus:
status: Suspended
message: "Daemonset needs manual intervention"
inputPath: testdata/partition_suspended.yaml

View File

@@ -0,0 +1,34 @@
apiVersion: apps.kruise.io/v1alpha1
kind: DaemonSet
metadata:
name: daemonset-test
namespace: kruise
generation: 1
labels:
app: sample
spec:
selector:
matchLabels:
app: sample
template:
metadata:
labels:
app: sample
spec:
containers:
- name: nginx
image: nginx:alpine
updateStrategy:
rollingUpdate:
partition: 0
paused: false
status:
currentNumberScheduled: 1
daemonSetHash: 5dffcdfcd7
desiredNumberScheduled: 1
numberUnavailable: 1
numberMisscheduled: 0
numberReady: 0
observedGeneration: 1
updatedNumberScheduled: 1

View File

@@ -0,0 +1,34 @@
apiVersion: apps.kruise.io/v1alpha1
kind: DaemonSet
metadata:
name: daemonset-test
namespace: kruise
generation: 1
labels:
app: sample
spec:
selector:
matchLabels:
app: sample
template:
metadata:
labels:
app: sample
spec:
containers:
- name: nginx
image: nginx:alpine
updateStrategy:
rollingUpdate:
partition: 0
paused: false
status:
currentNumberScheduled: 1
daemonSetHash: 5dffcdfcd7
desiredNumberScheduled: 1
numberAvailable: 1
numberMisscheduled: 0
numberReady: 1
observedGeneration: 1
updatedNumberScheduled: 1

View File

@@ -0,0 +1,33 @@
apiVersion: apps.kruise.io/v1alpha1
kind: DaemonSet
metadata:
name: daemonset-test
namespace: kruise
generation: 6
labels:
app: sample
spec:
selector:
matchLabels:
app: sample
template:
metadata:
labels:
app: sample
spec:
containers:
- name: nginx
image: nginx:alpine
updateStrategy:
rollingUpdate:
partition: 4
status:
currentNumberScheduled: 1
daemonSetHash: 5f8cdcdc65
desiredNumberScheduled: 10
numberAvailable: 10
numberMisscheduled: 0
numberReady: 10
observedGeneration: 6
updatedNumberScheduled: 7

View File

@@ -0,0 +1,33 @@
apiVersion: apps.kruise.io/v1alpha1
kind: DaemonSet
metadata:
name: daemonset-test
namespace: kruise
generation: 1
labels:
app: sample
spec:
selector:
matchLabels:
app: sample
template:
metadata:
labels:
app: sample
spec:
containers:
- name: nginx
image: nginx:alpine
updateStrategy:
rollingUpdate:
paused: true
status:
currentNumberScheduled: 1
daemonSetHash: 5dffcdfcd7
desiredNumberScheduled: 1
numberAvailable: 1
numberMisscheduled: 0
numberReady: 1
observedGeneration: 1
updatedNumberScheduled: 1

View File

@@ -0,0 +1,5 @@
apiVersion: apps.kruise.io/v1alpha1
kind: DaemonSet
metadata:
name: daemonset-test
namespace: kruise

View File

@@ -0,0 +1,35 @@
hs={ status = "Progressing", message = "Waiting for initialization" }
if obj.status ~= nil then
if obj.metadata.generation == obj.status.observedGeneration then
if obj.spec.updateStrategy.rollingUpdate.paused == true or not obj.status.updatedAvailableReplicas then
hs.status = "Suspended"
hs.message = "Statefulset is paused"
return hs
elseif obj.spec.updateStrategy.rollingUpdate.partition ~= 0 and obj.metadata.generation > 1 then
if obj.status.updatedReplicas > (obj.status.replicas - obj.spec.updateStrategy.rollingUpdate.partition) then
hs.status = "Suspended"
hs.message = "Statefulset needs manual intervention"
return hs
end
elseif obj.status.updatedAvailableReplicas == obj.status.replicas then
hs.status = "Healthy"
hs.message = "All Statefulset workloads are ready and updated"
return hs
else
if obj.status.updatedAvailableReplicas ~= obj.status.replicas then
hs.status = "Degraded"
hs.message = "Some replicas are not ready or available"
return hs
end
end
end
end
return hs

View File

@@ -0,0 +1,21 @@
tests:
- healthStatus:
status: Healthy
message: "All Statefulset workloads are ready and updated"
inputPath: testdata/healthy.yaml
- healthStatus:
status: Degraded
message: "Some replicas are not ready or available"
inputPath: testdata/degraded.yaml
- healthStatus:
status: Progressing
message: "Waiting for initialization"
inputPath: testdata/unknown.yaml
- healthStatus:
status: Suspended
message: "Statefulset is paused"
inputPath: testdata/suspended.yaml
- healthStatus:
status: Suspended
message: "Statefulset needs manual intervention"
inputPath: testdata/partition_suspended.yaml

View File

@@ -0,0 +1,42 @@
apiVersion: apps.kruise.io/v1beta1
kind: StatefulSet
metadata:
name: statefulset-test
namespace: kruise
generation: 5
labels:
app: sample
spec:
replicas: 2
selector:
matchLabels:
app: sample
template:
metadata:
labels:
app: sample
spec:
containers:
- name: nginx
image: nginx:alpine
updateStrategy:
rollingUpdate:
maxUnavailable: 1
minReadySeconds: 0
paused: false
partition: 0
podUpdatePolicy: ReCreate
type: RollingUpdate
status:
observedGeneration: 5
replicas: 2
updatedAvailableReplicas: 1
updatedReadyReplicas: 1
conditions:
- lastTransitionTime: "2021-09-21T22:35:31Z"
message: Deployment has minimum availability.
reason: MinimumReplicasAvailable
status: 'True'
type: FailedCreatePod

View File

@@ -0,0 +1,41 @@
apiVersion: apps.kruise.io/v1beta1
kind: StatefulSet
metadata:
name: statefulset-test
namespace: kruise
generation: 2
labels:
app: sample
spec:
replicas: 2
selector:
matchLabels:
app: sample
template:
metadata:
labels:
app: sample
spec:
containers:
- name: nginx
image: nginx:alpine
updateStrategy:
rollingUpdate:
maxUnavailable: 1
minReadySeconds: 0
paused: false
partition: 0
podUpdatePolicy: ReCreate
type: RollingUpdate
status:
observedGeneration: 2
replicas: 2
updatedAvailableReplicas: 2
updatedReadyReplicas: 2
conditions:
- lastTransitionTime: "2021-09-21T22:35:31Z"
message: Deployment has minimum availability.
reason: MinimumReplicasAvailable
status: 'False'
type: FailedCreatePod

View File

@@ -0,0 +1,36 @@
apiVersion: apps.kruise.io/v1beta1
kind: StatefulSet
metadata:
name: statefulset-test
namespace: kruise
generation: 3
labels:
app: sample
spec:
replicas: 10
selector:
matchLabels:
app: sample
template:
metadata:
labels:
app: sample
spec:
containers:
- image: nginx:mainline
updateStrategy:
rollingUpdate:
partition: 4
status:
availableReplicas: 10
currentReplicas: 4
currentRevision: statefulset-test-d4d4fb5bd
labelSelector: app=sample
observedGeneration: 3
readyReplicas: 10
replicas: 10
updateRevision: statefulset-test-56dfb978d4
updatedAvailableReplicas: 7
updatedReadyReplicas: 7
updatedReplicas: 7

View File

@@ -0,0 +1,36 @@
apiVersion: apps.kruise.io/v1beta1
kind: StatefulSet
metadata:
name: statefulset-test
namespace: kruise
generation: 2
labels:
app: sample
spec:
replicas: 2
selector:
matchLabels:
app: sample
template:
metadata:
labels:
app: sample
spec:
containers:
- name: nginx
image: nginx:alpine
updateStrategy:
rollingUpdate:
paused: true
status:
observedGeneration: 2
replicas: 2
updatedAvailableReplicas: 2
updatedReadyReplicas: 2
conditions:
- lastTransitionTime: "2021-09-21T22:35:31Z"
message: Deployment has minimum availability.
reason: MinimumReplicasAvailable
status: 'False'
type: FailedCreatePod

View File

@@ -0,0 +1,5 @@
apiVersion: apps.kruise.io/v1beta1
kind: StatefulSet
metadata:
name: statefulset-test
namespace: kruise

View File

@@ -0,0 +1,31 @@
hs={ status = "Progressing", message = "Rollout is still progressing" }
if obj.metadata.generation == obj.status.observedGeneration then
if obj.status.canaryStatus.currentStepState == "StepUpgrade" and obj.status.phase == "Progressing" then
hs.status = "Progressing"
hs.message = "Rollout is still progressing"
return hs
end
if obj.status.canaryStatus.currentStepState == "StepPaused" and obj.status.phase == "Progressing" then
hs.status = "Suspended"
hs.message = "Rollout is Paused need manual intervention"
return hs
end
if obj.status.canaryStatus.currentStepState == "Completed" and obj.status.phase == "Healthy" then
hs.status = "Healthy"
hs.message = "Rollout is Completed"
return hs
end
if obj.status.canaryStatus.currentStepState == "StepPaused" and (obj.status.phase == "Terminating" or obj.status.phase == "Disabled") then
hs.status = "Degraded"
hs.message = "Rollout is Disabled or Terminating"
return hs
end
end
return hs

View File

@@ -0,0 +1,17 @@
tests:
- healthStatus:
status: Healthy
message: "Rollout is Completed"
inputPath: testdata/healthy.yaml
- healthStatus:
status: Degraded
message: "Rollout is Disabled or Terminating"
inputPath: testdata/degraded.yaml
- healthStatus:
status: Progressing
message: "Rollout is still progressing"
inputPath: testdata/progressing.yaml
- healthStatus:
status: Suspended
message: "Rollout is Paused need manual intervention"
inputPath: testdata/suspended.yaml

View File

@@ -0,0 +1,50 @@
apiVersion: rollouts.kruise.io/v1alpha1
kind: Rollout
metadata:
name: rollouts-demo
namespace: default
annotations:
rollouts.kruise.io/rolling-style: partition
generation: 5
spec:
objectRef:
workloadRef:
apiVersion: apps/v1
kind: Deployment
name: workload-demo
strategy:
canary:
steps:
- replicas: 1
pause:
duration: 0
- replicas: 50%
pause:
duration: 0
- replicas: 100%
status:
canaryStatus:
canaryReadyReplicas: 1
canaryReplicas: 1
canaryRevision: 76fd76f75b
currentStepIndex: 1
currentStepState: StepPaused
lastUpdateTime: '2023-09-23T11:44:39Z'
message: BatchRelease is at state Ready, rollout-id , step 1
observedWorkloadGeneration: 7
podTemplateHash: 76fd76f75b
rolloutHash: 77cxd69w47b7bwddwv2w7vxvb4xxdbwcx9x289vw69w788w4w6z4x8dd4vbz2zbw
stableRevision: 6bfdfb5bfb
conditions:
- lastTransitionTime: '2023-09-23T11:44:09Z'
lastUpdateTime: '2023-09-23T11:44:09Z'
message: Rollout is in Progressing
reason: InRolling
status: 'True'
type: Progressing
message: >-
Rollout is in step(1/3), and you need manually confirm to enter the next
step
observedGeneration: 5
phase: Disabled

View File

@@ -0,0 +1,56 @@
apiVersion: rollouts.kruise.io/v1alpha1
kind: Rollout
metadata:
name: rollouts-demo
namespace: default
annotations:
rollouts.kruise.io/rolling-style: partition
generation: 7
spec:
objectRef:
workloadRef:
apiVersion: apps/v1
kind: Deployment
name: workload-demo
strategy:
canary:
steps:
- replicas: 1
pause:
duration: 0
- replicas: 50%
pause:
duration: 0
- replicas: 100%
status:
canaryStatus:
canaryReadyReplicas: 10
canaryReplicas: 10
canaryRevision: 76fd76f75b
currentStepIndex: 3
currentStepState: Completed
lastUpdateTime: '2023-09-23T11:48:58Z'
message: BatchRelease is at state Ready, rollout-id , step 3
observedWorkloadGeneration: 22
podTemplateHash: 76fd76f75b
rolloutHash: 77cxd69w47b7bwddwv2w7vxvb4xxdbwcx9x289vw69w788w4w6z4x8dd4vbz2zbw
stableRevision: 6bfdfb5bfb
conditions:
- lastTransitionTime: '2023-09-23T11:44:09Z'
lastUpdateTime: '2023-09-23T11:44:09Z'
message: Rollout progressing has been completed
reason: Completed
status: 'False'
type: Progressing
- lastTransitionTime: '2023-09-23T11:49:01Z'
lastUpdateTime: '2023-09-23T11:49:01Z'
message: ''
reason: ''
status: 'True'
type: Succeeded
message: Rollout progressing has been completed
observedGeneration: 7
phase: Healthy

View File

@@ -0,0 +1,48 @@
apiVersion: rollouts.kruise.io/v1alpha1
kind: Rollout
metadata:
name: rollouts-demo
namespace: default
annotations:
rollouts.kruise.io/rolling-style: partition
generation: 5
spec:
objectRef:
workloadRef:
apiVersion: apps/v1
kind: Deployment
name: workload-demo
strategy:
canary:
steps:
- replicas: 1
pause:
duration: 0
- replicas: 50%
pause:
duration: 0
- replicas: 100%
status:
canaryStatus:
canaryReadyReplicas: 0
canaryReplicas: 1
canaryRevision: 76fd76f75b
currentStepIndex: 1
currentStepState: StepUpgrade
lastUpdateTime: '2023-09-23T11:44:12Z'
message: BatchRelease is at state Verifying, rollout-id , step 1
observedWorkloadGeneration: 6
podTemplateHash: 76fd76f75b
rolloutHash: 77cxd69w47b7bwddwv2w7vxvb4xxdbwcx9x289vw69w788w4w6z4x8dd4vbz2zbw
stableRevision: 6bfdfb5bfb
conditions:
- lastTransitionTime: '2023-09-23T11:44:09Z'
lastUpdateTime: '2023-09-23T11:44:09Z'
message: Rollout is in Progressing
reason: InRolling
status: 'True'
type: Progressing
message: Rollout is in step(1/3), and upgrade workload to new version
observedGeneration: 5
phase: Progressing

View File

@@ -0,0 +1,50 @@
apiVersion: rollouts.kruise.io/v1alpha1
kind: Rollout
metadata:
name: rollouts-demo
namespace: default
annotations:
rollouts.kruise.io/rolling-style: partition
generation: 5
spec:
objectRef:
workloadRef:
apiVersion: apps/v1
kind: Deployment
name: workload-demo
strategy:
canary:
steps:
- replicas: 1
pause:
duration: 0
- replicas: 50%
pause:
duration: 0
- replicas: 100%
status:
canaryStatus:
canaryReadyReplicas: 1
canaryReplicas: 1
canaryRevision: 76fd76f75b
currentStepIndex: 1
currentStepState: StepPaused
lastUpdateTime: '2023-09-23T11:44:39Z'
message: BatchRelease is at state Ready, rollout-id , step 1
observedWorkloadGeneration: 7
podTemplateHash: 76fd76f75b
rolloutHash: 77cxd69w47b7bwddwv2w7vxvb4xxdbwcx9x289vw69w788w4w6z4x8dd4vbz2zbw
stableRevision: 6bfdfb5bfb
conditions:
- lastTransitionTime: '2023-09-23T11:44:09Z'
lastUpdateTime: '2023-09-23T11:44:09Z'
message: Rollout is in Progressing
reason: InRolling
status: 'True'
type: Progressing
message: >-
Rollout is in step(1/3), and you need manually confirm to enter the next
step
observedGeneration: 5
phase: Progressing