forked from paulczar/docker-percona_galera
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser-data.erb
73 lines (72 loc) · 2.57 KB
/
user-data.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#cloud-config
coreos:
etcd:
#generate a new token for each unique cluster from https://discovery.etcd.io/new
<%= @etcd_discovery %>
addr: $public_ipv4:4001
peer-addr: $public_ipv4:7001
units:
- name: etcd.service
command: start
- name: fleet.service
command: start
- name: docker-tcp.socket
command: start
enable: true
content: |
[Unit]
Description=Docker Socket for the API
[Socket]
ListenStream=4243
Service=docker.service
BindIPv6Only=both
[Install]
WantedBy=sockets.target
- name: database-data.service
command: start
enable: true
content: |
[Unit]
Description=database data
After=docker.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStartPre=/usr/bin/docker pull paulczar/percona-galera:latest
ExecStart=/bin/sh -c "/usr/bin/docker inspect database-data >/dev/null 2>&1 || docker run --name database-data -v /var/lib/mysql paulczar/percona-galera:latest true"
- name: database.service
command: <%= @command %>
enable: true
content: |
[Unit]
Description=database
After=database-data.service
[Service]
Restart=always
EnvironmentFile=/etc/environment
TimeoutStartSec=20m
ExecStartPre=/usr/bin/docker pull paulczar/percona-galera:latest
ExecStart=/bin/sh -c "/usr/bin/docker run --name database --rm -p 3306:3306 -p 4444:4444 -p 4567:4567 -p 4568:4568 -e PUBLISH=3306 -e HOST=$COREOS_PRIVATE_IPV4 -e CLUSTER=galera --volumes-from database-data paulczar/percona-galera:latest"
ExecStop=/usr/bin/docker stop database
write_files:
- path: /etc/motd
content: "Database Cluster Demo\n"
- path: /etc/profile.d/db-functions.sh
permissions: '0755'
content: |
function nse() {
sudo nsenter --pid --uts --mount --ipc --net --target $(docker inspect --format="{{ .State.Pid }}" $1)
}
function dev_db() {
eval `cat /etc/environment`
/usr/bin/docker run -it -e DEBUG=1 -p 3306:3306 -p 4444:4444 -p 4567:4567 -p 4568:4568 -e PUBLISH=3306 -e HOST=$COREOS_PRIVATE_IPV4 -e CLUSTER=galera paulczar/percona-galera:latest bash
}
function database() {
sudo nsenter --pid --uts --mount --ipc --net --target $(docker inspect --format="{{ .State.Pid }}" database)
}
function rebuild() {
docker build -t paulczar/percona-galera /home/core/share
}
function cleanup() {
etcdctl rm --recursive /database
}