use of io.strimzi.api.kafka.model.Kafka in project debezium by debezium.
the class OcpKafkaDeployer method deploy.
/**
* Deploys Kafka Cluster
* @return {@link OcpKafkaController} instance for deployed cluster
* @throws InterruptedException
*/
@Override
public OcpKafkaController deploy() throws InterruptedException {
LOGGER.info("Deploying Kafka Cluster");
Kafka kafka = kafkaOperation().createOrReplace(strimziBuilder.build());
OcpKafkaController controller = new OcpKafkaController(kafka, operatorController, ocp);
controller.waitForCluster();
return controller;
}
use of io.strimzi.api.kafka.model.Kafka in project strimzi by strimzi.
the class FeatureGatesIsolatedST method testSwitchingStrimziPodSetFeatureGateOnAndOff.
@IsolatedTest
void testSwitchingStrimziPodSetFeatureGateOnAndOff(ExtensionContext extensionContext) {
assumeFalse(Environment.isOlmInstall() || Environment.isHelmInstall());
final String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
final String producerName = "producer-test-" + new Random().nextInt(Integer.MAX_VALUE);
final String consumerName = "consumer-test-" + new Random().nextInt(Integer.MAX_VALUE);
final String topicName = KafkaTopicUtils.generateRandomNameOfTopic();
int zkReplicas = 1;
int kafkaReplicas = 3;
final LabelSelector zkSelector = KafkaResource.getLabelSelector(clusterName, KafkaResources.zookeeperStatefulSetName(clusterName));
final LabelSelector kafkaSelector = KafkaResource.getLabelSelector(clusterName, KafkaResources.kafkaStatefulSetName(clusterName));
int messageCount = 500;
List<EnvVar> coEnvVars = new ArrayList<>();
coEnvVars.add(new EnvVar(Environment.STRIMZI_FEATURE_GATES_ENV, "-UseStrimziPodSets", null));
LOGGER.info("Deploying CO with STS - SPS is disabled");
clusterOperator.unInstall();
clusterOperator = new SetupClusterOperator.SetupClusterOperatorBuilder().withExtensionContext(BeforeAllOnce.getSharedExtensionContext()).withNamespace(INFRA_NAMESPACE).withWatchingNamespaces(Constants.WATCH_ALL_NAMESPACES).withExtraEnvVars(coEnvVars).createInstallation().runInstallation();
LOGGER.info("Deploying Kafka");
resourceManager.createResource(extensionContext, KafkaTemplates.kafkaPersistent(clusterName, kafkaReplicas, zkReplicas).build());
resourceManager.createResource(extensionContext, KafkaTopicTemplates.topic(clusterName, topicName).build());
Map<String, String> kafkaPods = PodUtils.podSnapshot(clusterOperator.getDeploymentNamespace(), kafkaSelector);
Map<String, String> zkPods = PodUtils.podSnapshot(clusterOperator.getDeploymentNamespace(), zkSelector);
Map<String, String> coPod = DeploymentUtils.depSnapshot(ResourceManager.getCoDeploymentName());
KafkaClients clients = new KafkaClientsBuilder().withProducerName(producerName).withConsumerName(consumerName).withBootstrapAddress(KafkaResources.plainBootstrapAddress(clusterName)).withTopicName(topicName).withMessageCount(messageCount).withDelayMs(1000).withNamespaceName(clusterOperator.getDeploymentNamespace()).build();
resourceManager.createResource(extensionContext, clients.producerStrimzi(), clients.consumerStrimzi());
LOGGER.info("Changing FG env variable to enable SPS");
coEnvVars = kubeClient().getDeployment(Constants.STRIMZI_DEPLOYMENT_NAME).getSpec().getTemplate().getSpec().getContainers().get(0).getEnv();
coEnvVars.stream().filter(env -> env.getName().equals(Environment.STRIMZI_FEATURE_GATES_ENV)).findFirst().get().setValue("+UseStrimziPodSets");
Deployment coDep = kubeClient().getDeployment(Constants.STRIMZI_DEPLOYMENT_NAME);
coDep.getSpec().getTemplate().getSpec().getContainers().get(0).setEnv(coEnvVars);
kubeClient().getClient().apps().deployments().inNamespace(clusterOperator.getDeploymentNamespace()).withName(Constants.STRIMZI_DEPLOYMENT_NAME).replace(coDep);
coPod = DeploymentUtils.waitTillDepHasRolled(Constants.STRIMZI_DEPLOYMENT_NAME, 1, coPod);
zkPods = RollingUpdateUtils.waitTillComponentHasRolled(zkSelector, zkReplicas, zkPods);
kafkaPods = RollingUpdateUtils.waitTillComponentHasRolled(kafkaSelector, kafkaReplicas, kafkaPods);
KafkaUtils.waitForKafkaReady(clusterName);
LOGGER.info("Changing FG env variable to disable again SPS");
coEnvVars.stream().filter(env -> env.getName().equals(Environment.STRIMZI_FEATURE_GATES_ENV)).findFirst().get().setValue("");
coDep = kubeClient().getDeployment(Constants.STRIMZI_DEPLOYMENT_NAME);
coDep.getSpec().getTemplate().getSpec().getContainers().get(0).setEnv(coEnvVars);
kubeClient().getClient().apps().deployments().inNamespace(clusterOperator.getDeploymentNamespace()).withName(Constants.STRIMZI_DEPLOYMENT_NAME).replace(coDep);
DeploymentUtils.waitTillDepHasRolled(Constants.STRIMZI_DEPLOYMENT_NAME, 1, coPod);
RollingUpdateUtils.waitTillComponentHasRolled(zkSelector, zkReplicas, zkPods);
RollingUpdateUtils.waitTillComponentHasRolled(kafkaSelector, kafkaReplicas, kafkaPods);
ClientUtils.waitForClientsSuccess(producerName, consumerName, clusterOperator.getDeploymentNamespace(), messageCount);
}
use of io.strimzi.api.kafka.model.Kafka in project strimzi by strimzi.
the class AbstractST method verifyLabelsForService.
protected void verifyLabelsForService(String namespaceName, String clusterName, String serviceToTest, String kind) {
LOGGER.info("Verifying labels for Kafka Connect Services");
String serviceName = clusterName.concat("-").concat(serviceToTest);
kubeClient(namespaceName).listServices().stream().filter(service -> service.getMetadata().getName().equals(serviceName)).forEach(service -> {
LOGGER.info("Verifying labels for service {}", service.getMetadata().getName());
assertThat(service.getMetadata().getLabels().get(Labels.STRIMZI_CLUSTER_LABEL), is(clusterName));
assertThat(service.getMetadata().getLabels().get(Labels.STRIMZI_KIND_LABEL), is(kind));
assertThat(service.getMetadata().getLabels().get(Labels.STRIMZI_NAME_LABEL), is(serviceName));
});
}
use of io.strimzi.api.kafka.model.Kafka in project strimzi by strimzi.
the class KafkaTemplates method kafkaWithMetrics.
public static KafkaBuilder kafkaWithMetrics(String name, String namespace, int kafkaReplicas, int zookeeperReplicas) {
Kafka kafka = getKafkaFromYaml(Constants.PATH_TO_KAFKA_METRICS_CONFIG);
ConfigMap metricsCm = TestUtils.configMapFromYaml(Constants.PATH_TO_KAFKA_METRICS_CONFIG, "kafka-metrics");
KubeClusterResource.kubeClient().getClient().configMaps().inNamespace(namespace).createOrReplace(metricsCm);
return defaultKafka(kafka, name, kafkaReplicas, zookeeperReplicas).editOrNewMetadata().withNamespace(namespace).endMetadata().editSpec().withNewKafkaExporter().endKafkaExporter().endSpec();
}
use of io.strimzi.api.kafka.model.Kafka in project strimzi by strimzi.
the class KafkaTemplates method kafkaAndCruiseControlWithMetrics.
public static KafkaBuilder kafkaAndCruiseControlWithMetrics(String name, int kafkaReplicas, int zookeeperReplicas) {
Kafka kafka = getKafkaFromYaml(Constants.PATH_TO_KAFKA_CRUISE_CONTROL_METRICS_CONFIG);
ConfigMap kafkaMetricsCm = TestUtils.configMapFromYaml(Constants.PATH_TO_KAFKA_METRICS_CONFIG, "kafka-metrics");
KubeClusterResource.kubeClient().getClient().configMaps().inNamespace(kubeClient().getNamespace()).createOrReplace(kafkaMetricsCm);
ConfigMap zkMetricsCm = TestUtils.configMapFromYaml(Constants.PATH_TO_KAFKA_METRICS_CONFIG, "kafka-metrics");
KubeClusterResource.kubeClient().getClient().configMaps().inNamespace(kubeClient().getNamespace()).createOrReplace(zkMetricsCm);
ConfigMap ccMetricsCm = TestUtils.configMapFromYaml(Constants.PATH_TO_KAFKA_CRUISE_CONTROL_CONFIG, "cruise-control-metrics");
KubeClusterResource.kubeClient().getClient().configMaps().inNamespace(kubeClient().getNamespace()).createOrReplace(ccMetricsCm);
return defaultKafka(kafka, name, kafkaReplicas, zookeeperReplicas);
}
Aggregations