giddyup

command module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2015 License: Apache-2.0 Imports: 4 Imported by: 0

README

Giddyup

Purpose

Giddyup is a tool to that helps get services started in a Rancher compose stack. It aims to simplify entrypoint and command scripting to start your Docker services. This is a first pass at addressing common tasks when starting up applications in Docker containers on Rancher.

Current capabilities:

  • Get connection strings from DNS or Rancher Metadata.
  • Determine if your container is the leader in the service.
  • Proxy traffic to the leader
  • Wait for service to have the desired scale.

Examples

Determine if running container is the leader
#!/bin/bash
...
giddyup leader check
if [ "$?" -eq "0" ];then
   echo "I'm the leader"
fi
...
Wait for service scale

This is useful if you need to generate configurations based on all nodes in a service. Otherwise, each container will only get itself and the previous containers metadata.

#!/bin/bash
...
# wait upto 2 minutes for all containers to come up
./giddyup service wait scale --timeout 120
...
# Bring up the service
Get a Zookeeper connection string
#!/bin/bash
...
connection_string=$(./giddyup ip stringify --suffix :2181 zookeeper/zookeeper)
# Results in something like:
# 10.42.231.55:2181,10.42.145.91:2181,10.42.55.78:2181
...

Usage

ip stringify
NAME:
   giddyup ip stringify - Prints a joined list of IPs

USAGE:
   giddyup ip stringify [command options] [arguments...]

OPTIONS:
   --delimiter ","	Delimiter to use between entries
   --prefix 		Prepend Entries with this value
   --suffix 		Add this value to the end of each entry.
   --source "metadata"	Source to lookup IPs. [metadata, dns]

leader
NAME:
   giddyup leader - Determines if this container has lowest start index

USAGE:
   giddyup leader command [command options] [arguments...]

COMMANDS:
   check	Check if we are leader and exit.
   elect	Simple leader election with Rancher
   forward	Listen and forward all port traffic to leader.
   get		Get the leader of service
   help, h	Shows a list of commands or help for one command

OPTIONS:
   --help, -h	show help

elect and forward are to be used as entrypoints.

If elect is used, only the container determined by Rancher (lowest create_index) will run the service. A command must be given to the elect command to execute if the container becomes the leader. Otherwise all traffic is forwarded to the leader, and upon election the container will exit.

forward should be used in its own container. It works in situations where you want your service running all the time, for replication or something, but want all of the traffic to go to a specific (leader) host.

a forward example: giddyup leader forward --src-port 3307 --dst-port 3306

This will listen on port 3307 and forward to port 3306 on the leader. This allows you to put a service behind a load balancer, and still have traffic go to one place.

Service Wait
NAME:
   giddyup service wait - Wait for service states

USAGE:
   giddyup service wait command [command options] [arguments...]

COMMANDS:
   scale	Wait for number of service containers to reach set scale
   help, h	Shows a list of commands or help for one command

OPTIONS:
   --help, -h	show help

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Godeps
_workspace/src/github.com/Sirupsen/logrus
Package logrus is a structured logger for Go, completely API compatible with the standard library logger.
Package logrus is a structured logger for Go, completely API compatible with the standard library logger.
_workspace/src/github.com/codegangsta/cli
Package cli provides a minimal framework for creating and organizing command line Go applications.
Package cli provides a minimal framework for creating and organizing command line Go applications.
_workspace/src/golang.org/x/sys/unix
Package unix contains an interface to the low-level operating system primitives.
Package unix contains an interface to the low-level operating system primitives.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL