Skip to content

Commit 672a8b1

Browse files
committed
feat(api): add Tolerations field to ImpVMSpec and ImpVMClassSpec
1 parent ef44d6c commit 672a8b1

4 files changed

Lines changed: 102 additions & 1 deletion

File tree

api/v1alpha1/impvm_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ type ImpVMSpec struct {
6464
// +optional
6565
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
6666

67+
// Tolerations allow this VM to be scheduled onto nodes with matching taints.
68+
// Class tolerations are merged (additive union) with VM tolerations at schedule time.
69+
// Same semantics as Pod.spec.tolerations.
70+
// +optional
71+
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
72+
6773
// Env sets environment variables inside the VM via the guest agent.
6874
// +optional
6975
Env []corev1.EnvVar `json:"env,omitempty"`

api/v1alpha1/impvmclass_types.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package v1alpha1
22

3-
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3+
import (
4+
corev1 "k8s.io/api/core/v1"
5+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
6+
)
47

58
// ImpVMClassSpec defines compute resources for a class of VMs.
69
// All ImpVMs and ImpVMTemplates referencing this class inherit these values.
@@ -35,6 +38,12 @@ type ImpVMClassSpec struct {
3538
// RestartPolicy configures automatic restart for persistent VMs using this class.
3639
// +optional
3740
RestartPolicy *RestartPolicy `json:"restartPolicy,omitempty"`
41+
42+
// Tolerations specify tolerations inherited by all VMs of this class.
43+
// Merged additively with per-VM tolerations at schedule time.
44+
// Same semantics as Pod.spec.tolerations.
45+
// +optional
46+
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
3847
}
3948

4049
// +kubebuilder:object:root=true

config/crd/bases/imp.dev_impvmclasses.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,49 @@ spec:
307307
- cool-down
308308
type: string
309309
type: object
310+
tolerations:
311+
description: |-
312+
Tolerations specify tolerations inherited by all VMs of this class.
313+
Merged additively with per-VM tolerations at schedule time.
314+
Same semantics as Pod.spec.tolerations.
315+
items:
316+
description: |-
317+
The pod this Toleration is attached to tolerates any taint that matches
318+
the triple <key,value,effect> using the matching operator <operator>.
319+
properties:
320+
effect:
321+
description: |-
322+
Effect indicates the taint effect to match. Empty means match all taint effects.
323+
When specified, allowed values are NoSchedule, PreferNoSchedule and NoExecute.
324+
type: string
325+
key:
326+
description: |-
327+
Key is the taint key that the toleration applies to. Empty means match all taint keys.
328+
If the key is empty, operator must be Exists; this combination means to match all values and all keys.
329+
type: string
330+
operator:
331+
description: |-
332+
Operator represents a key's relationship to the value.
333+
Valid operators are Exists, Equal, Lt, and Gt. Defaults to Equal.
334+
Exists is equivalent to wildcard for value, so that a pod can
335+
tolerate all taints of a particular category.
336+
Lt and Gt perform numeric comparisons (requires feature gate TaintTolerationComparisonOperators).
337+
type: string
338+
tolerationSeconds:
339+
description: |-
340+
TolerationSeconds represents the period of time the toleration (which must be
341+
of effect NoExecute, otherwise this field is ignored) tolerates the taint. By default,
342+
it is not set, which means tolerate the taint forever (do not evict). Zero and
343+
negative values will be treated as 0 (evict immediately) by the system.
344+
format: int64
345+
type: integer
346+
value:
347+
description: |-
348+
Value is the taint value the toleration matches to.
349+
If the operator is Exists, the value should be empty, otherwise just a regular string.
350+
type: string
351+
type: object
352+
type: array
310353
vcpu:
311354
description: VCPU is the number of virtual CPUs allocated to each
312355
VM.

config/crd/bases/imp.dev_impvms.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,49 @@ spec:
570570
required:
571571
- name
572572
type: object
573+
tolerations:
574+
description: |-
575+
Tolerations allow this VM to be scheduled onto nodes with matching taints.
576+
Class tolerations are merged (additive union) with VM tolerations at schedule time.
577+
Same semantics as Pod.spec.tolerations.
578+
items:
579+
description: |-
580+
The pod this Toleration is attached to tolerates any taint that matches
581+
the triple <key,value,effect> using the matching operator <operator>.
582+
properties:
583+
effect:
584+
description: |-
585+
Effect indicates the taint effect to match. Empty means match all taint effects.
586+
When specified, allowed values are NoSchedule, PreferNoSchedule and NoExecute.
587+
type: string
588+
key:
589+
description: |-
590+
Key is the taint key that the toleration applies to. Empty means match all taint keys.
591+
If the key is empty, operator must be Exists; this combination means to match all values and all keys.
592+
type: string
593+
operator:
594+
description: |-
595+
Operator represents a key's relationship to the value.
596+
Valid operators are Exists, Equal, Lt, and Gt. Defaults to Equal.
597+
Exists is equivalent to wildcard for value, so that a pod can
598+
tolerate all taints of a particular category.
599+
Lt and Gt perform numeric comparisons (requires feature gate TaintTolerationComparisonOperators).
600+
type: string
601+
tolerationSeconds:
602+
description: |-
603+
TolerationSeconds represents the period of time the toleration (which must be
604+
of effect NoExecute, otherwise this field is ignored) tolerates the taint. By default,
605+
it is not set, which means tolerate the taint forever (do not evict). Zero and
606+
negative values will be treated as 0 (evict immediately) by the system.
607+
format: int64
608+
type: integer
609+
value:
610+
description: |-
611+
Value is the taint value the toleration matches to.
612+
If the operator is Exists, the value should be empty, otherwise just a regular string.
613+
type: string
614+
type: object
615+
type: array
573616
userData:
574617
description: |-
575618
UserData is an optional cloud-init user-data payload. Off by default;

0 commit comments

Comments
 (0)