use of io.strimzi.operator.common.PasswordGenerator in project strimzi by strimzi.
the class KafkaUpgradeDowngradeMockTest method initialize.
private Future<Void> initialize(VertxTestContext context, Kafka initialKafka) {
// Configure the Kubernetes Mock
mockKube = new MockKube2.MockKube2Builder(client).withKafkaCrd().withInitialKafkas(initialKafka).withStrimziPodSetCrd().withStatefulSetController().withPodController().withServiceController().withDeploymentController().build();
mockKube.start();
ResourceOperatorSupplier supplier = new ResourceOperatorSupplier(vertx, client, ResourceUtils.zookeeperLeaderFinder(vertx, client), ResourceUtils.adminClientProvider(), ResourceUtils.zookeeperScalerProvider(), ResourceUtils.metricsProvider(), pfa, 2_000);
ClusterOperatorConfig config = ResourceUtils.dummyClusterOperatorConfig(VERSIONS);
operator = new KafkaAssemblyOperator(vertx, pfa, new MockCertManager(), new PasswordGenerator(10, "a", "a"), supplier, config);
LOGGER.info("Reconciling initially -> create");
return operator.reconcile(new Reconciliation("initial-reconciliation", Kafka.RESOURCE_KIND, NAMESPACE, CLUSTER_NAME));
}
use of io.strimzi.operator.common.PasswordGenerator in project strimzi by strimzi.
the class PartialRollingUpdateMockTest method beforeEach.
@BeforeEach
public void beforeEach(VertxTestContext context) throws InterruptedException, ExecutionException, TimeoutException {
this.cluster = new KafkaBuilder().withMetadata(new ObjectMetaBuilder().withName(CLUSTER_NAME).withNamespace(NAMESPACE).build()).withNewSpec().withNewKafka().withReplicas(5).withListeners(new GenericKafkaListenerBuilder().withName("plain").withPort(9092).withType(KafkaListenerType.INTERNAL).withTls(false).build(), new GenericKafkaListenerBuilder().withName("tls").withPort(9093).withType(KafkaListenerType.INTERNAL).withTls(true).build()).withNewPersistentClaimStorage().withSize("123").withStorageClass("foo").withDeleteClaim(true).endPersistentClaimStorage().endKafka().withNewZookeeper().withReplicas(3).withNewPersistentClaimStorage().withSize("123").withStorageClass("foo").withDeleteClaim(true).endPersistentClaimStorage().endZookeeper().endSpec().build();
// Configure the Kubernetes Mock
mockKube = new MockKube2.MockKube2Builder(client).withKafkaCrd().withInitialKafkas(cluster).withStrimziPodSetCrd().withDeploymentController().withPodController().withStatefulSetController().withServiceController().build();
mockKube.start();
ResourceOperatorSupplier supplier = supplier(client);
kco = new KafkaAssemblyOperator(vertx, new PlatformFeaturesAvailability(false, KubernetesVersion.V1_16), new MockCertManager(), new PasswordGenerator(10, "a", "a"), supplier, ResourceUtils.dummyClusterOperatorConfig(VERSIONS, 2_000));
LOGGER.info("Initial reconciliation");
CountDownLatch createAsync = new CountDownLatch(1);
kco.reconcile(new Reconciliation("initialization", Kafka.RESOURCE_KIND, NAMESPACE, CLUSTER_NAME)).onComplete(ar -> {
context.verify(() -> assertThat(ar.succeeded(), is(true)));
createAsync.countDown();
});
if (!createAsync.await(60, TimeUnit.SECONDS)) {
context.failNow(new Throwable("Test timeout"));
}
LOGGER.info("Initial reconciliation complete");
context.completeNow();
}
use of io.strimzi.operator.common.PasswordGenerator in project strimzi-kafka-operator by strimzi.
the class KafkaCluster method generateJmxSecret.
/**
* Generate the Secret containing the username and password to secure the jmx port on the Kafka brokers.
*
* @param currentSecret The existing Secret with the current JMX credentials. Null if no secret exists yet.
*
* @return The generated Secret
*/
public Secret generateJmxSecret(Secret currentSecret) {
if (isJmxAuthenticated) {
PasswordGenerator passwordGenerator = new PasswordGenerator(16);
Map<String, String> data = new HashMap<>(2);
if (currentSecret != null && currentSecret.getData() != null) {
data.put(SECRET_JMX_USERNAME_KEY, currentSecret.getData().computeIfAbsent(SECRET_JMX_USERNAME_KEY, (key) -> Util.encodeToBase64(passwordGenerator.generate())));
data.put(SECRET_JMX_PASSWORD_KEY, currentSecret.getData().computeIfAbsent(SECRET_JMX_PASSWORD_KEY, (key) -> Util.encodeToBase64(passwordGenerator.generate())));
} else {
data.put(SECRET_JMX_USERNAME_KEY, Util.encodeToBase64(passwordGenerator.generate()));
data.put(SECRET_JMX_PASSWORD_KEY, Util.encodeToBase64(passwordGenerator.generate()));
}
return createJmxSecret(KafkaResources.kafkaJmxSecretName(cluster), data);
} else {
return null;
}
}
use of io.strimzi.operator.common.PasswordGenerator in project strimzi-kafka-operator by strimzi.
the class KafkaConnectCluster method generateJmxSecret.
/**
* Generate the Secret containing the username and password to secure the jmx port on the kafka connect workers
*
* @return The generated Secret
*/
public Secret generateJmxSecret() {
Map<String, String> data = new HashMap<>(2);
String[] keys = { SECRET_JMX_USERNAME_KEY, SECRET_JMX_PASSWORD_KEY };
PasswordGenerator passwordGenerator = new PasswordGenerator(16);
for (String key : keys) {
data.put(key, Base64.getEncoder().encodeToString(passwordGenerator.generate().getBytes(StandardCharsets.US_ASCII)));
}
return createJmxSecret(KafkaConnectCluster.jmxSecretName(cluster), data);
}
use of io.strimzi.operator.common.PasswordGenerator in project strimzi-kafka-operator by strimzi.
the class ZookeeperCluster method generateJmxSecret.
/**
* Generate the Secret containing the username and password to secure the jmx port on the zookeeper nodes
*
* @param currentSecret The existing Secret with the current JMX credentials. Null if no secret exists yet.
*
* @return The generated Secret
*/
public Secret generateJmxSecret(Secret currentSecret) {
if (isJmxAuthenticated) {
PasswordGenerator passwordGenerator = new PasswordGenerator(16);
Map<String, String> data = new HashMap<>(2);
if (currentSecret != null && currentSecret.getData() != null) {
data.put(SECRET_JMX_USERNAME_KEY, currentSecret.getData().computeIfAbsent(SECRET_JMX_USERNAME_KEY, (key) -> Util.encodeToBase64(passwordGenerator.generate())));
data.put(SECRET_JMX_PASSWORD_KEY, currentSecret.getData().computeIfAbsent(SECRET_JMX_PASSWORD_KEY, (key) -> Util.encodeToBase64(passwordGenerator.generate())));
} else {
data.put(SECRET_JMX_USERNAME_KEY, Util.encodeToBase64(passwordGenerator.generate()));
data.put(SECRET_JMX_PASSWORD_KEY, Util.encodeToBase64(passwordGenerator.generate()));
}
return createJmxSecret(KafkaResources.zookeeperJmxSecretName(cluster), data);
} else {
return null;
}
}
Aggregations