I am trying to launch AKHQ using Testcontainers, however when launching UI, I get the following message:
/ http:
{
"message": "Couldn't find any clusters on your configuration file,
please ensure that the configuration file is loaded correctly",
"_links": {
"self": {
"href": "/",
"templated": false
}
}
}
What I have tried:
var containerName = Guid.NewGuid().ToString();
#region Zookeeper
var zookeeperContainerName = $"zookeeper_{containerName}";
var zookeeperContainer = new ContainerBuilder()
.WithImage("confluentinc/cp-zookeeper:latest")
.WithName(zookeeperContainerName)
.WithPortBinding(2181, true)
.WithEnvironment(new Dictionary<string, string>
{
{"ZOOKEEPER_CLIENT_PORT", "2181"},
{"ZOOKEEPER_TICK_TIME", "2000"}
})
.WithWaitStrategy(Wait.ForUnixContainer().UntilPortIsAvailable(2181))
.Build();
await zookeeperContainer.StartAsync()
.ConfigureAwait(false);
#endregion
#region Kafka
var zookeeperHostPort =
zookeeperContainer.GetMappedPublicPort(2181);
var kafkaContainerName = $"kafka_{containerName}";
var kafkaHostPort = FindFreePort();
var kafkaContainer = new ContainerBuilder()
.WithImage("confluentinc/cp-kafka:latest")
.WithName(kafkaContainerName)
.WithHostname(kafkaContainerName)
.WithPortBinding(kafkaHostPort, 9092)
.WithEnvironment(new Dictionary<string, string>
{
{"KAFKA_BROKER_ID", "1"},
{"KAFKA_ZOOKEEPER_CONNECT",
$"host.docker.internal:{zookeeperHostPort}"},
{"KAFKA_LISTENER_SECURITY_PROTOCOL_MAP",
"PLAINTEXT:PLAINTEXT,PLAINTEXT_INTERNAL:PLAINTEXT"},
{"KAFKA_LISTENERS",
"PLAINTEXT://:9092,PLAINTEXT_INTERNAL://:29092"},
{"KAFKA_ADVERTISED_LISTENERS",
$"PLAINTEXT://localhost:{kafkaHostPort},
PLAINTEXT_INTERNAL://{kafkaContainerName}:29092"},
{"KAFKA_INTER_BROKER_LISTENER_NAME",
"PLAINTEXT_INTERNAL"},
{"KAFKA_TRANSACTION_STATE_LOG_MIN_ISR", "1"},
{"KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR", "1"},
{"KAFKA_AUTO_CREATE_TOPICS_ENABLE", "true"},
{"KAFKA_DELETE_TOPIC_ENABLE", "true"},
{"KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR", "1"},
})
.WithWaitStrategy(Wait.ForUnixContainer().UntilPortIsAvailable(9092))
.Build();
await kafkaContainer.StartAsync()
.ConfigureAwait(false);
#endregion
#region akhq
var akhqContainerName = $"akhq_{containerName}";
var akhqHostPort = 62732;
var akhqContainer = new ContainerBuilder()
.WithImage("tchiotludo/akhq:latest")
.WithName(akhqContainerName)
.WithPortBinding(akhqHostPort, 8082)
.WithEnvironment(new Dictionary<string, string>
{
{"MICRONAUT_SERVER_PORT", "8082"},
{"AKHQ_CONFIGURATION",
$"\r\n{akhqContainerName}:\r\nconnections:\r\ndocker-kafka-server:\r\nproperties:\r\nbootstrap.servers: \"
{kafkaContainerName}:29092\"\r\n"}
})
.WithWaitStrategy(Wait.ForUnixContainer().UntilPortIsAvailable(8082))
.Build();
await akhqContainer.StartAsync()
.ConfigureAwait(false);
#endregion