Skip to content

Commit

Permalink
Add support for pod tolerations (#650)
Browse files Browse the repository at this point in the history
* Add support for pod tolerations

* Generated changes

* Minor tweaks

* Review comments

* Bundle changes
  • Loading branch information
idlewis authored Aug 23, 2024
1 parent 131b063 commit f0681bd
Show file tree
Hide file tree
Showing 10 changed files with 188 additions and 1 deletion.
9 changes: 9 additions & 0 deletions api/v1/runtimecomponent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ type RuntimeComponentSpec struct {
// Disable information about services being injected into the application pod's environment variables. Default to false.
// +operator-sdk:csv:customresourcedefinitions:order=27,type=spec,displayName="Disable Service Links",xDescriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch"
DisableServiceLinks *bool `json:"disableServiceLinks,omitempty"`

// Tolerations to be added to application pods. Tolerations allow the scheduler to schedule pods on nodes with matching taints.
// +operator-sdk:csv:customresourcedefinitions:order=28,type=spec,displayName="Tolerations"
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
}

// Defines the topology spread constraints
Expand Down Expand Up @@ -513,6 +517,11 @@ func (cr *RuntimeComponent) GetPullSecret() *string {
return cr.Spec.PullSecret
}

// GetToleration returns pod tolerations slice
func (cr *RuntimeComponent) GetTolerations() []corev1.Toleration {
return cr.Spec.Tolerations
}

// GetServiceAccountName returns service account name
func (cr *RuntimeComponent) GetServiceAccountName() *string {
return cr.Spec.ServiceAccountName
Expand Down
7 changes: 7 additions & 0 deletions api/v1/zz_generated.deepcopy.go

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

40 changes: 40 additions & 0 deletions bundle/manifests/rc.app.stacks_runtimecomponents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5602,6 +5602,46 @@ spec:
type: string
type: object
type: object
tolerations:
description: Tolerations to be added to application pods. Tolerations
allow the scheduler to schedule pods on nodes with matching taints.
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
topologySpreadConstraints:
description: Defines the topology spread constraints
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ metadata:
categories: Application Runtime
certified: "true"
containerImage: icr.io/appcafe/runtime-component-operator:daily
createdAt: "2024-08-01T20:26:42Z"
createdAt: "2024-08-23T13:51:42Z"
description: Deploys any runtime component with dynamic and auto-tuning configuration
features.operators.openshift.io/disconnected: "true"
features.operators.openshift.io/fips-compliant: "true"
Expand Down Expand Up @@ -382,6 +382,10 @@ spec:
path: statefulSet.storage.volumeClaimTemplate
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:PersistentVolumeClaim
- description: Tolerations to be added to application pods. Tolerations allow
the scheduler to schedule pods on nodes with matching taints.
displayName: Tolerations
path: tolerations
- description: Labels to set on ServiceMonitor.
displayName: Monitoring Labels
path: monitoring.labels
Expand Down
1 change: 1 addition & 0 deletions common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,5 @@ type BaseComponent interface {
GetSecurityContext() *corev1.SecurityContext
GetManageTLS() *bool
GetDisableServiceLinks() *bool
GetTolerations() []corev1.Toleration
}
40 changes: 40 additions & 0 deletions config/crd/bases/rc.app.stacks_runtimecomponents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5598,6 +5598,46 @@ spec:
type: string
type: object
type: object
tolerations:
description: Tolerations to be added to application pods. Tolerations
allow the scheduler to schedule pods on nodes with matching taints.
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
topologySpreadConstraints:
description: Defines the topology spread constraints
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ spec:
path: statefulSet.storage.volumeClaimTemplate
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:PersistentVolumeClaim
- description: Tolerations to be added to application pods. Tolerations allow
the scheduler to schedule pods on nodes with matching taints.
displayName: Tolerations
path: tolerations
- description: Labels to set on ServiceMonitor.
displayName: Monitoring Labels
path: monitoring.labels
Expand Down
40 changes: 40 additions & 0 deletions internal/deploy/kubectl/runtime-component-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5601,6 +5601,46 @@ spec:
type: string
type: object
type: object
tolerations:
description: Tolerations to be added to application pods. Tolerations
allow the scheduler to schedule pods on nodes with matching taints.
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
topologySpreadConstraints:
description: Defines the topology spread constraints
properties:
Expand Down
40 changes: 40 additions & 0 deletions internal/deploy/kustomize/daily/base/runtime-component-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5601,6 +5601,46 @@ spec:
type: string
type: object
type: object
tolerations:
description: Tolerations to be added to application pods. Tolerations
allow the scheduler to schedule pods on nodes with matching taints.
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
topologySpreadConstraints:
description: Defines the topology spread constraints
properties:
Expand Down
2 changes: 2 additions & 0 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,8 @@ func CustomizePodSpec(pts *corev1.PodTemplateSpec, ba common.BaseComponent) {
} else {
pts.Spec.EnableServiceLinks = nil
}

pts.Spec.Tolerations = ba.GetTolerations()
}

// Initialize an empty TopologySpreadConstraints list and optionally prefers scheduling across zones/hosts for pods with podMatchLabels
Expand Down

0 comments on commit f0681bd

Please sign in to comment.