use of io.strimzi.api.kafka.model.EntityUserOperatorSpec in project debezium by debezium.
the class FabricKafkaBuilder method defaultKafkaEntityOperatorSpec.
private static EntityOperatorSpec defaultKafkaEntityOperatorSpec() {
EntityTopicOperatorSpec topicOperator = new EntityTopicOperatorSpec();
EntityUserOperatorSpec userOperator = new EntityUserOperatorSpec();
return new EntityOperatorSpecBuilder().withTopicOperator(topicOperator).withUserOperator(userOperator).build();
}
use of io.strimzi.api.kafka.model.EntityUserOperatorSpec in project strimzi-kafka-operator by strimzi.
the class EntityOperatorTest method testTlsSideCarContainerEnvVars.
@ParallelTest
public void testTlsSideCarContainerEnvVars() {
ContainerEnvVar envVar1 = new ContainerEnvVar();
String testEnvOneKey = "TEST_ENV_1";
String testEnvOneValue = "test.env.one";
envVar1.setName(testEnvOneKey);
envVar1.setValue(testEnvOneValue);
ContainerEnvVar envVar2 = new ContainerEnvVar();
String testEnvTwoKey = "TEST_ENV_2";
String testEnvTwoValue = "test.env.two";
envVar2.setName(testEnvTwoKey);
envVar2.setValue(testEnvTwoValue);
List<ContainerEnvVar> testEnvs = new ArrayList<>();
testEnvs.add(envVar1);
testEnvs.add(envVar2);
ContainerTemplate tlsContainer = new ContainerTemplate();
tlsContainer.setEnv(testEnvs);
Kafka resource = new KafkaBuilder(ResourceUtils.createKafka(namespace, cluster, replicas, image, healthDelay, healthTimeout)).editSpec().withNewEntityOperator().withTopicOperator(entityTopicOperatorSpec).withUserOperator(entityUserOperatorSpec).withNewTemplate().withTlsSidecarContainer(tlsContainer).endTemplate().endEntityOperator().endSpec().build();
List<EnvVar> containerEnvVars = EntityOperator.fromCrd(new Reconciliation("test", resource.getKind(), resource.getMetadata().getNamespace(), resource.getMetadata().getName()), resource, VERSIONS, true).getTlsSidecarEnvVars();
assertThat("Failed to correctly set container environment variable: " + testEnvOneKey, containerEnvVars.stream().filter(env -> testEnvOneKey.equals(env.getName())).map(EnvVar::getValue).findFirst().orElse("").equals(testEnvOneValue), is(true));
assertThat("Failed to correctly set container environment variable: " + testEnvTwoKey, containerEnvVars.stream().filter(env -> testEnvTwoKey.equals(env.getName())).map(EnvVar::getValue).findFirst().orElse("").equals(testEnvTwoValue), is(true));
}
use of io.strimzi.api.kafka.model.EntityUserOperatorSpec in project strimzi-kafka-operator by strimzi.
the class EntityUserOperatorTest method testFromCrdCaValidityAndRenewal.
@ParallelTest
public void testFromCrdCaValidityAndRenewal() {
EntityUserOperatorSpec entityUserOperatorSpec = new EntityUserOperatorSpecBuilder().build();
EntityOperatorSpec entityOperatorSpec = new EntityOperatorSpecBuilder().withUserOperator(entityUserOperatorSpec).build();
CertificateAuthority ca = new CertificateAuthority();
ca.setValidityDays(42);
ca.setRenewalDays(69);
Kafka customValues = new KafkaBuilder(ResourceUtils.createKafka(namespace, cluster, replicas, image, healthDelay, healthTimeout)).editSpec().withEntityOperator(entityOperatorSpec).withClientsCa(ca).endSpec().build();
EntityUserOperator entityUserOperator = EntityUserOperator.fromCrd(new Reconciliation("test", resource.getKind(), resource.getMetadata().getNamespace(), resource.getMetadata().getName()), customValues, true);
Kafka defaultValues = new KafkaBuilder(ResourceUtils.createKafka(namespace, cluster, replicas, image, healthDelay, healthTimeout)).editSpec().withEntityOperator(entityOperatorSpec).endSpec().build();
EntityUserOperator entityUserOperator2 = EntityUserOperator.fromCrd(new Reconciliation("test", resource.getKind(), resource.getMetadata().getNamespace(), resource.getMetadata().getName()), defaultValues, true);
assertThat(entityUserOperator.clientsCaValidityDays, is(42));
assertThat(entityUserOperator.clientsCaRenewalDays, is(69));
assertThat(entityUserOperator2.clientsCaValidityDays, is(CertificateAuthority.DEFAULT_CERTS_VALIDITY_DAYS));
assertThat(entityUserOperator2.clientsCaRenewalDays, is(CertificateAuthority.DEFAULT_CERTS_RENEWAL_DAYS));
}
use of io.strimzi.api.kafka.model.EntityUserOperatorSpec in project strimzi-kafka-operator by strimzi.
the class KafkaST method testRemoveUserAndTopicOperatorsFromEntityOperator.
@ParallelNamespaceTest
@KRaftNotSupported("EntityOperator is not supported by KRaft mode and is used in this test class")
void testRemoveUserAndTopicOperatorsFromEntityOperator(ExtensionContext extensionContext) {
final String namespaceName = StUtils.getNamespaceBasedOnRbac(namespace, extensionContext);
final String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
Instant startTime = Instant.now();
resourceManager.createResource(extensionContext, KafkaTemplates.kafkaEphemeral(clusterName, 3).build());
String eoDeploymentName = KafkaResources.entityOperatorDeploymentName(clusterName);
KafkaResource.replaceKafkaResourceInSpecificNamespace(clusterName, k -> {
k.getSpec().getEntityOperator().setTopicOperator(null);
k.getSpec().getEntityOperator().setUserOperator(null);
}, namespaceName);
PodUtils.waitUntilPodStabilityReplicasCount(namespaceName, eoDeploymentName, 0);
KafkaResource.replaceKafkaResourceInSpecificNamespace(clusterName, k -> {
k.getSpec().getEntityOperator().setTopicOperator(new EntityTopicOperatorSpec());
k.getSpec().getEntityOperator().setUserOperator(new EntityUserOperatorSpec());
}, namespaceName);
DeploymentUtils.waitForDeploymentReady(namespaceName, eoDeploymentName);
// Checking that EO was created
kubeClient().listPodsByPrefixInName(namespaceName, eoDeploymentName).forEach(pod -> {
pod.getSpec().getContainers().forEach(container -> {
assertThat(container.getName(), anyOf(containsString("topic-operator"), containsString("user-operator"), containsString("tls-sidecar")));
});
});
Instant endTime = Instant.now();
long duration = Duration.between(startTime, endTime).toSeconds();
assertNoCoErrorsLogged(duration);
}
use of io.strimzi.api.kafka.model.EntityUserOperatorSpec in project strimzi by strimzi.
the class EntityUserOperator method fromCrd.
/**
* Create an Entity User Operator from given desired resource
*
* @param reconciliation The reconciliation
* @param kafkaAssembly desired resource with cluster configuration containing the Entity User Operator one
* @return Entity User Operator instance, null if not configured in the ConfigMap
*/
public static EntityUserOperator fromCrd(Reconciliation reconciliation, Kafka kafkaAssembly) {
EntityUserOperator result = null;
EntityOperatorSpec entityOperatorSpec = kafkaAssembly.getSpec().getEntityOperator();
if (entityOperatorSpec != null) {
EntityUserOperatorSpec userOperatorSpec = entityOperatorSpec.getUserOperator();
if (userOperatorSpec != null) {
String namespace = kafkaAssembly.getMetadata().getNamespace();
result = new EntityUserOperator(reconciliation, kafkaAssembly);
result.setOwnerReference(kafkaAssembly);
String image = userOperatorSpec.getImage();
if (image == null) {
image = System.getenv().getOrDefault(ClusterOperatorConfig.STRIMZI_DEFAULT_USER_OPERATOR_IMAGE, "quay.io/strimzi/operator:latest");
}
result.setImage(image);
result.setWatchedNamespace(userOperatorSpec.getWatchedNamespace() != null ? userOperatorSpec.getWatchedNamespace() : namespace);
result.setReconciliationIntervalMs(userOperatorSpec.getReconciliationIntervalSeconds() * 1_000);
result.setLogging(userOperatorSpec.getLogging());
result.setGcLoggingEnabled(userOperatorSpec.getJvmOptions() == null ? DEFAULT_JVM_GC_LOGGING_ENABLED : userOperatorSpec.getJvmOptions().isGcLoggingEnabled());
result.setSecretPrefix(userOperatorSpec.getSecretPrefix() == null ? EntityUserOperatorSpec.DEFAULT_SECRET_PREFIX : userOperatorSpec.getSecretPrefix());
if (userOperatorSpec.getJvmOptions() != null) {
result.setJavaSystemProperties(userOperatorSpec.getJvmOptions().getJavaSystemProperties());
}
result.setJvmOptions(userOperatorSpec.getJvmOptions());
result.setResources(userOperatorSpec.getResources());
if (userOperatorSpec.getReadinessProbe() != null) {
result.setReadinessProbe(userOperatorSpec.getReadinessProbe());
}
if (userOperatorSpec.getLivenessProbe() != null) {
result.setLivenessProbe(userOperatorSpec.getLivenessProbe());
}
if (kafkaAssembly.getSpec().getClientsCa() != null) {
if (kafkaAssembly.getSpec().getClientsCa().getValidityDays() > 0) {
result.setClientsCaValidityDays(kafkaAssembly.getSpec().getClientsCa().getValidityDays());
}
if (kafkaAssembly.getSpec().getClientsCa().getRenewalDays() > 0) {
result.setClientsCaRenewalDays(kafkaAssembly.getSpec().getClientsCa().getRenewalDays());
}
}
if (kafkaAssembly.getSpec().getKafka().getAuthorization() != null) {
// Indicates whether the Kafka Admin API for ACL management are supported by the configured authorizer
// plugin. This information is passed to the User Operator.
result.aclsAdminApiSupported = kafkaAssembly.getSpec().getKafka().getAuthorization().supportsAdminApi();
}
}
}
return result;
}
Aggregations