Merge pull request #1483 from rneugeba/demo-up

Add WIP files for demo
This commit is contained in:
Rolf Neugebauer 2017-04-04 14:03:25 +01:00 committed by GitHub
commit f08ff5cfa8
10 changed files with 238 additions and 0 deletions

View File

@ -0,0 +1,6 @@
# A dockerfile to build an etcd container image from the upstream one
# with a script as entry point
FROM quay.io/coreos/etcd:v3.1.5
COPY ./etcd.sh /
ENTRYPOINT ["/etcd.sh"]

View File

@ -0,0 +1,20 @@
This directory contains scripts/files to bootstrap a `etcd` cluster.
In the local, hyperkit based, setup, we use a `etcd` running in a
Docker for Mac container to bootstrap the cluster. For a cloud based demo, we'd use `https://discovery.etcd.io`. The host/DfM side is setup with [dfm-setup.sh](./dfm-setup.sh).
The moby `etcd` package is build with [build-pkg.sh](./build-pkg.sh). It take the official `etcd` container and adds a [script](./etcd.sh) to start `etcd`.
To run (for now):
- Start the etcd bootstrap container in on window:
```
./dfm-setup.sh
```
- In another window build/run the moby image:
```
./build-pkg.sh
moby build etcd
moby run etcd
```

View File

@ -0,0 +1,2 @@
#! /bin/sh
docker build -t mobylinux/etcd .

46
projects/demo/etcd/dfm-setup.sh Executable file
View File

@ -0,0 +1,46 @@
#! /bin/sh
##
## This script starts a etcd container which is used to bootstrap a
## local etcd cluster. The etcd container is started on a non-standard
## port to keep the standard port free for the cluster.
##
## If you have a local etcd installed (brew install etcd) you can
## point the cli at it as well:
##
## etcdctl --debug --endpoints http://0.0.0.0:2381 member list
##
# debug
set -x
set -v
# Change depending on the cluster size
NUMPEERS=1
# Start a local etcd for bootstrapping
NAME=etcd-bootstrap
PORT=2381
#UUID=$(uuidgen)
UUID=6c007a14875d53d9bf0ef5a6fc0257c817f0fb83
ID=$(docker run -d --rm --name ${NAME} \
-p ${PORT}:${PORT} \
quay.io/coreos/etcd:v3.1.5 /usr/local/bin/etcd \
--debug \
--name ${NAME} \
--listen-client-urls http://0.0.0.0:${PORT} \
--advertise-client-urls http://0.0.0.0:$PORT,http://192.168.65.2:$PORT \
--initial-cluster-token ${NAME} \
--initial-cluster-state new \
--auto-compaction-retention 0)
trap "docker kill ${ID}" 2
# Could poll until returns without error, but sleep for 2s for now
sleep 2
docker exec -t ${ID} etcdctl --endpoints http://0.0.0.0:${PORT} mk discovery/${UUID}/_config/size ${NUMPEERS}
echo "KEY: ${UUID}"
docker logs -f ${ID}

22
projects/demo/etcd/etcd.sh Executable file
View File

@ -0,0 +1,22 @@
#! /bin/sh
# debug
set -x
set -v
# Needs to come from metadata
UUID=6c007a14875d53d9bf0ef5a6fc0257c817f0fb83
DISCOVER_URL=http://192.168.65.2:2381/v2/keys/discovery/${UUID}
IP=$(ifconfig eth0 2>/dev/null|awk '/inet addr:/ {print $2}'|sed 's/addr://')
NAME=$(hostname)
/usr/local/bin/etcd \
--name ${NAME} \
--debug \
--log-package-levels etcdmain=DEBUG,etcdserver=DEBUG \
--initial-advertise-peer-urls http://${IP}:2380 \
--listen-peer-urls http://${IP}:2380 \
--listen-client-urls http://${IP}:2379,http://127.0.0.1:2379 \
--advertise-client-urls http://${IP}:2379 \
--discovery ${DISCOVER_URL}

View File

