diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/NodeSelectorPatcher.kt b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/NodeSelectorPatcher.kt new file mode 100644 index 0000000000000000000000000000000000000000..b6d75eb801e12a0be07254f0578c9ca6b0463061 --- /dev/null +++ b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/NodeSelectorPatcher.kt @@ -0,0 +1,13 @@ +package theodolite.patcher + +import io.fabric8.kubernetes.api.model.KubernetesResource +import io.fabric8.kubernetes.api.model.Service +import io.fabric8.kubernetes.api.model.apps.Deployment + +class NodeSelectorPatcher(private val k8sResource: KubernetesResource, private val variableName: String): AbstractPatcher(k8sResource, variableName){ + override fun <String> patch(value: String) { + if (k8sResource is Deployment) { + k8sResource.spec.template.spec.nodeSelector = mapOf(variableName to value as kotlin.String) + } + } +} \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/PatcherManager.kt b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/PatcherManager.kt index f7875cf397fc746a8d8ab17f9df62cd73b6a63d4..b3a63e2adb58b42b90131d76160d7842f86cc019 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/PatcherManager.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/PatcherManager.kt @@ -12,6 +12,8 @@ class PatcherManager { "EnvVarPatcher" -> EnvVarPatcher(k8sResources.filter { it.first == patcherDefinition.resource}.map { resource -> resource.second }[0], patcherDefinition.container, patcherDefinition.variableName) + "NodeSelectorPatcher" -> NodeSelectorPatcher(k8sResources.filter { it.first == patcherDefinition.resource }.map { resource -> resource.second }[0], + patcherDefinition.variableName) else -> throw IllegalArgumentException("Patcher type ${patcherDefinition.type} not found") } } diff --git a/theodolite-quarkus/src/main/resources/yaml/testContext.yaml b/theodolite-quarkus/src/main/resources/yaml/testContext.yaml index 289d15bbe40d77818a3bf22ecac18e4d00754767..13c0ae3756b1955beba5ae9073d542badcb314bc 100644 --- a/theodolite-quarkus/src/main/resources/yaml/testContext.yaml +++ b/theodolite-quarkus/src/main/resources/yaml/testContext.yaml @@ -29,4 +29,16 @@ configOverrides: container: "workload-generator" variableName: "KAFKA_SERVER" value: "localhost:9192" + - patcher: + type: "NodeSelectorPatcher" + resource: "workloadGenerator.yaml" + variableName: "env" + value: "prod" + - patcher: + type: "NodeSelectorPatcher" + resource: "aggregation-deployment.yaml" + variableName: "env" + value: "prod" + +