diff --git a/projects/README.md b/projects/README.md index 2a87f2321..04792888b 100644 --- a/projects/README.md +++ b/projects/README.md @@ -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) diff --git a/projects/demo/README.md b/projects/demo/README.md deleted file mode 100644 index fc669e967..000000000 --- a/projects/demo/README.md +++ /dev/null @@ -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`. diff --git a/projects/demo/env.sh b/projects/demo/env.sh deleted file mode 100644 index 1e636b61d..000000000 --- a/projects/demo/env.sh +++ /dev/null @@ -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 diff --git a/projects/demo/etcd/pkg/build-pkg.sh b/projects/demo/etcd/pkg/build-pkg.sh deleted file mode 100755 index 30e8f92a2..000000000 --- a/projects/demo/etcd/pkg/build-pkg.sh +++ /dev/null @@ -1,4 +0,0 @@ -#! /bin/sh -docker build -t moby/etcd . - -docker build -t etcd.local -f Dockerfile.local . diff --git a/projects/demo/prom/.gitignore b/projects/demo/prom/.gitignore deleted file mode 100644 index 3af0ccb68..000000000 --- a/projects/demo/prom/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/data diff --git a/projects/demo/prom/Dockerfile b/projects/demo/prom/Dockerfile deleted file mode 100644 index 0e07679dd..000000000 --- a/projects/demo/prom/Dockerfile +++ /dev/null @@ -1,2 +0,0 @@ -FROM prom/prometheus -ADD prometheus.yml /etc/prometheus/ diff --git a/projects/demo/prom/Dockerfile.us-central1-f b/projects/demo/prom/Dockerfile.us-central1-f deleted file mode 100644 index c8e5cfd33..000000000 --- a/projects/demo/prom/Dockerfile.us-central1-f +++ /dev/null @@ -1,2 +0,0 @@ -FROM prom/prometheus:v1.6.0 -ADD prometheus-us-central.yml /etc/prometheus/prometheus.yml diff --git a/projects/demo/prom/build-prom.sh b/projects/demo/prom/build-prom.sh deleted file mode 100755 index 729354108..000000000 --- a/projects/demo/prom/build-prom.sh +++ /dev/null @@ -1,3 +0,0 @@ -#! /bin/sh - -docker build -t moby/prom-us-central1-f -f Dockerfile.us-central1-f . diff --git a/projects/demo/etcd/README.md b/projects/etcd/README.md similarity index 51% rename from projects/demo/etcd/README.md rename to projects/etcd/README.md index a86b88236..b96103f5f 100644 --- a/projects/demo/etcd/README.md +++ b/projects/etcd/README.md @@ -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. diff --git a/projects/demo/etcd/etcd.yml b/projects/etcd/etcd.yml similarity index 100% rename from projects/demo/etcd/etcd.yml rename to projects/etcd/etcd.yml diff --git a/projects/demo/etcd/infrakit-gcp.json b/projects/etcd/infrakit-gcp.json similarity index 100% rename from projects/demo/etcd/infrakit-gcp.json rename to projects/etcd/infrakit-gcp.json diff --git a/projects/demo/etcd/infrakit.json b/projects/etcd/infrakit.json similarity index 100% rename from projects/demo/etcd/infrakit.json rename to projects/etcd/infrakit.json diff --git a/projects/demo/etcd/pkg/Dockerfile b/projects/etcd/pkg/Dockerfile.etcd similarity index 100% rename from projects/demo/etcd/pkg/Dockerfile rename to projects/etcd/pkg/Dockerfile.etcd diff --git a/projects/demo/etcd/pkg/Dockerfile.local b/projects/etcd/pkg/Dockerfile.etcd.local similarity index 100% rename from projects/demo/etcd/pkg/Dockerfile.local rename to projects/etcd/pkg/Dockerfile.etcd.local diff --git a/projects/etcd/pkg/Dockerfile.prom.local b/projects/etcd/pkg/Dockerfile.prom.local new file mode 100644 index 000000000..8da667705 --- /dev/null +++ b/projects/etcd/pkg/Dockerfile.prom.local @@ -0,0 +1,2 @@ +FROM prom/prometheus +ADD etc/prometheus-local.yml /etc/prometheus/prometheus.yml diff --git a/projects/etcd/pkg/Dockerfile.prom.us-central1-f b/projects/etcd/pkg/Dockerfile.prom.us-central1-f new file mode 100644 index 000000000..088763e48 --- /dev/null +++ b/projects/etcd/pkg/Dockerfile.prom.us-central1-f @@ -0,0 +1,2 @@ +FROM prom/prometheus +ADD etc/prometheus-us-central.yml /etc/prometheus/prometheus.yml diff --git a/projects/etcd/pkg/build-pkg.sh b/projects/etcd/pkg/build-pkg.sh new file mode 100755 index 000000000..95c3e0a22 --- /dev/null +++ b/projects/etcd/pkg/build-pkg.sh @@ -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 . diff --git a/projects/demo/prom/prometheus-local.yml b/projects/etcd/pkg/etc/prometheus-local.yml similarity index 100% rename from projects/demo/prom/prometheus-local.yml rename to projects/etcd/pkg/etc/prometheus-local.yml diff --git a/projects/demo/prom/prometheus-us-central.yml b/projects/etcd/pkg/etc/prometheus-us-central.yml similarity index 100% rename from projects/demo/prom/prometheus-us-central.yml rename to projects/etcd/pkg/etc/prometheus-us-central.yml diff --git a/projects/demo/prom/prometheus.yml b/projects/etcd/pkg/etc/prometheus.yml similarity index 100% rename from projects/demo/prom/prometheus.yml rename to projects/etcd/pkg/etc/prometheus.yml diff --git a/projects/demo/etcd/pkg/etcd.sh b/projects/etcd/pkg/etcd.sh similarity index 100% rename from projects/demo/etcd/pkg/etcd.sh rename to projects/etcd/pkg/etcd.sh diff --git a/projects/demo/prom/etcd-prom-us-central1-f.yml b/projects/etcd/prom-us-central1-f.yml similarity index 100% rename from projects/demo/prom/etcd-prom-us-central1-f.yml rename to projects/etcd/prom-us-central1-f.yml diff --git a/projects/demo/etcd/start-infrakit.sh b/projects/etcd/start-infrakit.sh similarity index 100% rename from projects/demo/etcd/start-infrakit.sh rename to projects/etcd/start-infrakit.sh