demo: Rename ./project/demo to ./project/etcd

With redis-os and README documentation moved elsewhere,
the demo directory only contains the etcd demo setup.
Rename it.

Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
Rolf Neugebauer 2017-04-25 12:32:57 +01:00
parent db6d3d7ed2
commit 77941b7216
23 changed files with 69 additions and 87 deletions

View File

@ -20,6 +20,7 @@ If you want to create a project, please submit a pull request to create a new di
- [Landlock LSM](landlock/) programmatic access control
- [Clear Containers](clear-containers/) Clear Containers image
- [Logging](logging/) Experimental logging tools
- [etcd cluster](etcd/) etcd cluster demo from DockerCon'17
## Current projects not yet documented
- VMWare support (VMWare)

View File

@ -1,40 +0,0 @@
This directory contains files used in Moby/LinuxKit DockerCon 2017
keynote demos. They mostly serve as examples and probably need
adjustments to your specific environment.
# Prerequisites
Most of the scripts/files assume you are on a Mac.
- Recent Docker for Mac installed (We used 17.05.0-ce-rc1-mac8 from the edge channel)
- For the GCP portion: `brew install google-cloud-sdk`
- Infrakit: Clone [infrakit](https://github.com/docker/infrakit) and
the [GCP plugin](https://github.com/docker/infrakit.gcp) for
infrakit. The GCP plugin, needs to be v0.1. For each, `make
build-in-container` and then copy the contents of `./build`
somewhere in your path.
# GCP Setup
You probably want to change the project/zone
```
export CLOUDSDK_CORE_PROJECT=docker4x
export CLOUDSDK_COMPUTE_ZONE=europe-west1-d
gcloud auth login
gcloud auth application-default login
```
You may also want to create ssh-keys and upload them. See the [Generating a new SSH key-pair section](https://cloud.google.com/compute/docs/instances/connecting-to-instance)
# Expose VMs ports on localhost
You can use a `socat` container to forward ports from the VM to localhost (via Docker for Mac), to make it easier to access some VMs. To build
```
(cd dockerfiles; docker build -t socat -f Dockerfile.socat .)
```
And then run:
```
docker run --rm -t -d -p 8080:8080 socat tcp-listen:6379,reuseaddr,fork tcp:192.168.65.100:6379
```
This forwards local (host) port `6379` to `192.168.65.100:6379`, so if you start, say the `redis-os` image, run `moby run -ip 196.168.65.100 redis-os`.

View File

@ -1,5 +0,0 @@
export CLOUDSDK_CORE_PROJECT=docker4x
export CLOUDSDK_COMPUTE_ZONE=us-central1-f
export CLOUDSDK_COMPUTE_MACHINE=n1-standard-2
PATH=$PATH:~/src/docker/linuxkit/bin

View File

@ -1,4 +0,0 @@
#! /bin/sh
docker build -t moby/etcd .
docker build -t etcd.local -f Dockerfile.local .

View File

@ -1 +0,0 @@
/data

View File

@ -1,2 +0,0 @@
FROM prom/prometheus
ADD prometheus.yml /etc/prometheus/

View File

@ -1,2 +0,0 @@
FROM prom/prometheus:v1.6.0
ADD prometheus-us-central.yml /etc/prometheus/prometheus.yml

View File

@ -1,3 +0,0 @@
#! /bin/sh
docker build -t moby/prom-us-central1-f -f Dockerfile.us-central1-f .

View File

@ -1,20 +1,66 @@
This directory contains scripts/files to bootstrap a `etcd` cluster both on the local machine as well as on Google Cloud.
This directory contains files used in Moby/LinuxKit DockerCon 2017
keynote etcd cluster demo. They mostly serve as examples and probably
need adjustments to your specific environment. They may also break
over time :)
## Prerequisites
Most of the scripts/files assume you are on a Mac.
- Recent Docker for Mac installed (We used 17.05.0-ce-rc1-mac8 from the edge channel)
- For the GCP portion: `brew install google-cloud-sdk`
- Infrakit: Clone [infrakit](https://github.com/docker/infrakit) and
the [GCP plugin](https://github.com/docker/infrakit.gcp) for
infrakit. The GCP plugin, needs to be v0.1. For each, `make
build-in-container` and then copy the contents of `./build`
somewhere in your path.
## etcd cluster setup
An `etcd` cluster can be bootstrapped in different ways (see the [Documentation](https://coreos.com/etcd/docs/latest/op-guide/clustering.html) for more details. For the demo we use configuration via static IP addresses. With Infrakit these are managed by assigning `LogicalID`s to cluster members. The `LogicalID` is interpreted as a IP address.
The moby `etcd` package is build with [build-pkg.sh](./build-pkg.sh). It takes the official `etcd` container and adds a [script](./etcd.sh) to start `etcd`. [etcd.sh](./etcd.sh) first attempts to join a new cluster. If that fails it attempts to join an existing cluster. Note, the number and members of the cluster are somewhat hard coded in the script.
The `etcd` package takes the official `etcd` container and adds a
[script](./pkg/etcd.sh) to start `etcd`. [etcd.sh](./pkg/etcd.sh)
first attempts to join a new cluster. If that fails it attempts to
join an existing cluster. Note, the number and members of the cluster
are somewhat hard coded in the script.
Each node is also configured with a disk, which is mounted inside the
`etcd` container. `etcd` uses it to keep some state to help with
restarts.
## GCP Setup
You probably want to change the project/zone
```
export CLOUDSDK_CORE_PROJECT=docker4x
export CLOUDSDK_COMPUTE_ZONE=europe-west1-d
gcloud auth login
gcloud auth application-default login
```
You may also want to create ssh-keys and upload them. See the [Generating a new SSH key-pair section](https://cloud.google.com/compute/docs/instances/connecting-to-instance)
Note, the demo uses static IP addresses and they are specific to our
setup. The IP addresses need to be changed in the `infrakit-gcp.json`
config file.
In order to use the static IP addresses we created a custom network:
```
gcloud compute networks create rneugeba-demo --mode auto
gcloud compute networks subnets list
# get IP subnet for rneugeba-demo
gcloud compute firewall-rules create rneugeba-demo-internal --network \
rneugeba-demo --allow tcp,udp,icmp --source-ranges 10.132.0.0/9
```
The firewall setup means that all our projects networks can talk to the demo
network.
## Preparation
- Build the `etcd` image and then moby image inside the `pkg` directory:
```
./build-pkg.sh
moby build etcd
```
We create a number of local packages, not pulled from Hub. To build them, invoke `./build-pkg.sh` in the `./pkg` directory.
Then build the various YAML files using the `moby` tool and package/upload them to Google Cloud using the `linuxkit` tool.
## InfraKit cluster setup
@ -44,29 +90,6 @@ You can perform rolling updates, by for example, switching the kernel version in
## Infrakit GCP setup
You need to do the general setup as described in the demo [README](../README.md). Specifically, you need the `CLOUDSDK_*` environment variables set and you need to have authenticated with GCP.
Note, the demo uses static IP addresses and they are specific to our
setup. The IP addresses need to be changed in the `infrakit-gcp.json`
config file.
In order to use the static IP addresses we created a custom network:
```
gcloud compute networks create rneugeba-demo --mode auto
gcloud compute networks subnets list
# get IP subnet for rneugeba-demo
gcloud compute firewall-rules create rneugeba-demo-internal --network \
rneugeba-demo --allow tcp,udp,icmp --source-ranges 10.132.0.0/9
```
The firewall setup means that all our projects networks can talk to the demo
network.
Build the image and upload it:
```
moby build etcd
```
Start infrakit as above:
```
./start-infrakit
@ -76,3 +99,7 @@ Commit the configuration:
```
infrakit group commit infrakit-gcp.json
```
## Prometheus server
The etcd nodes use the Prometheus node exported. You can use the prometheus server image, also in this directory, to collect statistics from etc node. We currently build a specific Prometheus images with hard coded IP addresses. Ideally, the information should be passed in via the metadata/userdata.

View File

@ -0,0 +1,2 @@
FROM prom/prometheus
ADD etc/prometheus-local.yml /etc/prometheus/prometheus.yml

View File

@ -0,0 +1,2 @@
FROM prom/prometheus
ADD etc/prometheus-us-central.yml /etc/prometheus/prometheus.yml

7
projects/etcd/pkg/build-pkg.sh Executable file
View File

@ -0,0 +1,7 @@
#! /bin/sh
docker build -t moby/etcd -f Dockerfile.etcd .
docker build -t etcd.local -f Dockerfile.etcd.local .
docker build -t moby/prom-us-central1-f -f Dockerfile.prom.us-central1-f .
docker build -t moby/prom-local -f Dockerfile.prom.local .