Deploy to Docker SWARM
Deploy to Docker Swarm with Codefresh
You will need to provide:
docker-stack.ymlthat contains the definition of the application
- The host where your Docker Swarm is running
- An SSH key that Codefresh can use to access remotely the Docker Swarm host
- The stack name that will be used once the application is deployed
All this information will be passed to the pipeline in the form of build parameters.
For an example Docker Swarm application, see https://github.com/codefreshdemo/example-voting-app
Run in this root directory:
The app runs at
http://localhost:5000, and the results are at
Alternately, if you want to run it on a Docker Swarm, first make sure you have a Swarm.
If you don’t, run:
Once you have your swarm, in this directory run:
The swarm master must have Python installed.
Deploy to Remote Swarm with Codefresh
First you need to set up the following environment variables in your Codefresh pipeline:
||remote Docker Swarm master machine, accessible over SSH (for example, ubuntu@ec2-public-ip)|
||is new Docker stack name (use "vote", for example)|
||private SSH key, used to access Docker Swarm master machine|
||split character, you’ve used to replace
SSH_KEY variable has the contents of the SSH key that can access the Docker Swarm host. Currently, in order to pass SSH key through Codefresh UI, you need to convert it to single line string (replacing
comma), like this:
SPLIT_CHAR variable should hold the replacement character that was used for the SSH key (in the example above it is the comma character)
Deploy to Docker Swarm with a YAML step
Once you have defined all the variables, deploy to your cluster using the following freestyle step.
You can also pass custom credentials like this:
Create a CI/CD pipeine for Docker Swarm
Here is the complete pipeline:
And here is the pipeline definition:
The values of
MY_REGISTRY_PASSWORD depend upon the type of your connected registry.