Skip to content

Commit

Permalink
Fixing toleration implementation (#1316)
Browse files Browse the repository at this point in the history
In current implementation, tolerations are stored in the ModuleConfig of
the NMC. That means that on each update of Tolerations, kernel module
will be unloaded/loaded, which is undesirable.
In this PR, the tolerations are moved into ModuleItem, along with Name,
Namespace,Service Account and PullSecret, since it does not affect the
kernel module code, but just the way the worker pod is configured to
run. This way, tolerations can be changed in whatever way possible,
without affecting the loaded kernel modules
  • Loading branch information
yevgeny-shnaidman authored Jan 30, 2025
1 parent 1258f4b commit 56b7a30
Show file tree
Hide file tree
Showing 9 changed files with 211 additions and 164 deletions.
5 changes: 3 additions & 2 deletions api/v1beta1/nodemodulesconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,16 @@ type ModuleConfig struct {
//+optional
InTreeModuleToRemove string `json:"inTreeModuleToRemove,omitempty"`
Modprobe ModprobeSpec `json:"modprobe"`
//+optional
Tolerations []v1.Toleration `json:"tolerations,omitempty"`
}

type ModuleItem struct {
ImageRepoSecret *v1.LocalObjectReference `json:"imageRepoSecret,omitempty"`
Name string `json:"name"`
Namespace string `json:"namespace"`
ServiceAccountName string `json:"serviceAccountName"`
//+optional
// tolerations define which tolerations should be added for every load/unload pod running on the node
Tolerations []v1.Toleration `json:"tolerations,omitempty"`
}

type NodeModuleSpec struct {
Expand Down
14 changes: 7 additions & 7 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

156 changes: 80 additions & 76 deletions bundle/manifests/kmm.sigs.x-k8s.io_nodemodulesconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,44 +158,6 @@ spec:
type: array
type: object
type: object
tolerations:
items:
description: |-
The pod this Toleration is attached to tolerates any taint that matches
the triple <key,value,effect> using the matching operator <operator>.
properties:
effect:
description: |-
Effect indicates the taint effect to match. Empty means match all taint effects.
When specified, allowed values are NoSchedule, PreferNoSchedule and NoExecute.
type: string
key:
description: |-
Key is the taint key that the toleration applies to. Empty means match all taint keys.
If the key is empty, operator must be Exists; this combination means to match all values and all keys.
type: string
operator:
description: |-
Operator represents a key's relationship to the value.
Valid operators are Exists and Equal. Defaults to Equal.
Exists is equivalent to wildcard for value, so that a pod can
tolerate all taints of a particular category.
type: string
tolerationSeconds:
description: |-
TolerationSeconds represents the period of time the toleration (which must be
of effect NoExecute, otherwise this field is ignored) tolerates the taint. By default,
it is not set, which means tolerate the taint forever (do not evict). Zero and
negative values will be treated as 0 (evict immediately) by the system.
format: int64
type: integer
value:
description: |-
Value is the taint value the toleration matches to.
If the operator is Exists, the value should be empty, otherwise just a regular string.
type: string
type: object
type: array
required:
- containerImage
- insecurePull
Expand Down Expand Up @@ -224,6 +186,46 @@ spec:
type: string
serviceAccountName:
type: string
tolerations:
description: tolerations define which tolerations should be
added for every load/unload pod running on the node
items:
description: |-
The pod this Toleration is attached to tolerates any taint that matches
the triple <key,value,effect> using the matching operator <operator>.
properties:
effect:
description: |-
Effect indicates the taint effect to match. Empty means match all taint effects.
When specified, allowed values are NoSchedule, PreferNoSchedule and NoExecute.
type: string
key:
description: |-
Key is the taint key that the toleration applies to. Empty means match all taint keys.
If the key is empty, operator must be Exists; this combination means to match all values and all keys.
type: string
operator:
description: |-
Operator represents a key's relationship to the value.
Valid operators are Exists and Equal. Defaults to Equal.
Exists is equivalent to wildcard for value, so that a pod can
tolerate all taints of a particular category.
type: string
tolerationSeconds:
description: |-
TolerationSeconds represents the period of time the toleration (which must be
of effect NoExecute, otherwise this field is ignored) tolerates the taint. By default,
it is not set, which means tolerate the taint forever (do not evict). Zero and
negative values will be treated as 0 (evict immediately) by the system.
format: int64
type: integer
value:
description: |-
Value is the taint value the toleration matches to.
If the operator is Exists, the value should be empty, otherwise just a regular string.
type: string
type: object
type: array
required:
- config
- name
Expand Down Expand Up @@ -347,44 +349,6 @@ spec:
type: array
type: object
type: object
tolerations:
items:
description: |-
The pod this Toleration is attached to tolerates any taint that matches
the triple <key,value,effect> using the matching operator <operator>.
properties:
effect:
description: |-
Effect indicates the taint effect to match. Empty means match all taint effects.
When specified, allowed values are NoSchedule, PreferNoSchedule and NoExecute.
type: string
key:
description: |-
Key is the taint key that the toleration applies to. Empty means match all taint keys.
If the key is empty, operator must be Exists; this combination means to match all values and all keys.
type: string
operator:
description: |-
Operator represents a key's relationship to the value.
Valid operators are Exists and Equal. Defaults to Equal.
Exists is equivalent to wildcard for value, so that a pod can
tolerate all taints of a particular category.
type: string
tolerationSeconds:
description: |-
TolerationSeconds represents the period of time the toleration (which must be
of effect NoExecute, otherwise this field is ignored) tolerates the taint. By default,
it is not set, which means tolerate the taint forever (do not evict). Zero and
negative values will be treated as 0 (evict immediately) by the system.
format: int64
type: integer
value:
description: |-
Value is the taint value the toleration matches to.
If the operator is Exists, the value should be empty, otherwise just a regular string.
type: string
type: object
type: array
required:
- containerImage
- insecurePull
Expand Down Expand Up @@ -416,6 +380,46 @@ spec:
type: string
serviceAccountName:
type: string
tolerations:
description: tolerations define which tolerations should be
added for every load/unload pod running on the node
items:
description: |-
The pod this Toleration is attached to tolerates any taint that matches
the triple <key,value,effect> using the matching operator <operator>.
properties:
effect:
description: |-
Effect indicates the taint effect to match. Empty means match all taint effects.
When specified, allowed values are NoSchedule, PreferNoSchedule and NoExecute.
type: string
key:
description: |-
Key is the taint key that the toleration applies to. Empty means match all taint keys.
If the key is empty, operator must be Exists; this combination means to match all values and all keys.
type: string
operator:
description: |-
Operator represents a key's relationship to the value.
Valid operators are Exists and Equal. Defaults to Equal.
Exists is equivalent to wildcard for value, so that a pod can
tolerate all taints of a particular category.
type: string
tolerationSeconds:
description: |-
TolerationSeconds represents the period of time the toleration (which must be
of effect NoExecute, otherwise this field is ignored) tolerates the taint. By default,
it is not set, which means tolerate the taint forever (do not evict). Zero and
negative values will be treated as 0 (evict immediately) by the system.
format: int64
type: integer
value:
description: |-
Value is the taint value the toleration matches to.
If the operator is Exists, the value should be empty, otherwise just a regular string.
type: string
type: object
type: array
required:
- name
- namespace
Expand Down
Loading

0 comments on commit 56b7a30

Please sign in to comment.