Skip to content

A system to automatically provision and run web apps

Notifications You must be signed in to change notification settings

bencord0/deployr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Deployr
=======

A system to automatically provision and run web apps

Installation
============

  $ cd deployr
  $ pip install --user .

If you run this outside of a virtualenv, and as non-root, this will add the `deployr`
program to `~/.local/bin/deployr`. You may need to add this to your PATH.

Requirements
------------

Docker. `deployr` heavily relies on the docker ecosystem to build, push and run
webapps in containers.

Currently, `deployr` assumes that you have a local kubernetes instance running.
You can set one up using the `curl|bash` script at get.k8s.io.

You will also need a docker image repository to push images to. `deployr`
currently hardcodes a registry running on localhost. You can run it too using
the library registry_.

.. _registry: https://hub.docker.com/r/_/registry/


Usage
=====

  $ deployr
  usage: deployr [-h] {deploy,info,delete} ...

  optional arguments:
    -h, --help            show this help message and exit

  subcommands:
    {deploy,info,delete}

  $ deployr deploy --help
  usage: deployr deploy [-h] [-a APPNAME] repository [git_hash]

  positional arguments:
    repository            e.g. https://github.com/bencord0/scrumblr
    git_hash

  optional arguments:
    -h, --help            show this help message and exit
    -a APPNAME, --appname APPNAME


Deploying with deployr
----------------------

Using `deployr` is easy!

Just point `deployr` at a git repository.
For example, we're going to deploy an instance of the Scrumblr_ kanban board.

.. _Scrumblr: http://scrumblr.ca/


  $ deployr https://github.com/bencord0/scrumblr


This will deploy scrumblr to a locally running kubernetes instance.

Note, deployr expects to find a `Dockerfile` which will be used to create
a container image. `deployr` also expects to find a `deployr.yml` file,
a kubernetes pod description, with some templated parameters.

This will run the equivalent of

  GITURL=https://github.com/bencord0/scrumblr
  NAME="$(basename ${GITURL})"
  git clone "${GITURL}" "${TEMPDIR}/{NAME}"
  cd "${TEMPDIR}/${NAME}"

  docker build -t "localhost:5000/$NAME" .
  docker push "localhost:5000/$NAME"

  kubectl apply -f - <(m4 -D GITHASH=latest deployr.yml)

Note: there's nothing too special about m4, we're just using is for
templating some variables.

Deploy a specific commit
------------------------

  $ deployr https://github.com/bencord0/scrumblr ed4332d4480a24136bf18eaaab2c4ab2a0366a45

As above, this will clone, build and deploy an instance of scrumblr, but at a
specific snapshot of the code.

This is the equivalent of

  GITURL=https://github.com/bencord0/scrumblr
  GITHASH=ed4332d4480a24136bf18eaaab2c4ab2a0366a45
  NAME="$(basename ${GITURL})"
  git clone "${GITURL}" "${TEMPDIR}/{NAME}"
  cd "${TEMPDIR}/${NAME}"

  git reset --hard "${GITHASH}"

  docker build -t "localhost:5000/${NAME}:${GITHASH}" .
  docker push "localhost:5000/${NAME}:${GITHASH}"

  kubectl apply -f - <(m4 -D GITHASH="${GITHASH}" deployr.yml)

Deploy another instance of the application
------------------------------------------

You can run apps multiple times by specifying the `--appname`, or `-a` option.

  $ deployr -a scrumblr_one https://github.com/bencord0/scrumblr
  $ deployr -a scrumblr_two https://github.com/bencord0/scrumblr

Deploy a specific versions of the application
--------------------------------------------

  $ deployr -a yesterdays_app $repo $old_git_hash
  $ deployr -a todays_app $repo $new_git_hash


Subcommands
===========

Deploying using local code repositories
---------------------------------------

If `deployr` does not detect that the first argument is a git repository,
you can force using the deploy code by calling the `deploy` subcommand directly.

  $ deployr deploy ./path/to/repository [git hash]


Query for the deployment status
-------------------------------

  $ deployr info scrumblr

  scrumblr pod is available at 10.0.33.3

You can test the deployment by going to the address in your browser.

Delete an app
-------------

  $ deployr delete scrumblr

Use this command to clear up the resources once you are done with them.

About

A system to automatically provision and run web apps

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages