From db221de11a98ad8150877fc9006ec153cb5d770b Mon Sep 17 00:00:00 2001 From: Salomon Popp Date: Tue, 17 Dec 2024 12:33:16 +0100 Subject: [PATCH] Add Kubernetes affinity and tolerations to streams-bootstrap v2 values (#567) --- docs/docs/schema/defaults.json | 84 +++++++++++++++++++ docs/docs/schema/pipeline.json | 56 +++++++++++++ kpops/components/streams_bootstrap_v2/base.py | 13 +++ 3 files changed, 153 insertions(+) diff --git a/docs/docs/schema/defaults.json b/docs/docs/schema/defaults.json index aef4b99f2..189f2b510 100644 --- a/docs/docs/schema/defaults.json +++ b/docs/docs/schema/defaults.json @@ -1537,6 +1537,18 @@ "additionalProperties": true, "description": "Settings specific to producers.", "properties": { + "affinity": { + "anyOf": [ + { + "$ref": "#/$defs/Affinity" + }, + { + "type": "null" + } + ], + "default": null, + "description": "Map to configure pod affinities https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity." + }, "imageTag": { "default": "latest", "description": "Docker image tag of the streams-bootstrap-v2 app.", @@ -1565,6 +1577,22 @@ } ], "description": "Kafka Streams settings" + }, + "tolerations": { + "anyOf": [ + { + "items": { + "$ref": "#/$defs/Toleration" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "description": "Array containing taint references. When defined, pods can run on nodes, which would otherwise deny scheduling.", + "title": "Tolerations" } }, "required": [ @@ -2609,6 +2637,18 @@ "additionalProperties": true, "description": "streams-bootstrap-v2 app configurations.\nThe attributes correspond to keys and values that are used as values for the streams bootstrap helm chart.", "properties": { + "affinity": { + "anyOf": [ + { + "$ref": "#/$defs/Affinity" + }, + { + "type": "null" + } + ], + "default": null, + "description": "Map to configure pod affinities https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity." + }, "autoscaling": { "anyOf": [ { @@ -2668,6 +2708,22 @@ } ], "description": "streams-bootstrap-v2 streams section" + }, + "tolerations": { + "anyOf": [ + { + "items": { + "$ref": "#/$defs/Toleration" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "description": "Array containing taint references. When defined, pods can run on nodes, which would otherwise deny scheduling.", + "title": "Tolerations" } }, "required": [ @@ -3264,6 +3320,18 @@ "additionalProperties": true, "description": "Base value class for all streams bootstrap v2 related components.", "properties": { + "affinity": { + "anyOf": [ + { + "$ref": "#/$defs/Affinity" + }, + { + "type": "null" + } + ], + "default": null, + "description": "Map to configure pod affinities https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity." + }, "imageTag": { "default": "latest", "description": "Docker image tag of the streams-bootstrap-v2 app.", @@ -3292,6 +3360,22 @@ } ], "description": "" + }, + "tolerations": { + "anyOf": [ + { + "items": { + "$ref": "#/$defs/Toleration" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "description": "Array containing taint references. When defined, pods can run on nodes, which would otherwise deny scheduling.", + "title": "Tolerations" } }, "required": [ diff --git a/docs/docs/schema/pipeline.json b/docs/docs/schema/pipeline.json index 29afa02e6..ba3865ecf 100644 --- a/docs/docs/schema/pipeline.json +++ b/docs/docs/schema/pipeline.json @@ -1197,6 +1197,18 @@ "additionalProperties": true, "description": "Settings specific to producers.", "properties": { + "affinity": { + "anyOf": [ + { + "$ref": "#/$defs/Affinity" + }, + { + "type": "null" + } + ], + "default": null, + "description": "Map to configure pod affinities https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity." + }, "imageTag": { "default": "latest", "description": "Docker image tag of the streams-bootstrap-v2 app.", @@ -1225,6 +1237,22 @@ } ], "description": "Kafka Streams settings" + }, + "tolerations": { + "anyOf": [ + { + "items": { + "$ref": "#/$defs/Toleration" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "description": "Array containing taint references. When defined, pods can run on nodes, which would otherwise deny scheduling.", + "title": "Tolerations" } }, "required": [ @@ -2269,6 +2297,18 @@ "additionalProperties": true, "description": "streams-bootstrap-v2 app configurations.\nThe attributes correspond to keys and values that are used as values for the streams bootstrap helm chart.", "properties": { + "affinity": { + "anyOf": [ + { + "$ref": "#/$defs/Affinity" + }, + { + "type": "null" + } + ], + "default": null, + "description": "Map to configure pod affinities https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity." + }, "autoscaling": { "anyOf": [ { @@ -2328,6 +2368,22 @@ } ], "description": "streams-bootstrap-v2 streams section" + }, + "tolerations": { + "anyOf": [ + { + "items": { + "$ref": "#/$defs/Toleration" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "description": "Array containing taint references. When defined, pods can run on nodes, which would otherwise deny scheduling.", + "title": "Tolerations" } }, "required": [ diff --git a/kpops/components/streams_bootstrap_v2/base.py b/kpops/components/streams_bootstrap_v2/base.py index 95f3281e2..27fc1e9b6 100644 --- a/kpops/components/streams_bootstrap_v2/base.py +++ b/kpops/components/streams_bootstrap_v2/base.py @@ -11,6 +11,7 @@ from kpops.component_handlers.helm_wrapper.model import HelmRepoConfig from kpops.components.base_components import KafkaApp from kpops.components.base_components.helm_app import HelmApp, HelmAppValues +from kpops.components.common.kubernetes_model import Affinity, Toleration from kpops.components.common.topic import KafkaTopic, KafkaTopicStr from kpops.utils.docstring import describe_attr from kpops.utils.pydantic import ( @@ -100,6 +101,8 @@ class StreamsBootstrapV2Values(HelmAppValues): """Base value class for all streams bootstrap v2 related components. :param image_tag: Docker image tag of the streams-bootstrap-v2 app. + :param affinity: Map to configure pod affinities https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity. + :param tolerations: Array containing taint references. When defined, pods can run on nodes, which would otherwise deny scheduling. """ image_tag: str = Field( @@ -112,6 +115,16 @@ class StreamsBootstrapV2Values(HelmAppValues): description=describe_attr("streams", __doc__), ) + affinity: Affinity | None = Field( + default=None, + description=describe_attr("affinity", __doc__), + ) + + tolerations: list[Toleration] | None = Field( + default=None, + description=describe_attr("tolerations", __doc__), + ) + @deprecated("StreamsBootstrapV2 component is deprecated, use StreamsBootstrap instead.") class StreamsBootstrapV2(KafkaApp, HelmApp, ABC):