use of org.bf2.operator.resources.v1alpha1.ManagedKafkaAgentSpecBuilder in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class ManagedKafkaProvisioner method install.
/**
* Install this Kafka provisioner. This can be called once per test class or per test method.
*/
public void install() throws Exception {
// delete/create the namespaces to be used
Map<String, String> nsAnnotations = new HashMap<>();
if (PerformanceEnvironment.KAFKA_COLLECT_LOG) {
nsAnnotations.put(Constants.ORG_BF2_KAFKA_PERFORMANCE_COLLECTPODLOG, "true");
}
cluster.waitForDeleteNamespace(StrimziOperatorManager.OPERATOR_NS);
FleetShardOperatorManager.deleteFleetShard(cluster.kubeClient()).get(2, TimeUnit.MINUTES);
cluster.createNamespace(Constants.KAFKA_NAMESPACE, nsAnnotations, Map.of());
List<Node> workers = cluster.getWorkerNodes();
boolean smallNodes = workers.stream().anyMatch(n -> TestUtils.getMaxAvailableResources(n).cpuMillis < 3000);
if (smallNodes) {
MixedOperation<Deployment, DeploymentList, RollableScalableResource<Deployment>> deployments = cluster.kubeClient().client().apps().deployments();
this.informer = deployments.inAnyNamespace().inform(new ResourceEventHandler<Deployment>() {
@Override
public void onUpdate(Deployment oldObj, Deployment newObj) {
onAdd(newObj);
}
@Override
public void onDelete(Deployment obj, boolean deletedFinalStateUnknown) {
}
@Override
public void onAdd(Deployment obj) {
if (!obj.getMetadata().getNamespace().equals(StrimziOperatorManager.OPERATOR_NS) && !obj.getMetadata().getNamespace().equals(FleetShardOperatorManager.OPERATOR_NS)) {
return;
}
// patch any deployment that requests a lot of cpu, and make sure it's on the perf infra
deployments.inNamespace(obj.getMetadata().getNamespace()).withName(obj.getMetadata().getName()).edit(new TypedVisitor<ResourceRequirementsBuilder>() {
@Override
public void visit(ResourceRequirementsBuilder element) {
Quantity cpu = null;
if (element.getRequests() != null) {
cpu = element.getRequests().get("cpu");
}
if (cpu == null && element.getLimits() != null) {
cpu = element.getLimits().get("cpu");
}
if (cpu != null && Quantity.getAmountInBytes(cpu).compareTo(BigDecimal.valueOf(1)) > 0) {
element.addToRequests("cpu", Quantity.parse("1"));
}
}
});
}
});
}
// installs the Strimzi Operator using the OLM bundle
CompletableFuture<Void> strimziFuture = strimziManager.deployStrimziOperator();
cluster.connectNamespaceToMonitoringStack(StrimziOperatorManager.OPERATOR_NS);
// installs a cluster wide fleetshard operator
// not looking at the returned futures - it's assumed that we'll eventually wait on the managed kafka deployment
CompletableFuture<Void> future = FleetShardOperatorManager.deployFleetShardOperator(cluster.kubeClient());
CompletableFuture.allOf(future, strimziFuture).get(2, TimeUnit.MINUTES);
var agentResource = this.cluster.kubeClient().client().resource(new ManagedKafkaAgentBuilder().withNewMetadata().withName(ManagedKafkaAgentResourceClient.RESOURCE_NAME).withNamespace(FleetShardOperatorManager.OPERATOR_NS).endMetadata().withSpec(new ManagedKafkaAgentSpecBuilder().withNewObservability().withAccessToken("").withChannel("").withRepository("").withTag("").endObservability().build()).build());
agentResource.createOrReplace();
// FleetShardOperatorManager.deployFleetShardSync(cluster.kubeClient());
cluster.connectNamespaceToMonitoringStack(FleetShardOperatorManager.OPERATOR_NS);
strimziVersions = SyncApiClient.getSortedAvailableStrimziVersions(() -> agentResource.fromServer().get().getStatus()).collect(Collectors.toList());
}
use of org.bf2.operator.resources.v1alpha1.ManagedKafkaAgentSpecBuilder in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class OperatorST method deploy.
@BeforeAll
void deploy() throws Exception {
strimziOperatorManager = new OlmBasedStrimziOperatorManager(kube, StrimziOperatorManager.OPERATOR_NS);
CompletableFuture.allOf(strimziOperatorManager.deployStrimziOperator(), FleetShardOperatorManager.deployFleetShardOperator(kube)).join();
// since sync is not installed, manually create the agent resource
var agentResource = kube.client().resource(new ManagedKafkaAgentBuilder().withNewMetadata().withName(ManagedKafkaAgentResourceClient.RESOURCE_NAME).withNamespace(FleetShardOperatorManager.OPERATOR_NS).endMetadata().withSpec(new ManagedKafkaAgentSpecBuilder().withNewObservability().withAccessToken("").withChannel("").withRepository("").withTag("").endObservability().build()).build());
agentResource.createOrReplace();
// the operator will update the status after a while
strimziVersions = SyncApiClient.getSortedAvailableStrimziVersions(() -> agentResource.fromServer().get().getStatus()).collect(Collectors.toList());
assertTrue(strimziVersions.size() > 1);
latestStrimziVersion = strimziVersions.get(strimziVersions.size() - 1);
latestKafkaVersion = SyncApiClient.getLatestAvailableKafkaVersion(() -> agentResource.fromServer().get().getStatus(), latestStrimziVersion);
}
Aggregations