I'm trying to use Pulumi to manage some docker con...
# general
m
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?
Copy code
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
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
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
@mysterious-belgium-44686 Are you trying to get this working with local or aws right now?
m
local
s
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
Yeah what I'm doing is testing replacing docker-compose with Pulumi
s
oh lmao ok
m
šŸ˜Š
p
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
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
šŸ‘