mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-21 01:59:07 +00:00
Merge pull request #1588 from rneugeba/meta-up
demo: Switch etcd to use metadata
This commit is contained in:
commit
f47bc385c6
@ -22,9 +22,7 @@ This should create a HyperKit based, InfraKit managed `etcd` cluster with 5 `etc
|
||||
|
||||
Start InfraKit:
|
||||
```
|
||||
infrakit-flavor-vanilla &
|
||||
infrakit-group-default &
|
||||
../../../bin/infrakit-instance-hyperkit
|
||||
./start-infrakit
|
||||
```
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
To check if everything is fine, note down the IP address from one of
|
||||
the nodes and then:
|
||||
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 -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`.
|
||||
|
@ -4,7 +4,9 @@
|
||||
set -x
|
||||
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
|
||||
IP=""
|
||||
@ -13,13 +15,12 @@ while [ -z "$IP" ]; do
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# Name is infra+last octet of IP address
|
||||
NUM=$(echo ${IP} | cut -d . -f 4)
|
||||
PREFIX=$(echo ${IP} | cut -d . -f 1,2,3)
|
||||
NAME=infra${NUM}
|
||||
# Where to store data
|
||||
DATADIR=/var/lib/etcd
|
||||
|
||||
# This should come from Metadata
|
||||
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"
|
||||
# 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
|
||||
|
@ -31,13 +31,6 @@ onboot:
|
||||
- CAP_SYS_ADMIN
|
||||
rootfsPropagation: shared
|
||||
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
|
||||
image: "mobylinux/dhcpcd:0d4012269cb142972fed8542fbdc3ff5a7b695cd"
|
||||
binds:
|
||||
@ -48,7 +41,32 @@ services:
|
||||
- CAP_NET_BIND_SERVICE
|
||||
- CAP_NET_RAW
|
||||
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
|
||||
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
|
||||
image: "mobylinux/etcd"
|
||||
capabilities:
|
||||
@ -61,10 +79,11 @@ services:
|
||||
net: host
|
||||
binds:
|
||||
- /var/lib/etcd:/var/lib/etcd
|
||||
- /var/config/etcd:/etc/etcd
|
||||
|
||||
outputs:
|
||||
- format: kernel+initrd
|
||||
# - format: gcp
|
||||
# project: docker4x
|
||||
# bucket: rolf
|
||||
# replace: true
|
||||
- format: gcp
|
||||
project: docker4x
|
||||
bucket: rolf
|
||||
replace: true
|
||||
|
@ -18,16 +18,31 @@
|
||||
"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",
|
||||
"DiskType": "pd-standard",
|
||||
"AutoDeleteDisk": true,
|
||||
"ReuseExistingDisk": false,
|
||||
"Scopes": [ ]
|
||||
}
|
||||
},
|
||||
"Flavor": {
|
||||
"Plugin": "flavor-vanilla",
|
||||
"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": {
|
||||
"tier": "etcd-cluster",
|
||||
"project": "infrakit"
|
||||
|
@ -23,6 +23,18 @@
|
||||
"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",
|
||||
|
Loading…
Reference in New Issue
Block a user