Giter Club home page Giter Club logo

shipbuilder's Introduction

ShipBuilder

This is ShipBuilder v2.0, based on LXC 2.

The legacy v1.0 branch lives on in maintenance mode.

About

ShipBuilder is a git-based application deployment and serving system (PaaS) written in Go.

Primary components:

  • ShipBuilder command-line client
  • ShipBuilder server
  • Container management (LXC 2.x)
  • HTTP load balancer (HAProxy)

Requirements

The server has been tested and verified compatible with Ubuntu 16.04.

Releases may be downloaded, or built on a Ubuntu Linux or macOS machine, provided the following are installed and available in the build environment:

  • golang v1.9+
  • git and bzr clients
  • go-bindata (go get -u github.com/jteeuwen/go-bindata/...)
  • fpm (for building debs and RPMs, automatic installation available via make deps)
  • daemontools v0.76+ (for envdir)
  • Amazon AWS credentials + an s3 bucket

Build Packs

Any server application can be run on ShipBuilder, but it will need a corresponding build-pack! The current supported build-packs are:

  • python - Any python 2.x app
  • nodejs - Node.js apps
  • java8-mvn - Java 8 + Maven
  • java9-mvn - Java 9 + Maven
  • scala-sbt - Scala SBT applications and projects
  • playframework2 - Play-framework 2.1.x

Server Installation

See SERVER.md

TODO 2017-10-24: Create additional buildpack provider which uses FS with bindata as a fallthrough, to enable real-time overrides without recompile.

TODO: lxd init ??

TODO: 2017-12-03: Fix sb-server /etc/shipbuilder dir permissions to disallow other users from viewing the directory contents (downgrade 3rd party perms).

TODO: 2017-12-04: Fix port allocation bug triggered by blind port incrementing, grep for '// Then attempt start it again.' for relevant section of cmd_deploy.go.

TODO: 2017-12-16: Figure out why shutdown_container.py isn't purging iptables rules.

Why isn't the LB gettng updated hap configs?

Also: Revisit git push weirdness / workaround hacks.

TODO: Test rollbacks. TODO: Automatically scrub old app images from slaves.

TODO: Additional protection against dyno port conflicts via checking against running containers on the host during launch in container_start.py.

TODO: Disable remaining services in ubuntu container, e.g.:

TODO: Package SB-logger as a standalone program and stop embedding the full sb binary. Security practice improvement.

/sbin/init /lib/systemd/systemd-journald /lib/systemd/systemd-udevd /lib/systemd/systemd-logind /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation /sbin/dhclient -1 -v -pf /run/dhclient.eth0.pid -lf /var/lib/dhcp/dhclient.eth0.leases -I -df /var/lib/dhcp/dhclient6.eth0.leases eth0 /sbin/agetty --noclear --keep-baud console 115200 38400 9600 linux [ssh] /bin/sh /usr/lib/apt/apt.systemd.daily install /bin/sh /usr/lib/apt/apt.systemd.daily lock_is_held install /usr/bin/python3 /usr/bin/unattended-upgrade


Note: it's now recommended to ensure $sbHost is set to a domain name.. example: install/node.sh 2nd ssh cmd.

TOOD: PORT ALLOCATION BUG - could be caused by the tmp.sh during deploy; when there's an error it blindly tries incrementing the port...

2017-12-17: =Idea= What about tracking user activity logging + queries w/ fields: USERNAME . Remember how USERNAME is a difficult thing to infer with the present iteration of shipbuilder. Perhaps make it a pluggable "Addon" or "Module", "Dynamic Plugin Module, etc. One is the current scheme of not caring about or handling anything. Maybe it's a plugin which simply enforces that the other spydaddy plugin isn't installed? Then there is the most granular scenario of the current username where both the username, timestamp, and argv are embedded alongside a system account producing start/stop(/error?) messages. Finally, consider the middleground of not forcing users to get their own accounts, this exists as a clean subset of the more complete solution.

(Also: LDAP integration?)

TODO: 2017-12-18 (Mon) Fix needed for SB client exiting with 0 status code even when connecting to sb-server failed.

TODO: 2017-12-20: SB client can be fixed by adding 'ruok' equivalent in client.go.

TODO: 2017-12-12: Make backup of HAProxy cfg before overwriting, then restore orig config if hap svc restart fails.

TODO: 2017-12-28: Add "git remote add shipbuilder ssh://xxxxxxxxxx" to apps:create output.

Client

See CLIENT.md

TODO 2017-10-15: Migrate client commands to cli.v2.

Creating your first app

All applications need a Procfile. In ShipBuilder, these are 100% compatible with Heroku's Procfiles (documentation).

See TUTORIAL.md

Development

Sample development workflow:

  1. Make local edits
  2. Run:
make clean deb \
    && rsync -azve ssh dist/*.deb dev-host.lan:/tmp/ \
    && ssh dev-host.lan /bin/sh -c \
        'set -e && cd /tmp/ ' \
        '&& sudo --non-interactive dpkg -i *.deb && rm *.deb ' \
        '&& sudo --non-interactive systemctl daemon-reload ' \
        '&& sudo --non-interactive systemctl restart shipbuilder'

Thanks

Thank you to SendHub for supporting the initial development of this project.

shipbuilder's People

Contributors

cameronnemo avatar ecoleman avatar jaytaylor avatar josegonzalez avatar rdpfeffer avatar trevors avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shipbuilder's Issues

Need a way to reliably destroy ZFS containers

Need a way to reliably destroy ZFS containers when there are child dependencies.

ubuntu@ip-10-60-86-207:~$ sudo lxc-destroy -n myapp-s5
cannot destroy 'tank/myapp-s5': filesystem has children
use '-r' to destroy the following datasets:
tank/myapp-s5@myapp-s5_v2_web_10002
tank/myapp-s5@myapp-s5_v3_web_10001
lxc_container: Error destroying rootfs for myapp-s5
Destroying myapp-s5 failed
ubuntu@ip-10-60-86-207:~$

Config unset/remove doesn't work

Calling shipbuilder get:remove VARIABLE -aAPP is not properly removing the variable from the environment. For ex:

$ shipbuilder config:get POSTGRES_ENGINE -aAPP
Client connecting via 'ubuntu@APP..
django_postgrespool

$ shipbuilder config:remove POSTGRES_ENGINE -aAPP
Client connecting via 'ubuntu@APP..
0:01 === Removing environment variables..
0:01
Finished removing environment variables.
0:01 NOTICE: Redeploy deferred, changes will not be active until next deploy is triggered

Notice that no environment variables were removed.
Additionally, I don't believe that this should have been deferred.

Creating new node cannot create zpool

When attempting to create a new node like so:

./install/node.sh -H sb-node7a -d /dev/xvdb -s /dev/xvdc install

I get the following error:

info: installLxc() succeeded
info: attempting to unmount /mnt and /dev/xvdb to be safe
info: existing fs type on /dev/xvdb is ext4
info: formatting /dev/xvdb with zfs
invalid vdev specification
use '-f' to override the following errors:
/dev/xvdb is part of potentially active pool 'tank'
error: command 'sudo zpool create -o ashift=12 tank /dev/xvdb' exited with non-zero status 1
error: remote prepareNode() invocation exited with non-zero status 1

If I don't specify the swap device, i get a different error:

./install/node.sh -H sb-node7a -d /dev/xvdb install
info: auto-detected shipbuilder host: ubuntu@sb
info: auto-detected lxc filesystem: zfs
info: auto-detected zfs pool: tank
info: verifying ssh and sudo access for 2 hosts
info: testing host ubuntu@sb .. succeeded
info: testing host sb-node7a .. succeeded
....
sent 80 bytes received 20 bytes 28.57 bytes/sec
total size is 31289 speedup is 312.89
error: prepareNode() missing required zfs parameter: $zfsPool
error: remote prepareNode() invocation exited with non-zero status 1

The relevant env nodes are:

$ cat env/LXC_FS
zfs
brock ~/dev/sendhub/shipbuilder [master*]
$ cat env/ZFS_POOL
tank

Any ideas?

Idea: service on all container nodes for iptables sync

Service on all container nodes which periodically syncs the iptables to match the currently listed containers.

  • Upon finding a mis-match, emits warning messge to log.
  • Automatically corrects the port situation.

This would be great because sometimes the iptables rules mysteriously get out of sync for the running containers on the system, leading to this emerging as a habitual pattern for LB<=>Container communication failure.

New Nodes Become Unresponsive

Wondering if you have any suggestions on the following.

I recently new nodes on our installation based on the ami build-nd-5. Upon initial deploy to them, they appear fine but after some period of time they no longer properly report their IP back to the shipbuilder server:

..
3:46 [sb-node7a] [s1_v473_egress_10002] - error retrieving ip
3:46 Retrying starting app dyno egress on host sb-node7a, failure reason: exit status 1
..

After the deploy, when inspecting the dynos on the node, everything looks fine. The dyno is running and I haven't found any problems with it with the exception that the shipbuilder server doesn't get the ip and thus doesn't update iptables/the loadbalancer to send traffic to it.

If you have any suggestions, it would be much appreciated.

command line options

Would be cool if you could add help to the command line and offer more options in terms of node management

shipbuilder -h or --help

shipbuilder list (shows running containers)

apps:destroy command doesn't kill the app entirely

After a number of failed builds, I ran apps:destroy -a{name} and the command ran successfully, but running logs -a{name} still shows a continuos stream of network events and app output. logs is the only command that works, any other command will return Unknown application error.

Dyno upstart improvements

So, the main problem you're going to run into with this setup is that Upstart has syscall hook based PID-tracking which it uses to keep track of the processes it is supposed to manage during the launch process. Since you are using start-stop-daemon to run /app/run-in-context, then using that to run /app/runs, then running multiple PIDs from /app/run, this is three layers of PID indirection which will confuse upstart greatly and cause it to get mixed up when it sends signals to downstream processes and potentially create a number of unresponsive, unreliable, and/or orphan PIDs.

This setup could be made more reliable by making the /app/run be called from Upstart directly without start-stop-daemon, then place a signal handler into /app/run which passes any signals it receives down to every child process it owns. An easy way of doing that can be, if your pid happened to be 12345, you can pass the signal to -12345 to send it to your entire POSIX Process Group. Or you can keep appending the $$ value to some list in bash, then loop across the list in the handler to signal all subprocesses using the signal received from above. Another option is to make a pre-stop hook which sends the signals where they are needed before the stop hook stops the master process.

Another option: make a separate upstart config for each daemon in the Procfile, so Upstart can watch each of them. Then use some of Upstart's dependencies, to make a task which depends on all the others to perform the starts and stops, while Upstart will be able to see each PID. Then, in the bash launcher of each task, use the exec function to launch the tasks, which causes them to inherit bash's PID. Then the PID it runs with and the PID Upstart expects are the same, and you get reliable operation.

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.