@ -0,0 +1,31 @@
kernel:
image: "mobylinux/kernel:4.9.x"
cmdline: "console=ttyS0 console=tty0 page_poison=1"
init: "mobylinux/init:00c3a5bbfd9794f4a3187fcc4a9f0c826c46d474"
system:
- name: sysctl
image: "mobylinux/sysctl:2cf2f9d5b4d314ba1bfc22b2fe931924af666d8c"
net: host
pid: host
ipc: host
capabilities:
- CAP_SYS_ADMIN
readonly: true
daemon:
- name: rngd
image: "mobylinux/rngd:3dad6dd43270fa632ac031e99d1947f20b22eec9@sha256:1c93c1db7196f6f71f8e300bc1d15f0376dd18e8891c8789d77c8ff19f3a9a92"
capabilities:
- CAP_SYS_ADMIN
oomScoreAdj: -800
readonly: true
- name: etcd
image: "mobylinux/etcd"
capabilities:
- CAP_NET_BIND_SERVICE
- CAP_CHOWN
- CAP_SETUID
- CAP_SETGID
- CAP_DAC_OVERRIDE
net: host
outputs:
- format: kernel+initrd

View File

@ -0,0 +1,30 @@
{
"ID": "cattle",
"Properties": {
"Allocation": {
"Size": 5
},
"Instance": {
"Plugin": "instance-hyperkit",
"Properties": {
"Moby": "nginx-4.10",
"Disk" : 512,
"CPUs" : 2,
"Memory" : 1024
}
},
"Flavor": {
"Plugin": "flavor-vanilla",
"Properties": {
"Init": [
"test1",
"test2"
],
"Tags": {
"tier": "sample",
"project": "infrakit"
}
}
}
}
}

View File

@ -0,0 +1,27 @@
kernel:
image: "mobylinux/kernel:4.10.x"
cmdline: "console=ttyS0 console=tty0 page_poison=1"
init: "mobylinux/init:00c3a5bbfd9794f4a3187fcc4a9f0c826c46d474"
system:
- name: sysctl
image: "mobylinux/sysctl:2cf2f9d5b4d314ba1bfc22b2fe931924af666d8c"
net: host
pid: host
ipc: host
capabilities:
- CAP_SYS_ADMIN
readonly: true
daemon:
- name: nginx
image: "nginx:alpine"
capabilities:
- CAP_NET_BIND_SERVICE
- CAP_CHOWN
- CAP_SETUID
- CAP_SETGID
- CAP_DAC_OVERRIDE
net: host
outputs:
- format: kernel+initrd
- format: iso-bios
- format: iso-efi

View File

@ -0,0 +1,27 @@
kernel:
image: "mobylinux/kernel:4.9.x"
cmdline: "console=ttyS0 console=tty0 page_poison=1"
init: "mobylinux/init:00c3a5bbfd9794f4a3187fcc4a9f0c826c46d474"
system:
- name: sysctl
image: "mobylinux/sysctl:2cf2f9d5b4d314ba1bfc22b2fe931924af666d8c"
net: host
pid: host
ipc: host
capabilities:
- CAP_SYS_ADMIN
readonly: true
daemon:
- name: nginx
image: "nginx:alpine"
capabilities:
- CAP_NET_BIND_SERVICE
- CAP_CHOWN
- CAP_SETUID
- CAP_SETGID
- CAP_DAC_OVERRIDE
net: host
outputs:
- format: kernel+initrd
- format: iso-bios
- format: iso-efi

View File

@ -0,0 +1,27 @@
kernel:
image: "mobylinux/kernel:4.9.x"
cmdline: "console=ttyS0 console=tty0 page_poison=1"
init: "mobylinux/init:00c3a5bbfd9794f4a3187fcc4a9f0c826c46d474"
system:
- name: sysctl
image: "mobylinux/sysctl:2cf2f9d5b4d314ba1bfc22b2fe931924af666d8c"
net: host
pid: host
ipc: host
capabilities:
- CAP_SYS_ADMIN
readonly: true
daemon:
- name: nginx
image: "nginx:alpine"
capabilities:
- CAP_NET_BIND_SERVICE
- CAP_CHOWN
- CAP_SETUID
- CAP_SETGID
- CAP_DAC_OVERRIDE
net: host
outputs:
- format: kernel+initrd
- format: iso-bios
- format: iso-efi