Giter Site home page Giter Site logo

tbobm / my_deployer Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 52 KB

Implementation of the My Deployer school project, a lightweight container deploying solution.

Dockerfile 0.68% Python 98.91% Shell 0.41%
docker python devops container-healthchecks docker-image containers python-click cli

my_deployer's Introduction

My Deployer

Base CI

A lightweight container deployment solution, written in Python.

Goal

In order to support learning the basics of Containerization principles and starting to code in Python, the "My Deployer" aims to implement the following features:

  • Ensure Docker is installed and at the expected version on a remote host
  • Provide a simple way of building Docker images on a remote host
  • Deploy these images on the remote host by taking in account image version
  • Enable upgrading remote containers and reverting failing deployments
  • Verify running container healthchecks and restart them if necessary

Installation

  • Clone this repository
  • pip install .

Example

my_deployer config localhost --port 2222 --username vagrant
my_deployer build ssh://vagrant@localhost:2222 examples/hello-world --tag 1.0
my_deployer deploy ssh://vagrant@localhost:2222 examples/hello-world --tag 1.0

Usage

my_deployer --help
Usage: my_deployer [OPTIONS] COMMAND [ARGS]...

  Handy lightweight container deployment CLI program.

Options:
  --help  Show this message and exit.

Commands:
  build        Build the Service on the remote host.
  config       Configure Docker on the remote host.
  deploy       Deploy the Service on the remote host.
  healthcheck  Ensure the running containers are healthy.

Config:

The config command will:

  • SSH using the given arguments
  • Install or update Docker on the remote host
my_deployer config --help
Usage: my_deployer config [OPTIONS] HOSTNAME

  Configure Docker on the remote host.

Options:
  --port INTEGER   SSH port to use.  [default: 22]
  --username TEXT  Remote user username if required.
  --password TEXT  Remote user password if required.
  --help           Show this message and exit.

Build:

The build command will:

  • Connect to the Docker socket through the url (i.e.: ssh-based URL)
  • Build a Docker image on the remote host
  • Tag this image using if the corresponding flag is set
my_deployer build --help
Usage: my_deployer build [OPTIONS] URL [SERVICES]...

  Build the Service on the remote host.

Options:
  --tag TEXT  Remote image tag for service(s) to build.
  --help      Show this message and exit.

Deploy:

The deploy command will:

  • Look for existing services
  • Stop these services
  • Try to run a container using the service image with the given tag if specified
  • Restore or remove the previous containers if any
my_deployer deploy --help
Usage: my_deployer deploy [OPTIONS] URL [SERVICES]...

  Deploy the Service on the remote host.

Options:
  --tag TEXT  Remote image tag for service(s) to deploy.  [default: latest]
  --help      Show this message and exit.

Healthcheck:

The healthcheck command will:

  • List every container's healthcheck if any
  • Restart every unhealthy container if asked
my_deployer healthcheck --help
Usage: my_deployer healthcheck [OPTIONS] URL [SERVICES]...

  Ensure the running containers are healthy.

Options:
  --restart  Restart unhealthy containers.  [default: False]
  --help     Show this message and exit.

Tasks

Communication

With the host:

  • Access a remote host using SSH
  • Connect to the remote Docker client

With the user:

  • Provide a friendly logging interface
  • (optional): Enable a verbose mode (0 or 1) to display remote log

Config

Ensure Docker is installed and at the expected version on a remote host.

  • Enquire about the currently installed Docker version, if any
  • Install or upgrade Docker to expected version if necessary
  • (optional): Display informations about the Docker configuration

Build

Provide a simple way of building Docker images on a remote host

  • Build the Docker image with the corresponding values
  • (optional): Generate some metadatas and display them

Deploy

Deploy these images on the remote host by taking in account image version

  • Enable upgrading remote containers and reverting failing deployments

  • Enquire if the specified image is already deployed and which version -if any- it is using

  • Deploy the newly built image (or a specified one) if necessary

  • If an already built container exists, stop it and restore it if the one getting deployed fails

  • Delete previous container if the new one is succesful and healthy

Healthcheck

Verify running container healthchecks and restart them if necessary

  • List every container's healthcheck status
  • If specified, restart the unhealthy containers

my_deployer's People

Contributors

tbobm avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

my_deployer's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.