-
Notifications
You must be signed in to change notification settings - Fork 190
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
Add selector.matchExtraResources into Stage API #977
Comments
# oom.yaml
apiVersion: kwok.x-k8s.io/v1alpha1
kind: Stage
metadata:
name: oom
spec:
resourceRef:
apiGroup: v1
kind: Pod
selector:
matchExpressions:
- key: .status.phase
operator: In
values:
- Running
matchExtraResources:
- resourceRef:
apiGroup: custom.metrics.k8s.io/v1beta2
kind: MetricValue
selector:
matchCEL:
- expression: |
self.metadata.name == target.metadata.name &&
self.metadata.namespace == target.metadata.namespace &&
OOM(self.spec.containers, target.spec.containers)
next:
patches:
- subresource: status
root: status
template: |
{{ $now := Now }}
{{ $root := target }}
conditions:
- lastProbeTime: null
lastTransitionTime: {{ $now | Quote }}
message: ''
reason: ''
status: "False"
type: Ready
- lastProbeTime: null
lastTransitionTime: {{ $now | Quote }}
message: ''
reason: ''
status: "True"
type: OutOfMemory
containerStatuses:
{{ range $index, $item := .spec.containers }}
{{ $origin := index $root.status.containerStatuses $index }}
- image: {{ $item.image | Quote }}
name: {{ $item.name | Quote }}
ready: false
restartCount: {{ $origin.restartCount }}
started: false
state:
terminated:
exitCode: 137
finishedAt: {{ $now | Quote }}
reason: OOMKilled
startedAt: {{ $now | Quote }}
{{ end }}
phase: Failed |
# node-image-exists.yaml
apiVersion: kwok.x-k8s.io/v1alpha1
kind: Stage
metadata:
name: node-image-exists
spec:
resourceRef:
apiGroup: v1
kind: Node
selector:
matchExtraResources:
- resourceRef:
apiGroup: v1
kind: Pod
selector:
matchExpressions:
- key: .status.phase
operator: In
values:
- Running
- ContainerCreating
next:
patches:
- subresource: status
root: status
template: |
{{ $exist := list }}
images:
{{ range .status.images }}
- names:
{{ range .names }}
{{ $exist = append $exist . }}
- {{ . | Quote }}
{{ end }}
{{ if .sizeBytes }}
sizeBytes: {{ .sizeBytes }}
{{ end }}
{{ end }}
{{ range matchExtraResources }}
{{ range .spec.containers }}
{{ if not (in $exist .image) }}
- names:
- {{ .image | Quote }}
{{ end }}
{{ end }}
{{ end }}
|
Whats the major difference between |
Trigger can be thought of as a Stage between different resources. |
Redesigning the API to put it in Stage |
Hi @wzshiming with the reference of #839 , I have figured that you planned to redesign the API instead of adding a template function to node template that would look like this
Can you guide how to achieve this trigger API? Do I have to include corresponding If YES, how can I test my changes after applying them as I have already successfully setup the KWOK project in my local system (MacOS arm64) |
What would you like to be added?
Add Trigger API allow to modify any resources
Why is this needed?
Closer to Kubelet
The text was updated successfully, but these errors were encountered: