From 55d76f7979eba0ece6f55ad3cadd23e1fcd4a52f Mon Sep 17 00:00:00 2001 From: lorenz <stu203404@mail.uni-kiel.de> Date: Thu, 25 Feb 2021 22:17:37 +0100 Subject: [PATCH] Fix the aggregation-deployment correct + ResourceLimitPatcher --- .../patcher/ResourceLimitPatcher.kt | 22 +++--- .../yaml/aggregation-deployment.yaml | 72 +++++++++---------- 2 files changed, 49 insertions(+), 45 deletions(-) diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/ResourceLimitPatcher.kt b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/ResourceLimitPatcher.kt index 3ccc42a76..b31733e64 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/ResourceLimitPatcher.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/ResourceLimitPatcher.kt @@ -3,32 +3,36 @@ package theodolite.patcher import io.fabric8.kubernetes.api.model.KubernetesResource import io.fabric8.kubernetes.api.model.Quantity import io.fabric8.kubernetes.api.model.ResourceRequirements -import io.fabric8.kubernetes.api.model.ResourceRequirementsBuilder import io.fabric8.kubernetes.api.model.apps.Deployment -import io.fabric8.kubernetes.api.model.apps.StatefulSet -import java.lang.IllegalStateException -class ResourceLimitPatcher(private val k8sResource: KubernetesResource, private val container: String, private val variableName: String): AbstractPatcher(k8sResource, container, variableName) { +class ResourceLimitPatcher( + private val k8sResource: KubernetesResource, + private val container: String, + private val variableName: String +) : AbstractPatcher(k8sResource, container, variableName) { override fun <String> patch(value: String) { if (k8sResource is Deployment) { k8sResource.spec.template.spec.containers.filter { it.name == container }.forEach { try { + println("before: " + it.resources.limits.toString()) + println("$variableName to : $value") if (it.resources.limits.isNullOrEmpty()) { it.resources.limits = mapOf(variableName to Quantity(value as kotlin.String)) } else { - val values = it.resources.limits - println(values) - values[variableName] = Quantity(value as kotlin.String) - it.resources.limits = values + val values = Quantity(value as kotlin.String) + it.resources.limits[variableName] = values } } catch (e: IllegalStateException) { val resource = ResourceRequirements() resource.limits = mapOf(variableName to Quantity(value as kotlin.String)) it.resources = resource } + + println("after " + it.resources.limits.toString()) + } } } -} \ No newline at end of file +} diff --git a/theodolite-quarkus/src/main/resources/yaml/aggregation-deployment.yaml b/theodolite-quarkus/src/main/resources/yaml/aggregation-deployment.yaml index 07732ca1d..85fe24371 100644 --- a/theodolite-quarkus/src/main/resources/yaml/aggregation-deployment.yaml +++ b/theodolite-quarkus/src/main/resources/yaml/aggregation-deployment.yaml @@ -14,42 +14,42 @@ spec: spec: terminationGracePeriodSeconds: 0 containers: - - name: uc-application - image: uc-app:latest - ports: - - containerPort: 5555 - name: jmx - env: - - name: KAFKA_BOOTSTRAP_SERVERS - value: "my-confluent-cp-kafka:9092" - - name: SCHEMA_REGISTRY_URL - value: "http://my-confluent-cp-schema-registry:8081" - - name: JAVA_OPTS - value: "-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=5555" - - name: COMMIT_INTERVAL_MS # Set as default for the applications - value: "100" - resources: - limits: - memory: 4Gi - cpu: 1000m - - name: prometheus-jmx-exporter - image: "solsson/kafka-prometheus-jmx-exporter@sha256:6f82e2b0464f50da8104acd7363fb9b995001ddff77d248379f8788e78946143" - command: - - java - - -XX:+UnlockExperimentalVMOptions - - -XX:+UseCGroupMemoryLimitForHeap - - -XX:MaxRAMFraction=1 - - -XshowSettings:vm - - -jar - - jmx_prometheus_httpserver.jar - - "5556" - - /etc/jmx-aggregation/jmx-kafka-prometheus.yml - ports: - - containerPort: 5556 - volumeMounts: - - name: jmx-config - mountPath: /etc/jmx-aggregation + - name: uc-application + image: ghcr.io/cau-se/theodolite-uc1-kstreams-app:latest + ports: + - containerPort: 5555 + name: jmx + env: + - name: KAFKA_BOOTSTRAP_SERVERS + value: "my-confluent-cp-kafka:9092" + - name: SCHEMA_REGISTRY_URL + value: "http://my-confluent-cp-schema-registry:8081" + - name: JAVA_OPTS + value: "-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=5555" + - name: COMMIT_INTERVAL_MS # Set as default for the applications + value: "100" + resources: + limits: + memory: 4Gi + cpu: 1000m + - name: prometheus-jmx-exporter + image: "solsson/kafka-prometheus-jmx-exporter@sha256:6f82e2b0464f50da8104acd7363fb9b995001ddff77d248379f8788e78946143" + command: + - java + - -XX:+UnlockExperimentalVMOptions + - -XX:+UseCGroupMemoryLimitForHeap + - -XX:MaxRAMFraction=1 + - -XshowSettings:vm + - -jar + - jmx_prometheus_httpserver.jar + - "5556" + - /etc/jmx-aggregation/jmx-kafka-prometheus.yml + ports: + - containerPort: 5556 + volumeMounts: + - name: jmx-config + mountPath: /etc/jmx-aggregation volumes: - name: jmx-config configMap: - name: aggregation-jmx-configmap + name: aggregation-jmx-configmap \ No newline at end of file -- GitLab