Files
linuxkit/projects/demo/etcd

This directory contains scripts/files to bootstrap a etcd cluster both on the local machine as well as on Google Cloud.

An etcd cluster can be bootstrapped in different ways (see the Documentation for more details. For the demo we use configuration via static IP addresses. With Infrakit these are managed by assigning LogicalIDs to cluster members. The LogicalID is interpreted as a IP address.

The moby etcd package is build with build-pkg.sh. It takes the official etcd container and adds a script to start etcd. 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.

Preparation

  • Build the etcd image and then moby image:
./build-pkg.sh
moby build etcd

InfraKit cluster setup (OUTDATED)

This should create a HyperKit based, InfraKit managed etcd cluster with 5 etcd instances.

Start InfraKit:

./start-infrakit

Note: The HyperKit InfraKit plugin must be started from the directory where the etcd mobylinux image is located.

Now, commit the new config:

infrakit group commit infrakit.json

To check if everything is fine, we created (above) a local etcd.local docker image which already has the environment set up to contact the cluster:

docker run --rm -ti etcd.local etcdctl member list
docker run --rm -ti etcd.local etcdctl cluster-health

You can perform rolling updates, by for example, switching the kernel version in etcd.yml, build a new moby, e.g., moby build -name etcd-4.10 etcd, update infrakit.json, and then commit the new configuration to InfraKit: infrakit group commit infrakit.json.

Infrakit GCP setup

Note: This setup is somewhat specific to our GCP setup (IP addresses and account info) and needs to be adjusted to your setting. The configuration is documented in the top-level README.md.

Build the image and upload it:

moby build etcd

Start the infrakit components in separate windows:

infrakit-group-default
infrakit-flavor-vanilla
infrakit-instance-gcp

Commit the configuration:

infrakit group commit infrakit-gce.json