Skip to content

Commit

Permalink
MGDSTRM-10039 elevating the priority of the kafka broker and zk pods
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Nov 7, 2022
1 parent caa603d commit 147887b
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
Expand Down
10 changes: 10 additions & 0 deletions operator/src/main/java/org/bf2/operator/operands/KafkaCluster.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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());
}
Expand Down
9 changes: 9 additions & 0 deletions operator/src/main/kubernetes/kubernetes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
---
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,18 @@ private void alternativeConfig(Consumer<KafkaInstanceConfiguration> 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");
Expand Down

0 comments on commit 147887b

Please # to comment.