From 147887b8cfee81224eb2b02ec7887d11dd916747 Mon Sep 17 00:00:00 2001 From: Steve Hawkins Date: Thu, 3 Nov 2022 08:13:05 -0400 Subject: [PATCH] MGDSTRM-10039 elevating the priority of the kafka broker and zk pods --- .../operator/managers/OperandOverrideManager.java | 7 +++++++ .../java/org/bf2/operator/operands/KafkaCluster.java | 10 ++++++++++ operator/src/main/kubernetes/kubernetes.yml | 9 +++++++++ .../resources/instances/standard-dynamic.properties | 2 +- .../org/bf2/operator/operands/KafkaClusterTest.java | 12 ++++++++++++ 5 files changed, 39 insertions(+), 1 deletion(-) diff --git a/operator/src/main/java/org/bf2/operator/managers/OperandOverrideManager.java b/operator/src/main/java/org/bf2/operator/managers/OperandOverrideManager.java index 8d3d661ec..85b1d51cc 100644 --- a/operator/src/main/java/org/bf2/operator/managers/OperandOverrideManager.java +++ b/operator/src/main/java/org/bf2/operator/managers/OperandOverrideManager.java @@ -122,6 +122,9 @@ public static class OperandOverrides { @JsonProperty(value = "dynamic-scaling-scheduling") public boolean dynamicScalingScheduling; + + @JsonProperty(value = "elevate-priority") + public boolean elevatePriority; } static final OperandOverrides EMPTY = new OperandOverrides(); @@ -245,6 +248,10 @@ public boolean useDynamicScalingScheduling(String strimzi) { return getOverrides(strimzi).dynamicScalingScheduling; } + public boolean useElevatedPriority(String strimzi) { + return getOverrides(strimzi).elevatePriority; + } + public boolean migratedToDynamicScalingScheduling() { return overrides.values().stream().allMatch(o -> o.dynamicScalingScheduling); } diff --git a/operator/src/main/java/org/bf2/operator/operands/KafkaCluster.java b/operator/src/main/java/org/bf2/operator/operands/KafkaCluster.java index fbddc78ae..9d5c5995b 100644 --- a/operator/src/main/java/org/bf2/operator/operands/KafkaCluster.java +++ b/operator/src/main/java/org/bf2/operator/operands/KafkaCluster.java @@ -106,6 +106,8 @@ @DefaultBean public class KafkaCluster extends AbstractKafkaCluster { + private static final String KAS_FLEETSHARD_MEDIUM_PRIORITY = "kas-fleetshard-medium"; + private static final String CRUISECONTROL_SUFFIX = "-cruisecontrol"; private static final String ZOOKEEPER_SUFFIX = "-zookeeper"; @@ -487,6 +489,10 @@ private KafkaClusterTemplate buildKafkaTemplate(ManagedKafka managedKafka, int r // some of them will have ZK, admin-server, canary and broker needs to be on its own podTemplateBuilder.addToTolerations(buildKafkaBrokerToleration()); + if (overrideManager.useElevatedPriority(strimzi)) { + podTemplateBuilder.withPriorityClassName(KAS_FLEETSHARD_MEDIUM_PRIORITY); + } + podTemplateBuilder.addAllToTolerations(OperandUtils.profileTolerations(managedKafka, this.informerManager.getLocalAgent(), dynamicScalingScheduling)); if (replicas == 1) { @@ -574,6 +580,10 @@ private ZookeeperClusterTemplate buildZookeeperTemplate(ManagedKafka managedKafk boolean dynamicScalingScheduling = overrideManager.useDynamicScalingScheduling(strimzi); podNestedBuilder.addAllToTolerations(OperandUtils.profileTolerations(managedKafka, informerManager.getLocalAgent(), dynamicScalingScheduling)); + if (overrideManager.useElevatedPriority(strimzi)) { + podNestedBuilder.withPriorityClassName(KAS_FLEETSHARD_MEDIUM_PRIORITY); + } + if (addAffinity) { podNestedBuilder.withAffinity(affinityBuilder.build()); } diff --git a/operator/src/main/kubernetes/kubernetes.yml b/operator/src/main/kubernetes/kubernetes.yml index 2f9f1b09e..92b4ef566 100644 --- a/operator/src/main/kubernetes/kubernetes.yml +++ b/operator/src/main/kubernetes/kubernetes.yml @@ -254,4 +254,13 @@ metadata: name: kas-fleetshard-reservation value: -4 globalDefault: false +description: "Used for reservation deployments" +--- +apiVersion: scheduling.k8s.io/v1 +kind: PriorityClass +metadata: + name: kas-fleetshard-medium +value: 100 +globalDefault: false +description: "Slightly elevated above the default, and well below the kas-fleetshard-high." --- diff --git a/operator/src/main/resources/instances/standard-dynamic.properties b/operator/src/main/resources/instances/standard-dynamic.properties index 460f21f2e..d69a53b18 100644 --- a/operator/src/main/resources/instances/standard-dynamic.properties +++ b/operator/src/main/resources/instances/standard-dynamic.properties @@ -4,4 +4,4 @@ adminserver.container-request-cpu=100m zookeeper.container-request-cpu=100m cruisecontrol.container-request-cpu=100m kafka.container-cpu=3200m -kafka.container-request-cpu=3100m +kafka.container-request-cpu=2900m diff --git a/operator/src/test/java/org/bf2/operator/operands/KafkaClusterTest.java b/operator/src/test/java/org/bf2/operator/operands/KafkaClusterTest.java index 285b4add4..ed240b4e5 100644 --- a/operator/src/test/java/org/bf2/operator/operands/KafkaClusterTest.java +++ b/operator/src/test/java/org/bf2/operator/operands/KafkaClusterTest.java @@ -216,6 +216,18 @@ private void alternativeConfig(Consumer configModifi QuarkusMock.installMockForType(mock, KafkaInstanceConfigurations.class); } + @Test + void testElevatedPriority() throws IOException { + final ManagedKafka managedKafka = exampleManagedKafka("2Ti"); + + Mockito.when(overrideManager.useElevatedPriority(Mockito.anyString())).thenReturn(true); + + Kafka kafka = kafkaCluster.kafkaFrom(managedKafka, null); + + assertEquals("kas-fleetshard-core", kafka.getSpec().getKafka().getTemplate().getPod().getPriorityClassName()); + assertEquals("kas-fleetshard-core", kafka.getSpec().getZookeeper().getTemplate().getPod().getPriorityClassName()); + } + @Test void testNodeAffinity() throws IOException { final ManagedKafka managedKafka = exampleManagedKafka("2Ti");