use of org.bf2.operator.resources.v1alpha1.ManagedKafka in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class IngressControllerManagerTest method testReplicaReduction.
@Test
public void testReplicaReduction() {
openShiftClient.resourceList((List) buildNodes(12)).createOrReplace();
IntStream.range(0, 6).forEach(i -> {
ManagedKafka mk = ManagedKafka.getDummyInstance(1);
mk.getMetadata().setName("ingressTest" + i);
mk.getMetadata().setNamespace("ingressTest");
mk.getSpec().getCapacity().setIngressPerSec(Quantity.parse("125Mi"));
Kafka kafka = this.kafkaCluster.kafkaFrom(mk, null);
openShiftClient.resource(kafka).createOrReplace();
});
informerManager.createKafkaInformer();
ingressControllerManager.reconcileIngressControllers();
checkAzReplicaCount(4);
// remove two kafkas - we should keep the same number of replicas
var kafkas = openShiftClient.resources(Kafka.class).inNamespace("ingressTest");
assertTrue(kafkas.withName("ingressTest0").delete());
assertTrue(kafkas.withName("ingressTest1").delete());
ingressControllerManager.reconcileIngressControllers();
checkAzReplicaCount(4);
// remove two more kafkas - and we should reduce
assertTrue(kafkas.withName("ingressTest2").delete());
assertTrue(kafkas.withName("ingressTest3").delete());
ingressControllerManager.reconcileIngressControllers();
checkAzReplicaCount(2);
}
use of org.bf2.operator.resources.v1alpha1.ManagedKafka in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class StrimziManager method currentStrimziVersion.
/**
* Returns the current Strimzi version for the Kafka instance
* It comes directly from the Kafka custom resource label or from the ManagedKafka in case of creation
*
* @param managedKafka ManagedKafka instance
* @return current Strimzi version for the Kafka instance
*/
public String currentStrimziVersion(ManagedKafka managedKafka) {
Kafka kafka = cachedKafka(managedKafka);
// on first time Kafka resource creation, we take the Strimzi version from the ManagedKafka resource spec
String kafkaStrimziVersion = kafka != null && kafka.getMetadata().getLabels() != null && kafka.getMetadata().getLabels().containsKey(this.versionLabel) ? kafka.getMetadata().getLabels().get(this.versionLabel) : managedKafka.getSpec().getVersions().getStrimzi();
log.debugf("currentStrimziVersion = %s", kafkaStrimziVersion);
return kafkaStrimziVersion;
}
use of org.bf2.operator.resources.v1alpha1.ManagedKafka in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class MockManagedKafkaFactory method markForDeletion.
private void markForDeletion(String id) {
ManagedKafka mk = this.kafkas.get(id);
if (mk != null && !mk.isMarkedForDeletion()) {
log.infof("Mock ManagedKafka Factory:: marking cluster %s for deletion", mk.getId());
mk.getSpec().setDeleted(true);
mkClient.patch(mk);
} else {
log.infof("Mock ManagedKafka Factory:: Is cluster %s already deleted?", id);
}
}
use of org.bf2.operator.resources.v1alpha1.ManagedKafka in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class CanaryTest method createCanaryService.
@Test
void createCanaryService() throws Exception {
ManagedKafka mk = new ManagedKafkaBuilder().withNewMetadata().withNamespace("test").withName("test-mk").endMetadata().withSpec(new ManagedKafkaSpecBuilder().withNewVersions().withKafka("2.6.0").endVersions().withNewEndpoint().withBootstrapServerHost("test-mk-kafka-bootstrap").endEndpoint().build()).build();
Service canaryService = canary.serviceFrom(mk, null);
server.getClient().services().create(canaryService);
assertNotNull(server.getClient().services().inNamespace(canaryService.getMetadata().getNamespace()).withName(canaryService.getMetadata().getName()).get());
KafkaClusterTest.diffToExpected(canaryService, "/expected/canary-service.yml");
}
use of org.bf2.operator.resources.v1alpha1.ManagedKafka in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class CanaryTest method createCanaryDeployment.
@ParameterizedTest(name = "createCanaryDeployment: {0}")
@CsvSource({ "shouldHaveNoDiffByDefault, test-mk-kafka-bootstrap, '[]'", "shouldNotHaveInitContainersIfDevCluster, bootstrap.kas.testing.domain.tld, '[{\"op\":\"remove\",\"path\":\"/spec/template/spec/initContainers\"},{\"op\":\"replace\",\"path\":\"/spec/template/spec/containers/0/env/0/value\",\"value\":\"bootstrap.kas.testing.domain.tld:443\"}]'" })
void createCanaryDeployment(String name, String bootstrapServerHost, String expectedDiff) throws Exception {
ManagedKafka mk = new ManagedKafkaBuilder().withNewMetadata().withNamespace("test").withName("test-mk").endMetadata().withSpec(new ManagedKafkaSpecBuilder().withNewVersions().withKafka("2.6.0").endVersions().withNewEndpoint().withBootstrapServerHost(bootstrapServerHost).endEndpoint().build()).build();
Deployment canaryDeployment = canary.deploymentFrom(mk, null);
KafkaClusterTest.diffToExpected(canaryDeployment, "/expected/canary.yml", expectedDiff);
}
Aggregations