https://pulumi.com logo
Title
m

mysterious-belgium-44686

06/09/2021, 12:45 AM
I'm trying to use Pulumi to manage some docker containers. One container is running Kafka. How can I have Pulumi wait until Kafka is up and running before creating the topic?
kafkaContainer = docker.Container("kafka-container",
    image=kafkaImage.name,
    restart="on-failure",
    networks_advanced=[{ 'name': network.name }],
    start=True,
    envs=[
      "KAFKA_BROKER_ID=1",
      "KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181",
      "KAFKA_ADVERTISED_LISTENERS=<PLAINTEXT://kafka:29092>,PLAINTEXT_<HOST://localhost:9092>",
      "KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT",
      "KAFKA_INTER_BROKER_LISTENER_NAME=PLAINTEXT",
      "KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1"
    ],
    ports=[{
        'internal': 9092,
    }],
    opts=pulumi.ResourceOptions(depends_on=[zkContainer])
)


topic = kafka.Topic("topic",
      name="sample-topic",
      replication_factor=1,
      partitions=4,
      opts=pulumi.ResourceOptions(depends_on=[kafkaContainer])
    )
s

steep-toddler-94095

06/09/2021, 12:56 AM
wondering adding the
healthcheck
property to your container will work
otherwise there isn't enough information for Pulumi to know when the kafka process is actually running within the container
m

mysterious-belgium-44686

06/09/2021, 1:05 AM
Hmmm yeah the problem is the healthcheck was gonna be "is this topic there" but I can try something else
Adding a healthcheck didn't work šŸ˜•
šŸ™ 1
I guess I could try to do this in two stages?
Or with a custom provider or something hm
s

sparse-tomato-5980

06/09/2021, 3:09 AM
@mysterious-belgium-44686 Are you trying to get this working with local or aws right now?
m

mysterious-belgium-44686

06/09/2021, 3:09 AM
local
s

sparse-tomato-5980

06/09/2021, 3:10 AM
for local you'd want to add Kafka to our
docker-compose.yml
and Pulumi comes up after that service's health check
(note that we don't currently use docker.Container for anything)
m

mysterious-belgium-44686

06/09/2021, 3:11 AM
Yeah what I'm doing is testing replacing docker-compose with Pulumi
s

sparse-tomato-5980

06/09/2021, 3:11 AM
oh lmao ok
m

mysterious-belgium-44686

06/09/2021, 3:13 AM
😊
p

prehistoric-nail-50687

06/09/2021, 5:56 AM
Yeah what I’m doing is testing replacing docker-compose with Pulumi
@sparse-tomato-5980 I never thought about this, what do you think would be the advantages in a local setup? Don’t you think it complicates things for ā€œnormal usersā€?
m

mysterious-belgium-44686

06/09/2021, 1:06 PM
I think you might have meant to message me with that one, not Max?
šŸ‘ 1
Mostly I was curious to try and see if I could
p

prehistoric-nail-50687

06/09/2021, 2:02 PM
šŸ‘