Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added health check for spot.io SpotDeployment #10152

Merged
merged 3 commits into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 41 additions & 0 deletions resource_customizations/spot.io/SpotDeployment/health.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
hs = {}

if obj.status == nil or obj.status.conditions == nil then
return hs
end

for _, condition in ipairs(obj.status.conditions) do
if condition.type == "InvalidSpec" then
hs.status = "Degraded"
hs.message = condition.message
return hs
end
if condition.type == "Progressing" and condition.reason == "RolloutAborted" then
hs.status = "Degraded"
hs.message = condition.message
return hs
end
if condition.type == "Progressing" and condition.reason == "ProgressDeadlineExceeded" then
hs.status = "Degraded"
hs.message = condition.message
return hs
end
if condition.type == "Paused" and condition.status == "True" then
hs.status = "Suspended"
hs.message = "Rollout is paused"
return hs
end
end

if obj.status.phase == "Progressing" then
hs.status = "Progressing"
hs.message = "Waiting for rollout to finish steps"
return hs
end

dleinov marked this conversation as resolved.
Show resolved Hide resolved
hs.status = "Healthy"
hs.message = ""
return hs



12 changes: 12 additions & 0 deletions resource_customizations/spot.io/SpotDeployment/health_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
tests:
- healthStatus:
status: Degraded
message: "Rollout is aborted"
inputPath: testdata/degraded_spotdeployment.yaml
- healthStatus:
status: Healthy
inputPath: testdata/healthy_spotdeployment.yaml
- healthStatus:
status: Degraded
message: "The Rollout \"basic\" is invalid: spec.strategy.strategy: Required value: Rollout has missing field '.spec.strategy.canary or .spec.strategy.blueGreen'"
inputPath: testdata/invalid_spec_spotdeployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
apiVersion: spot.io/v1beta1
kind: SpotDeployment
metadata:
name: canary-demo
namespace: default
spec:
replicas: 5
revisionHistoryLimit: 3
selector:
matchLabels:
app: canary-demo
template:
metadata:
creationTimestamp: null
labels:
app: canary-demo
spec:
containers:
- image: nginx:1.21
imagePullPolicy: Always
name: canary-demo
ports:
- containerPort: 8080
name: http
protocol: TCP
resources:
requests:
cpu: 5m
memory: 32Mi
status:
availableReplicas: 5
conditions:
- lastTransitionTime: "2019-11-03T01:32:46Z"
lastUpdateTime: "2019-11-03T01:32:46Z"
message: Rollout has minimum availability
reason: AvailableReason
status: "True"
type: Available
- lastTransitionTime: "2019-11-05T18:20:12Z"
lastUpdateTime: "2019-11-05T18:20:12Z"
message: Rollout is aborted
reason: RolloutAborted
status: "False"
type: Progressing
observedGeneration: 58b949649c
readyReplicas: 5
replicas: 5
selector: app=canary-demo
liveVersionDate: "2022-07-25T08:57:57.000Z"
liveVersionImages:
nginx: nginx:1.20
phase: Degraded
revision: "52"
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
apiVersion: spot.io/v1beta1
kind: SpotDeployment
metadata:
clusterName: ''
creationTimestamp: '2019-05-01T21:55:30Z'
generation: 1
labels:
app.kubernetes.io/instance: guestbook-canary
ksonnet.io/component: guestbook-ui
name: guestbook-canary
namespace: default
resourceVersion: '955764'
uid: d6105ccd-6c5b-11e9-b8d7-025000000001
spec:
minReadySeconds: 10
replicas: 5
selector:
matchLabels:
app: guestbook-canary
template:
metadata:
creationTimestamp: null
labels:
app: guestbook-canary
spec:
containers:
- image: 'gcr.io/heptio-images/ks-guestbook-demo:0.1'
name: guestbook-canary
ports:
- containerPort: 80
resources: {}
status:
conditions:
- lastTransitionTime: '2019-05-01T21:55:30Z'
lastUpdateTime: '2019-05-01T21:55:58Z'
message: ReplicaSet "guestbook-canary-84ccfddd66" has successfully progressed.
reason: NewReplicaSetAvailable
status: 'True'
type: Progressing
- lastTransitionTime: '2019-05-01T21:55:58Z'
lastUpdateTime: '2019-05-01T21:55:58Z'
message: Rollout has minimum availability
reason: AvailableReason
status: 'True'
type: Available
observedGeneration: c45557fd9
readyReplicas: 5
replicas: 5
selector: app=guestbook-canary
liveVersionDate: "2022-07-14T07:56:27.000Z"
liveVersionImages:
rollouts-demo: gcr.io/heptio-images/ks-guestbook-demo:0.1
phase: Healthy
revision: "9"
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
apiVersion: spot.io/v1beta1
kind: SpotDeployment
metadata:
creationTimestamp: "2020-11-13T00:22:49Z"
generation: 3
name: basic
namespace: argocd-e2e
resourceVersion: "181746"
uid: 5b0926f3-30b7-4727-a76e-46c0d2617906
spec:
replicas: 1
selector:
matchLabels:
app: basic
template:
metadata:
creationTimestamp: null
labels:
app: basic
spec:
containers:
- image: nginx:1.19-alpine
name: basic
resources:
requests:
cpu: 1m
memory: 16Mi
status:
availableReplicas: 1
conditions:
- lastTransitionTime: "2020-11-13T00:22:48Z"
lastUpdateTime: "2020-11-13T00:22:50Z"
message: ReplicaSet "basic-754cb84d5" has successfully progressed.
reason: NewReplicaSetAvailable
status: "True"
type: Progressing
- lastTransitionTime: "2020-11-13T00:22:50Z"
lastUpdateTime: "2020-11-13T00:22:50Z"
message: Rollout has minimum availability
reason: AvailableReason
status: "True"
type: Available
- lastTransitionTime: "2020-11-13T00:40:30Z"
lastUpdateTime: "2020-11-13T00:40:30Z"
message: 'The Rollout "basic" is invalid: spec.strategy.strategy: Required value:
Rollout has missing field ''.spec.strategy.canary or .spec.strategy.blueGreen'''
reason: InvalidSpec
status: "True"
type: InvalidSpec
observedGeneration: "3"
readyReplicas: 1
replicas: 1
selector: app=basic
phase: Degraded