Skip to content

pb-/redeployster

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

redeployster

Rationale

Sometimes Kubernetes is the answer, but other times not. redeployster recreates containers in scrappy, non-enterprise docker-compose setups. It's only purpose is to run docker-compose up -d $SERVICE and to expose that functionality through HTTP so that your build pipelines can trigger it remotely.

Usage

Attach a redeployster.token label to the services you want to make deployable:

# docker-compose.yml
version: "3"
services:
  hello:
    image: hello-world
    labels:
      - 'redeployster.token=dolphin'

Make sure that the service got launched manually once so the container(s) have the label:

docker-compose up -d

The deployable service is now configured:

  • The name of the docker-compose service will be a new exposed path on redeployster: call POST /hello here to deploy the hello service.
  • The token will be required by reployster to trigger the deploy: add Authorization: Bearer dolphin http header to the call.
  • Adding a token also acts as an opt-in flag for a service to be deployable. Without a token, redeployster will ignore the service.

Try

go run .

# In another shell:
curl -i -XPOST -H'Authorization: Bearer dolphin' http://localhost:4711/hello

FAQ

How to detect deploy failures from the http client?

Redeployster replies with HTTP Status 200 as soon as a deploy job starts because it then streams the deploy output. To access the exit code of a job, you can read the Exit-Code HTTP trailer.

Here is an example with curl that saves the headers in a separate file and then uses grep to exit with a non-zero code if the deployment fails:

curl -XPOST -H'Authorization: Bearer dolphin' http://localhost:4711/hello -D headers.txt
grep -q '^Exit-Code: 0\b' headers.txt

How to expose redeployster to the Internet under HTTPS?

Redeployster currently doesn't have options to provide a certificate in order to listen directly on port 443.

It is meant to run on the same host as the services it needs to deploy. These Docker-managed services are most likely exposed to the HTTPS port via a reverse proxy like Nginx, Traefik, Caddy etc.

One typical scenario is to add a forwarder service under the reverse-proxy. The forwarder will then proxy requests to redeployster running directly on the host. See this example using Caddy as the forwarder, and assuming Traefik as the main reverse-proxy.

# docker-compose.yml
services:
  forwarder:
    image: caddy:2.6.4-alpine
    command: 'caddy reverse-proxy --from :3000 --to host.docker.internal:4711'
    extra_hosts:
      - "host.docker.internal:host-gateway"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.forwarder.rule=Host(`deploy.example.com`)"
      - "traefik.http.services.forwarder.loadbalancer.server.port=3000"
      - "traefik.http.routers.forwarder.tls.certresolver=default"

Note: If you have a firewall, you might need to allow Docker's network interface to access the Redeployster's port (4711)

Why not run redeployster within Docker?

We could also run it within a Docker container and let it handle the other containers by mounting the Docker socket. But redeployster actually needs to call docker-compose, and for this it needs access to the docker-compose.yml file from the host.

Development

Requirements: go

Useful commands:

  • Build the binary: go build .
  • Build & run from source: go run .
  • Format the code: go fmt .

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages