Skip to content
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 configuration for setting tolerations on service pods #1676

Merged
merged 1 commit into from
May 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion assemblyline/odm/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,19 @@ class Mount(odm.Model):
"& `resource_key` fields to mount ConfigMaps")


KUBERNETES_TOLERATION_OPS = ['Exists', 'Equal']
KUBERNETES_TOLERATION_EFFECTS = ['NoSchedule', 'PreferNoSchedule', 'NoExecute']

@odm.model(index=False, store=False, description="Limit a set of kubernetes objects based on a label query.")
class Toleration(odm.Model):
key = odm.Optional(odm.Keyword(), description="The taint key that the toleration applies to")
operator = odm.Enum(values=KUBERNETES_TOLERATION_OPS,
default="Equal", description="Relationship between taint key and value")
value = odm.Optional(odm.Keyword(), description="Taint value the toleration matches to")
effect = odm.Optional(odm.Enum(KUBERNETES_TOLERATION_EFFECTS), description="The taint effect to match.")
toleration_seconds = odm.Optional(odm.Integer(min=0),
description="The period of time the toleration tolerates the taint")

@odm.model(index=False, store=False,
description="A set of default values to be used running a service when no other value is set")
class ScalerServiceDefaults(odm.Model):
Expand All @@ -670,6 +683,9 @@ class ScalerServiceDefaults(odm.Model):
description="Environment variables to pass onto services")
mounts: List[Mount] = odm.List(odm.Compound(Mount), default=[],
description="A list of volume mounts for every service")
tolerations: List[Toleration] = odm.List(odm.Compound(Toleration), default=[],
description="Toleration to apply to service pods.\n"
"Reference: https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/")


# The operations we support for label and field selectors are based on the common subset of
Expand All @@ -688,7 +704,6 @@ class FieldSelector(odm.Model):
# Excluded from this list is Gt and Lt for above reason
KUBERNETES_LABEL_OPS = ['In', 'NotIn', 'Exists', 'DoesNotExist']


@odm.model(index=False, store=False, description="Limit a set of kubernetes objects based on a label query.")
class LabelSelector(odm.Model):
key = odm.keyword(description="Name of label to select on.")
Expand Down