mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-22 10:31:35 +00:00
projects: Remove the etcd projects
It was last used close to a year ago and is not longer maintained/used. Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
parent
07c2f49edc
commit
db52123afc
@ -1,105 +0,0 @@
|
|||||||
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 `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
|
|
||||||
|
|
||||||
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 `linuxkit` tool and package/upload them to Google Cloud using the `linuxkit` tool.
|
|
||||||
|
|
||||||
## InfraKit cluster setup
|
|
||||||
|
|
||||||
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 LinuxKit, e.g., `linuxkit 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
|
|
||||||
|
|
||||||
Start infrakit as above:
|
|
||||||
```
|
|
||||||
./start-infrakit
|
|
||||||
```
|
|
||||||
|
|
||||||
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.
|
|
@ -1,44 +0,0 @@
|
|||||||
kernel:
|
|
||||||
image: linuxkit/kernel:4.9.74
|
|
||||||
cmdline: "console=ttyS0 console=tty0 page_poison=1"
|
|
||||||
init:
|
|
||||||
- linuxkit/init:5a577d070817b4f17821657823082651baafd4ed
|
|
||||||
- linuxkit/runc:abc3f292653e64a2fd488e9675ace19a55ec7023
|
|
||||||
- linuxkit/containerd:e58a382c33bb509ba3e0e8170dfaa5a100504c5b
|
|
||||||
- linuxkit/ca-certificates:de21b84d9b055ad9dcecc57965b654a7a24ef8e0
|
|
||||||
onboot:
|
|
||||||
- name: sysctl
|
|
||||||
image: linuxkit/sysctl:4c1ef93bb5eb1a877318db4b2daa6768ed002e21
|
|
||||||
- name: format
|
|
||||||
image: linuxkit/format:e945016ec780a788a71dcddc81497d54d3b14bc7
|
|
||||||
- name: mount
|
|
||||||
image: linuxkit/mount:b346ec277b7074e5c9986128a879c10a1d18742b
|
|
||||||
command: ["/usr/bin/mountie", "/var/lib/etcd"]
|
|
||||||
- name: dhcpcd
|
|
||||||
image: linuxkit/dhcpcd:0d59a6cc03412289ef4313f2491ec666c1715cc9
|
|
||||||
command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
|
|
||||||
- name: metadata
|
|
||||||
image: linuxkit/metadata:2af15c9f4b0e73515c219b7cc14e6e65e1d4fd6d
|
|
||||||
services:
|
|
||||||
- name: rngd
|
|
||||||
image: linuxkit/rngd:94e01a4b16fadb053455cdc2269c4eb0b39199cd
|
|
||||||
- name: ntpd
|
|
||||||
image: linuxkit/openntpd:536e5947607c9e6a6771957c2ff817230cba0d3c
|
|
||||||
- name: node_exporter
|
|
||||||
image: linuxkit/node_exporter:db8ba40196c010d06f15ffd231132d360614d507
|
|
||||||
- name: etcd
|
|
||||||
image: moby/etcd
|
|
||||||
capabilities:
|
|
||||||
- CAP_CHOWN
|
|
||||||
- CAP_SETUID
|
|
||||||
- CAP_SETGID
|
|
||||||
- CAP_DAC_OVERRIDE
|
|
||||||
- CAP_SYS_ADMIN
|
|
||||||
- CAP_MKNOD
|
|
||||||
net: host
|
|
||||||
binds:
|
|
||||||
- /var/lib/etcd:/var/lib/etcd
|
|
||||||
- /var/config/etcd:/etc/etcd
|
|
||||||
trust:
|
|
||||||
org:
|
|
||||||
- linuxkit
|
|
@ -1,53 +0,0 @@
|
|||||||
{
|
|
||||||
"ID": "etcd.gcp",
|
|
||||||
"Properties": {
|
|
||||||
"Allocation": {
|
|
||||||
"LogicalIDs": [
|
|
||||||
"10.132.0.200",
|
|
||||||
"10.132.0.201",
|
|
||||||
"10.132.0.202",
|
|
||||||
"10.132.0.203",
|
|
||||||
"10.132.0.204"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"Instance": {
|
|
||||||
"Plugin": "instance-gcp",
|
|
||||||
"Properties": {
|
|
||||||
"NamePrefix": "etcd-demo",
|
|
||||||
"Description": "ETCD test cluster",
|
|
||||||
"Network": "rneugeba-demo",
|
|
||||||
"Connect" : true,
|
|
||||||
"MachineType": "n1-standard-1",
|
|
||||||
"DiskType": "pd-standard",
|
|
||||||
"DiskSizeMb": 60,
|
|
||||||
"DiskImage": "https://www.googleapis.com/compute/v1/projects/docker4x/global/images/etcd",
|
|
||||||
"AutoDeleteDisk": true,
|
|
||||||
"ReuseExistingDisk": false,
|
|
||||||
"Scopes": [ ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Flavor": {
|
|
||||||
"Plugin": "flavor-vanilla",
|
|
||||||
"Properties": {
|
|
||||||
"Init": [
|
|
||||||
"{",
|
|
||||||
" \"etcd\": {",
|
|
||||||
" \"name_prefix\": {",
|
|
||||||
" \"perm\": \"0644\",",
|
|
||||||
" \"content\": \"server\"",
|
|
||||||
"},",
|
|
||||||
" \"init_cluster\": {",
|
|
||||||
" \"perm\": \"0644\",",
|
|
||||||
" \"content\": \"server200=http://10.132.0.200:2380,server201=http://10.132.0.201:2380,server202=http://10.132.0.202:2380,server203=http://10.132.0.203:2380,server204=http://10.132.0.204:2380\"",
|
|
||||||
"}",
|
|
||||||
"}",
|
|
||||||
"}"
|
|
||||||
],
|
|
||||||
"Tags": {
|
|
||||||
"tier": "etcd-cluster",
|
|
||||||
"project": "infrakit"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
{
|
|
||||||
"ID": "etcd",
|
|
||||||
"Properties": {
|
|
||||||
"Allocation": {
|
|
||||||
"LogicalIDs": [
|
|
||||||
"192.168.65.200",
|
|
||||||
"192.168.65.201",
|
|
||||||
"192.168.65.202",
|
|
||||||
"192.168.65.203",
|
|
||||||
"192.168.65.204"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"Instance": {
|
|
||||||
"Plugin": "instance-hyperkit",
|
|
||||||
"Properties": {
|
|
||||||
"kernel+initrd": "etcd",
|
|
||||||
"Disk" : 2048,
|
|
||||||
"CPUs" : 1,
|
|
||||||
"Memory" : 1024
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Flavor": {
|
|
||||||
"Plugin": "flavor-vanilla",
|
|
||||||
"Properties": {
|
|
||||||
"Init": [
|
|
||||||
"{",
|
|
||||||
" \"etcd\": {",
|
|
||||||
" \"name_prefix\": {",
|
|
||||||
" \"perm\": \"0644\",",
|
|
||||||
" \"content\": \"server\"",
|
|
||||||
"},",
|
|
||||||
" \"init_cluster\": {",
|
|
||||||
" \"perm\": \"0644\",",
|
|
||||||
" \"content\": \"server200=http://192.168.65.200:2380,server201=http://192.168.65.201:2380,server202=http://192.168.65.202:2380,server203=http://192.168.65.203:2380,server204=http://192.168.65.204:2380\"",
|
|
||||||
"}",
|
|
||||||
"}",
|
|
||||||
"}"
|
|
||||||
],
|
|
||||||
"Tags": {
|
|
||||||
"tier": "etcd-cluster",
|
|
||||||
"project": "infrakit"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
FROM quay.io/coreos/etcd:v3.1.5
|
|
||||||
|
|
||||||
COPY ./etcd.sh /
|
|
||||||
|
|
||||||
ENTRYPOINT ["/etcd.sh"]
|
|
@ -1,6 +0,0 @@
|
|||||||
# A dockerfile to build an etcd container image from the upstream one
|
|
||||||
#
|
|
||||||
# It sets the environment to talk to the local cluster
|
|
||||||
FROM quay.io/coreos/etcd:v3.1.5
|
|
||||||
|
|
||||||
ENV ETCDCTL_ENDPOINTS="http://192.168.65.200:2379,http://192.168.65.201:2379,http://192.168.65.202:2379,http://192.168.65.203:2379,http://192.168.65.204:2379"
|
|
@ -1,2 +0,0 @@
|
|||||||
FROM prom/prometheus
|
|
||||||
ADD etc/prometheus-local.yml /etc/prometheus/prometheus.yml
|
|
@ -1,2 +0,0 @@
|
|||||||
FROM prom/prometheus
|
|
||||||
ADD etc/prometheus-us-central.yml /etc/prometheus/prometheus.yml
|
|
@ -1,7 +0,0 @@
|
|||||||
#! /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 .
|
|
@ -1,19 +0,0 @@
|
|||||||
global:
|
|
||||||
|
|
||||||
scrape_configs:
|
|
||||||
# - job_name: 'prometheus'
|
|
||||||
# scrape_interval: 20s
|
|
||||||
# static_configs:
|
|
||||||
# - targets: ['localhost:9090']
|
|
||||||
|
|
||||||
# Scrape the Node Exporter
|
|
||||||
- job_name: 'node'
|
|
||||||
scrape_interval: 20s
|
|
||||||
static_configs:
|
|
||||||
- targets: ['localhost:9100', 'localhost:9101', 'localhost:9102', 'localhost:9103', 'localhost:9104']
|
|
||||||
|
|
||||||
# # Scrape the containerd exporter
|
|
||||||
# - job_name: 'containerd'
|
|
||||||
# scrape_interval: 15s
|
|
||||||
# static_configs:
|
|
||||||
# - targets: ['192.168.65.200:13337', '192.168.65.201:13337', '192.168.65.202:13337', '192.168.65.203:13337', '192.168.65.204:13337']
|
|
@ -1,13 +0,0 @@
|
|||||||
global:
|
|
||||||
|
|
||||||
scrape_configs:
|
|
||||||
- job_name: 'prometheus'
|
|
||||||
scrape_interval: 20s
|
|
||||||
static_configs:
|
|
||||||
- targets: ['localhost:9090']
|
|
||||||
|
|
||||||
# Scrape the Node Exporter
|
|
||||||
- job_name: 'node'
|
|
||||||
scrape_interval: 20s
|
|
||||||
static_configs:
|
|
||||||
- targets: ['10.128.0.200:9100', '10.128.0.201:9100', '10.128.0.202:9100', '10.128.0.203:9100', '10.128.0.204:9100']
|
|
@ -1,13 +0,0 @@
|
|||||||
global:
|
|
||||||
|
|
||||||
scrape_configs:
|
|
||||||
- job_name: 'prometheus'
|
|
||||||
scrape_interval: 20s
|
|
||||||
static_configs:
|
|
||||||
- targets: ['localhost:9090']
|
|
||||||
|
|
||||||
# Scrape the Node Exporter
|
|
||||||
- job_name: 'node'
|
|
||||||
scrape_interval: 20s
|
|
||||||
static_configs:
|
|
||||||
- targets: ['10.128.0.200:9100', '10.128.0.201:9100', '10.128.0.202:9100', '10.128.0.203:9100', '10.128.0.204:9100']
|
|
@ -1,58 +0,0 @@
|
|||||||
#! /bin/sh
|
|
||||||
|
|
||||||
# debug
|
|
||||||
set -x
|
|
||||||
set -v
|
|
||||||
|
|
||||||
# Get initial cluster data from metadata
|
|
||||||
NAME_PREFIX="$(cat /etc/etcd/name_prefix)"
|
|
||||||
INIT_CLUSTER="$(cat /etc/etcd/init_cluster)"
|
|
||||||
|
|
||||||
# Wait till we have an IP address
|
|
||||||
IP=""
|
|
||||||
while [ -z "$IP" ]; do
|
|
||||||
IP=$(ifconfig eth0 2>/dev/null|awk '/inet addr:/ {print $2}'|sed 's/addr://')
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
|
|
||||||
# Where to store data
|
|
||||||
DATADIR=/var/lib/etcd
|
|
||||||
|
|
||||||
# Name is NAME_PREFIX+last octet of IP address
|
|
||||||
NUM=$(echo ${IP} | cut -d . -f 4)
|
|
||||||
NAME=${NAME_PREFIX}${NUM}
|
|
||||||
|
|
||||||
# We currently have no easy way to determine if we join a cluster for
|
|
||||||
# the first time or if we got restarted and need to join an existing
|
|
||||||
# cluster. So we first try joining a *new* cluster. This fails if we
|
|
||||||
# had already joined it previously. As a fallback we then try to join
|
|
||||||
# an existing cluster.
|
|
||||||
|
|
||||||
# Try to join an new cluster
|
|
||||||
/usr/local/bin/etcd \
|
|
||||||
--name ${NAME} \
|
|
||||||
--debug \
|
|
||||||
--log-package-levels etcdmain=DEBUG,etcdserver=DEBUG \
|
|
||||||
--data-dir $DATADIR \
|
|
||||||
--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 \
|
|
||||||
--initial-cluster-token etcd-cluster-1 \
|
|
||||||
--initial-cluster ${INIT_CLUSTER} \
|
|
||||||
--initial-cluster-state new
|
|
||||||
|
|
||||||
[ $? -eq 0 ] && exit 0
|
|
||||||
|
|
||||||
# Try to join an existing cluster
|
|
||||||
/usr/local/bin/etcd \
|
|
||||||
--name ${NAME} \
|
|
||||||
--debug \
|
|
||||||
--log-package-levels etcdmain=DEBUG,etcdserver=DEBUG \
|
|
||||||
--data-dir $DATADIR \
|
|
||||||
--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 \
|
|
||||||
--initial-cluster ${INIT_CLUSTER} \
|
|
||||||
--initial-cluster-state existing
|
|
@ -1,30 +0,0 @@
|
|||||||
kernel:
|
|
||||||
image: mobylinux/kernel:4.9.x
|
|
||||||
cmdline: "console=ttyS0 page_poison=1"
|
|
||||||
init:
|
|
||||||
- linuxkit/init:5a577d070817b4f17821657823082651baafd4ed
|
|
||||||
- mobylinux/runc:b0fb122e10dbb7e4e45115177a61a3f8d68c19a9
|
|
||||||
- mobylinux/containerd:18eaf72f3f4f9a9f29ca1951f66df701f873060b
|
|
||||||
- mobylinux/ca-certificates:eabc5a6e59f05aa91529d80e9a595b85b046f935
|
|
||||||
onboot:
|
|
||||||
- name: sysctl
|
|
||||||
image: linuxkit/sysctl:4c1ef93bb5eb1a877318db4b2daa6768ed002e21
|
|
||||||
- name: dhcpcd
|
|
||||||
image: linuxkit/dhcpcd:0d59a6cc03412289ef4313f2491ec666c1715cc9
|
|
||||||
command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
|
|
||||||
- name: metadata
|
|
||||||
image: linuxkit/metadata:2af15c9f4b0e73515c219b7cc14e6e65e1d4fd6d
|
|
||||||
services:
|
|
||||||
- name: rngd
|
|
||||||
image: mobylinux/rngd:3dad6dd43270fa632ac031e99d1947f20b22eec9
|
|
||||||
- name: prometheus
|
|
||||||
image: moby/prom-us-central1-f
|
|
||||||
binds:
|
|
||||||
- /dev:/dev
|
|
||||||
- /var/lib/misc:/data
|
|
||||||
capabilities:
|
|
||||||
- all
|
|
||||||
net: host
|
|
||||||
trust:
|
|
||||||
image:
|
|
||||||
- mobylinux/kernel
|
|
@ -1,20 +0,0 @@
|
|||||||
# !/bin/sh
|
|
||||||
|
|
||||||
# Start the infrakit plugins, save their PID
|
|
||||||
|
|
||||||
INFRAKIT_HOME=~/.infrakit
|
|
||||||
IK_PLUGINS=$INFRAKIT_HOME/plugins
|
|
||||||
|
|
||||||
rm -rf $INFRAKIT_HOME
|
|
||||||
mkdir -p $INFRAKIT_HOME/cli
|
|
||||||
|
|
||||||
infrakit-flavor-vanilla &
|
|
||||||
infrakit-instance-hyperkit &
|
|
||||||
infrakit-instance-gcp --project $CLOUDSDK_CORE_PROJECT --zone $CLOUDSDK_COMPUTE_ZONE &
|
|
||||||
|
|
||||||
|
|
||||||
# start the group plugin in the foreground. If it exits, it will take
|
|
||||||
# the others down as well.
|
|
||||||
infrakit-group-default
|
|
||||||
|
|
||||||
rm -rf $INFRAKIT_HOME
|
|
Loading…
Reference in New Issue
Block a user