pulumi / pulumi-docker

A Docker Pulumi resource package, providing multi-language access to Docker resources and building images.
85 stars 14 forks source link

Docker Swarm management #282

Open martinsotirov opened 3 years ago

martinsotirov commented 3 years ago

Am I missing something or are there no utilities to init and join a swarm from this package?

lblackstone commented 3 years ago

I don't believe this is currently supported.

dystopiandev commented 2 years ago

Bump. 2022. Anything change?

Lwtsde commented 2 years ago

I would also love to see support for Docker Swarm management since i can not implement it myself :)

dystopiandev commented 1 year ago

Bump. 2023. Anything change?

jchook commented 1 year ago

You can use @pulumi/command to init + join a swarm.

For example:

export const initSwarm = new command.remote.Command("initSwarm", {
  connection: {
    host: managerInstance.ipAddress,
    user: "root",
    privateKey,
  },
  create: pulumi.interpolate`
    docker swarm init --advertise-addr ${managerInstance.ipAddress}
    docker swarm join-token worker -q 
  `,
});

const joinSwarmToken = initSwarm.stdout.apply(
  (stdout) => stdout.split("\n").pop()?.trim() || ""
);

export const joinSwarm = new command.remote.Command("joinSwarm", {
  connection: {
    host: workerInstance.ipAddress,
    user: "root",
    privateKey,
  },
  create: pulumi.interpolate` docker swarm join --token ${joinSwarmToken} ${managerInstance.ipAddress}:2377 `,
});