-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved configuration #14
Changes from 2 commits
63940ec
eeb56bd
e3e8bb5
6b26dc3
749f356
5cce24a
b53d8a7
68eb75a
34e55c5
3dc9d66
69ca45c
e82ee84
9239d16
3505716
26b02e3
4279577
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,2 @@ | ||
# build outputs | ||
*.pyc | ||
|
||
# credentials | ||
_env* | ||
manta | ||
manta.pub | ||
|
||
# temp | ||
python-manta/ | ||
.DS_Store | ||
_env |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,11 @@ FROM percona:5.6 | |
|
||
RUN apt-get update \ | ||
&& apt-get install -y \ | ||
python \ | ||
python-dev \ | ||
gcc \ | ||
curl \ | ||
percona-xtrabackup \ | ||
python \ | ||
python-dev \ | ||
gcc \ | ||
curl \ | ||
percona-xtrabackup \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# get Python drivers MySQL, Consul, and Manta | ||
|
@@ -17,22 +17,25 @@ RUN curl -Ls -o get-pip.py https://bootstrap.pypa.io/get-pip.py && \ | |
python-Consul==0.4.7 \ | ||
manta==2.5.0 | ||
|
||
# get Containerpilot release | ||
RUN export CP_VERSION=2.0.1 &&\ | ||
curl -Lo /tmp/containerpilot.tar.gz \ | ||
https://github.com/joyent/containerpilot/releases/download/${CP_VERSION}/containerpilot-${CP_VERSION}.tar.gz && \ | ||
tar -xzf /tmp/containerpilot.tar.gz && \ | ||
mv /containerpilot /bin/ | ||
# Add ContainerPilot and set its configuration file path | ||
ENV CONTAINERPILOT_VER 2.0.1 | ||
ENV CONTAINERPILOT file:///etc/containerpilot.json | ||
RUN export CONTAINERPILOT_CHECKSUM=a4dd6bc001c82210b5c33ec2aa82d7ce83245154 \ | ||
&& curl -Lso /tmp/containerpilot.tar.gz \ | ||
"https://github.com/joyent/containerpilot/releases/download/${CONTAINERPILOT_VER}/containerpilot-${CONTAINERPILOT_VER}.tar.gz" \ | ||
&& echo "${CONTAINERPILOT_CHECKSUM} /tmp/containerpilot.tar.gz" | sha1sum -c \ | ||
&& tar zxf /tmp/containerpilot.tar.gz -C /usr/local/bin \ | ||
&& rm /tmp/containerpilot.tar.gz | ||
|
||
# configure Containerpilot and MySQL | ||
COPY bin/* /bin/ | ||
# configure ContainerPilot and MySQL | ||
COPY etc/* /etc/ | ||
COPY bin/* /usr/local/bin/ | ||
|
||
# override the parent entrypoint | ||
ENTRYPOINT [] | ||
|
||
# use --console to get error logs to stderr | ||
CMD [ "/bin/containerpilot", \ | ||
CMD [ "/usr/local/bin/containerpilot", \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason not to drop the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Like we do one line later with |
||
"mysqld", \ | ||
"--console", \ | ||
"--log-bin=mysql-bin", \ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,11 @@ | |
|
||
MySQL designed for container-native deployment on Joyent's Triton platform. This repo serves as a blueprint demonstrating the autopilot design pattern -- automatically setting up replication, backups, and failover without human intervention. | ||
|
||
[![DockerPulls](https://img.shields.io/docker/pulls/autopilotpattern/mysql.svg)](https://registry.hub.docker.com/u/autopilotpattern/mysql/) | ||
[![DockerStars](https://img.shields.io/docker/stars/autopilotpattern/mysql.svg)](https://registry.hub.docker.com/u/autopilotpattern/mysql/) | ||
[![ImageLayers](https://badge.imagelayers.io/autopilotpattern/mysql:latest.svg)](https://imagelayers.io/?images=autopilotpattern/mysql:latest) | ||
[![Join the chat at https://gitter.im/autopilotpattern/mysql](https://badges.gitter.im/autopilotpattern/mysql.svg)](https://gitter.im/autopilotpattern/mysql) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
--- | ||
|
||
## Architecture | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ | |
|
||
log = logging.getLogger('triton-mysql') | ||
|
||
consul = pyconsul.Consul(host=os.environ.get('TRITON_MYSQL_CONSUL', 'consul')) | ||
consul = pyconsul.Consul(host=os.environ.get('CONSUL', 'consul')) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For #11 |
||
config = None | ||
|
||
# consts for node state | ||
|
@@ -175,7 +175,7 @@ def __init__(self): | |
self.user = os.environ.get('MANTA_SUBUSER', None) | ||
self.role = os.environ.get('MANTA_ROLE', None) | ||
self.key_id = os.environ.get('MANTA_KEY_ID', None) | ||
self.private_key = os.environ.get('MANTA_PRIVATE_KEY') | ||
self.private_key = os.environ.get('MANTA_PRIVATE_KEY') # @TODO: need changes here | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will need to be aware of the text munging of the input. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should do it: self.private_key = os.environ.get('MANTA_PRIVATE_KEY').replace('#', '\n') |
||
self.url = os.environ.get('MANTA_URL', | ||
'https://us-east.manta.joyent.com') | ||
self.bucket = os.environ.get('MANTA_BUCKET', | ||
|
@@ -205,13 +205,13 @@ def put_backup(self, backup_id, infile): | |
|
||
class Containerpilot(object): | ||
""" | ||
Containerpilot config is where we rewrite Containerpilot's own config | ||
Containerpilot config is where we rewrite ContainerPilot's own config | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I correctly capitalized ContainerPilot in all the text, but left it as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can always just capitalize the |
||
so that we can dynamically alter what service we advertise | ||
""" | ||
|
||
def __init__(self, node): | ||
# TODO: we should make sure we can support JSON-in-env-var | ||
# the same as Containerpilot itself | ||
# the same as ContainerPilot itself | ||
self.node = node | ||
self.path = os.environ.get('CONTAINERPILOT').replace('file://', '') | ||
with open(self.path, 'r') as f: | ||
|
@@ -231,12 +231,12 @@ def render(self): | |
f.write(new_config) | ||
|
||
def reload(self): | ||
""" force Containerpilot to reload its configuration """ | ||
log.info('Reloading Containerpilot configuration.') | ||
""" force ContainerPilot to reload its configuration """ | ||
log.info('Reloading ContainerPilot configuration.') | ||
os.kill(1, signal.SIGHUP) | ||
|
||
# --------------------------------------------------------- | ||
# Top-level functions called by Containerpilot or forked by this program | ||
# Top-level functions called by ContainerPilot or forked by this program | ||
|
||
def on_start(): | ||
""" | ||
|
@@ -257,7 +257,7 @@ def on_start(): | |
def health(): | ||
""" | ||
Run a simple health check. Also acts as a check for whether the | ||
Containerpilot configuration needs to be reloaded (if it's been | ||
ContainerPilot configuration needs to be reloaded (if it's been | ||
changed externally), or if we need to make a backup because the | ||
backup TTL has expired. | ||
""" | ||
|
@@ -793,7 +793,7 @@ def write_snapshot(conn): | |
# create_snapshot call and return. The snapshot process will be | ||
# re-parented to Containerpilot | ||
set_backup_ttl() | ||
subprocess.Popen(['python', '/bin/triton-mysql.py', 'create_snapshot']) | ||
subprocess.Popen(['python', '/usr/local/bin/triton-mysql.py', 'create_snapshot']) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Couldn't this rely on |
||
|
||
def set_backup_ttl(): | ||
""" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,33 @@ | ||
mysql: | ||
extends: | ||
file: common-compose.yml | ||
service: mysql | ||
links: | ||
- consul:consul | ||
image: autopilotpattern/mysql:latest | ||
mem_limit: 4g | ||
restart: always | ||
# expose for linking, but each container gets a private IP for | ||
# internal use as well | ||
expose: | ||
- 3306 | ||
labels: | ||
- triton.cns.services=mysql | ||
env_file: _env | ||
environment: | ||
- CONTAINERPILOT=file:///etc/containerpilot.json | ||
- MANTA_PRIVATE_KEY | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can (and probably should) eliminate this line because we're getting it from the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that was the issue I was facing in #14 (comment) |
||
|
||
consul: | ||
extends: | ||
file: common-compose.yml | ||
service: consul | ||
image: progrium/consul:latest | ||
command: -server -bootstrap -ui-dir /ui | ||
restart: always | ||
mem_limit: 128m | ||
ports: | ||
- 8500 | ||
expose: | ||
- 53 | ||
- 8300 | ||
- 8301 | ||
- 8302 | ||
- 8400 | ||
- 8500 | ||
dns: | ||
- 127.0.0.1 | ||
labels: | ||
- triton.cns.services=consul |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
mysql: | ||
extends: | ||
file: common-compose.yml | ||
file: docker-compose.yml | ||
service: mysql | ||
mem_limit: 512m | ||
build: . | ||
environment: | ||
- CONSUL=consul | ||
links: | ||
- consul:consul | ||
ports: | ||
- 3306 | ||
|
||
consul: | ||
extends: | ||
file: common-compose.yml | ||
file: docker-compose.yml | ||
service: consul | ||
ports: | ||
- 8500:8500 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd love to try adding the
pip install
steps in here so we canapt-get purge
GCC after it's done its job, similar to https://github.com/autopilotpattern/nfsserver/blob/wip/Dockerfile#L8-L19.