generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1159 from wzshiming/feat/node-not-ready-stage
Add node not ready stage
- Loading branch information
Showing
3 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
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,61 @@ | ||
apiVersion: kwok.x-k8s.io/v1alpha1 | ||
kind: Stage | ||
metadata: | ||
name: node-not-ready | ||
spec: | ||
resourceRef: | ||
apiGroup: v1 | ||
kind: Node | ||
selector: | ||
matchExpressions: | ||
- key: '.metadata.labels["node-not-ready.stage.kwok.x-k8s.io"]' | ||
operator: 'In' | ||
values: | ||
- 'true' | ||
- key: '.status.phase' | ||
operator: 'In' | ||
values: | ||
- 'Running' | ||
delay: | ||
durationMilliseconds: 1000 | ||
durationFrom: | ||
expressionFrom: '.metadata.annotations["node-not-ready.stage.kwok.x-k8s.io/delay"]' | ||
jitterDurationMilliseconds: 1000 | ||
jitterDurationFrom: | ||
expressionFrom: '.metadata.annotations["node-not-ready.stage.kwok.x-k8s.io/jitter-delay"]' | ||
weight: 10000 | ||
next: | ||
statusTemplate: | | ||
{{ $now := Now }} | ||
{{ $defaultReason := "nodeFailed" }} | ||
{{ $defaultMessage := "node failed" }} | ||
{{ $annotations := or .metadata.annotations dict }} | ||
{{ $failureType := or ( index $annotations "node-not-ready.stage.kwok.x-k8s.io/type" ) "" }} | ||
{{ $failureReason := or ( index $annotations "node-not-ready.stage.kwok.x-k8s.io/reason" ) $defaultReason }} | ||
{{ $failureMessage := or ( index $annotations "node-not-ready.stage.kwok.x-k8s.io/message" ) $defaultMessage }} | ||
{{ $lastTransitionTime := or .metadata.creationTimestamp $now }} | ||
conditions: | ||
{{ range NodeConditions }} | ||
{{ if eq .type "Ready" }} | ||
- lastHeartbeatTime: {{ $now | Quote }} | ||
lastTransitionTime: {{ $lastTransitionTime | Quote }} | ||
message: {{ $failureMessage | Quote }} | ||
reason: {{ $failureReason | Quote }} | ||
status: "False" | ||
type: {{ .type | Quote}} | ||
{{ else if eq .type $failureType }} | ||
- lastHeartbeatTime: {{ $now | Quote }} | ||
lastTransitionTime: {{ $lastTransitionTime | Quote }} | ||
message: {{ $failureMessage | Quote }} | ||
reason: {{ $failureReason | Quote }} | ||
status: "True" | ||
type: {{ .type | Quote}} | ||
{{ else }} | ||
- lastHeartbeatTime: {{ $now | Quote }} | ||
lastTransitionTime: {{ $lastTransitionTime | Quote }} | ||
message: {{ .message | Quote }} | ||
reason: {{ .reason | Quote }} | ||
status: {{ .status | Quote }} | ||
type: {{ .type | Quote}} | ||
{{ end }} | ||
{{ end }} |
11 changes: 11 additions & 0 deletions
11
kustomize/stage/node/chaos/testdata/node-not-ready.input.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,11 @@ | ||
# @Stage: ../node-not-ready.yaml | ||
apiVersion: v1 | ||
kind: Node | ||
metadata: | ||
name: node-not-ready | ||
labels: | ||
node-not-ready.stage.kwok.x-k8s.io: "true" | ||
annotations: | ||
node-not-ready.stage.kwok.x-k8s.io/type: NetworkUnavailable | ||
status: | ||
phase: Running |
44 changes: 44 additions & 0 deletions
44
kustomize/stage/node/chaos/testdata/node-not-ready.output.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,44 @@ | ||
apiGroup: v1 | ||
kind: Node | ||
name: node-not-ready | ||
stages: | ||
- delay: 1000000000 | ||
next: | ||
- data: | ||
status: | ||
conditions: | ||
- lastHeartbeatTime: <Now> | ||
lastTransitionTime: <Now> | ||
message: node failed | ||
reason: nodeFailed | ||
status: "False" | ||
type: Ready | ||
- lastHeartbeatTime: <Now> | ||
lastTransitionTime: <Now> | ||
message: kubelet has sufficient memory available | ||
reason: KubeletHasSufficientMemory | ||
status: "False" | ||
type: MemoryPressure | ||
- lastHeartbeatTime: <Now> | ||
lastTransitionTime: <Now> | ||
message: kubelet has no disk pressure | ||
reason: KubeletHasNoDiskPressure | ||
status: "False" | ||
type: DiskPressure | ||
- lastHeartbeatTime: <Now> | ||
lastTransitionTime: <Now> | ||
message: kubelet has sufficient PID available | ||
reason: KubeletHasSufficientPID | ||
status: "False" | ||
type: PIDPressure | ||
- lastHeartbeatTime: <Now> | ||
lastTransitionTime: <Now> | ||
message: node failed | ||
reason: nodeFailed | ||
status: "True" | ||
type: NetworkUnavailable | ||
kind: patch | ||
subresource: status | ||
type: application/merge-patch+json | ||
stage: node-not-ready | ||
weight: 10000 |