Merge pull request #1588 from rneugeba/meta-up

demo: Switch etcd to use metadata
This commit is contained in:
Justin Cormack 2017-04-11 20:08:16 +01:00 committed by GitHub
commit f47bc385c6
5 changed files with 71 additions and 26 deletions

View File

@ -22,9 +22,7 @@ This should create a HyperKit based, InfraKit managed `etcd` cluster with 5 `etc
Start InfraKit: Start InfraKit:
``` ```
infrakit-flavor-vanilla & ./start-infrakit
infrakit-group-default &
../../../bin/infrakit-instance-hyperkit
``` ```
Note: The HyperKit InfraKit plugin must be started from the directory Note: The HyperKit InfraKit plugin must be started from the directory
@ -35,10 +33,10 @@ Now, commit the new config:
infrakit group commit infrakit.json infrakit group commit infrakit.json
``` ```
To check if everything is fine, note down the IP address from one of 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:
the nodes and then:
``` ```
docker run --rm -t quay.io/coreos/etcd:v3.1.5 etcdctl --endpoints http://192.168.65.200:2379 member list 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`. 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`.

View File

@ -4,7 +4,9 @@
set -x set -x
set -v set -v
DATADIR=/var/lib/etcd # 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 # Wait till we have an IP address
IP="" IP=""
@ -13,13 +15,12 @@ while [ -z "$IP" ]; do
sleep 1 sleep 1
done done
# Name is infra+last octet of IP address # Where to store data
NUM=$(echo ${IP} | cut -d . -f 4) DATADIR=/var/lib/etcd
PREFIX=$(echo ${IP} | cut -d . -f 1,2,3)
NAME=infra${NUM}
# This should come from Metadata # Name is NAME_PREFIX+last octet of IP address
INIT_CLUSTER="infra200=http://${PREFIX}.200:2380,infra201=http://${PREFIX}.201:2380,infra202=http://${PREFIX}.202:2380,infra203=http://${PREFIX}.203:2380,infra204=http://${PREFIX}.204:2380" 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 # 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 # the first time or if we got restarted and need to join an existing

View File

@ -31,13 +31,6 @@ onboot:
- CAP_SYS_ADMIN - CAP_SYS_ADMIN
rootfsPropagation: shared rootfsPropagation: shared
command: ["/mount.sh", "/var/lib/etcd"] command: ["/mount.sh", "/var/lib/etcd"]
services:
- name: rngd
image: "mobylinux/rngd:3dad6dd43270fa632ac031e99d1947f20b22eec9@sha256:1c93c1db7196f6f71f8e300bc1d15f0376dd18e8891c8789d77c8ff19f3a9a92"
capabilities:
- CAP_SYS_ADMIN
oomScoreAdj: -800
readonly: true
- name: dhcpcd - name: dhcpcd
image: "mobylinux/dhcpcd:0d4012269cb142972fed8542fbdc3ff5a7b695cd" image: "mobylinux/dhcpcd:0d4012269cb142972fed8542fbdc3ff5a7b695cd"
binds: binds:
@ -48,7 +41,32 @@ services:
- CAP_NET_BIND_SERVICE - CAP_NET_BIND_SERVICE
- CAP_NET_RAW - CAP_NET_RAW
net: host net: host
command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
- name: metadata
image: mobylinux/metadata:960e6c371c9a07cf512dfcfa9734a5e0db427e96
net: host
binds:
- /dev:/dev
- /var:/var
- /etc/resolv.conf:/etc/resolv.conf
capabilities:
- all
services:
- name: rngd
image: "mobylinux/rngd:3dad6dd43270fa632ac031e99d1947f20b22eec9"
capabilities:
- CAP_SYS_ADMIN
oomScoreAdj: -800 oomScoreAdj: -800
readonly: true
- name: ntpd
image: "mobylinux/openntpd:a570316d7fc49ca1daa29bd945499f4963d227af"
capabilities:
- CAP_SYS_TIME
- CAP_SYS_NICE
- CAP_SYS_CHROOT
- CAP_SETUID
- CAP_SETGID
net: host
- name: etcd - name: etcd
image: "mobylinux/etcd" image: "mobylinux/etcd"
capabilities: capabilities:
@ -61,10 +79,11 @@ services:
net: host net: host
binds: binds:
- /var/lib/etcd:/var/lib/etcd - /var/lib/etcd:/var/lib/etcd
- /var/config/etcd:/etc/etcd
outputs: outputs:
- format: kernel+initrd - format: kernel+initrd
# - format: gcp - format: gcp
# project: docker4x project: docker4x
# bucket: rolf bucket: rolf
# replace: true replace: true

View File

@ -18,16 +18,31 @@
"Network": "rneugeba-demo", "Network": "rneugeba-demo",
"Connect" : true, "Connect" : true,
"MachineType": "n1-standard-1", "MachineType": "n1-standard-1",
"DiskType": "pd-standard",
"DiskSizeMb": 60, "DiskSizeMb": 60,
"DiskImage": "https://www.googleapis.com/compute/v1/projects/docker4x/global/images/etcd", "DiskImage": "https://www.googleapis.com/compute/v1/projects/docker4x/global/images/etcd",
"DiskType": "pd-standard", "AutoDeleteDisk": true,
"ReuseExistingDisk": false,
"Scopes": [ ] "Scopes": [ ]
} }
}, },
"Flavor": { "Flavor": {
"Plugin": "flavor-vanilla", "Plugin": "flavor-vanilla",
"Properties": { "Properties": {
"Init": [ ], "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": { "Tags": {
"tier": "etcd-cluster", "tier": "etcd-cluster",
"project": "infrakit" "project": "infrakit"

View File

@ -23,6 +23,18 @@
"Plugin": "flavor-vanilla", "Plugin": "flavor-vanilla",
"Properties": { "Properties": {
"Init": [ "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": { "Tags": {
"tier": "etcd-cluster", "tier": "etcd-cluster",