mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-22 18:41:37 +00:00
commit
f08ff5cfa8
6
projects/demo/etcd/Dockerfile
Normal file
6
projects/demo/etcd/Dockerfile
Normal file
@ -0,0 +1,6 @@
|
||||
# A dockerfile to build an etcd container image from the upstream one
|
||||
# with a script as entry point
|
||||
FROM quay.io/coreos/etcd:v3.1.5
|
||||
COPY ./etcd.sh /
|
||||
|
||||
ENTRYPOINT ["/etcd.sh"]
|
20
projects/demo/etcd/README.md
Normal file
20
projects/demo/etcd/README.md
Normal file
@ -0,0 +1,20 @@
|
||||
This directory contains scripts/files to bootstrap a `etcd` cluster.
|
||||
|
||||
In the local, hyperkit based, setup, we use a `etcd` running in a
|
||||
Docker for Mac container to bootstrap the cluster. For a cloud based demo, we'd use `https://discovery.etcd.io`. The host/DfM side is setup with [dfm-setup.sh](./dfm-setup.sh).
|
||||
|
||||
The moby `etcd` package is build with [build-pkg.sh](./build-pkg.sh). It take the official `etcd` container and adds a [script](./etcd.sh) to start `etcd`.
|
||||
|
||||
To run (for now):
|
||||
|
||||
- Start the etcd bootstrap container in on window:
|
||||
```
|
||||
./dfm-setup.sh
|
||||
```
|
||||
|
||||
- In another window build/run the moby image:
|
||||
```
|
||||
./build-pkg.sh
|
||||
moby build etcd
|
||||
moby run etcd
|
||||
```
|
2
projects/demo/etcd/build-pkg.sh
Executable file
2
projects/demo/etcd/build-pkg.sh
Executable file
@ -0,0 +1,2 @@
|
||||
#! /bin/sh
|
||||
docker build -t mobylinux/etcd .
|
46
projects/demo/etcd/dfm-setup.sh
Executable file
46
projects/demo/etcd/dfm-setup.sh
Executable file
@ -0,0 +1,46 @@
|
||||
#! /bin/sh
|
||||
##
|
||||
## This script starts a etcd container which is used to bootstrap a
|
||||
## local etcd cluster. The etcd container is started on a non-standard
|
||||
## port to keep the standard port free for the cluster.
|
||||
##
|
||||
## If you have a local etcd installed (brew install etcd) you can
|
||||
## point the cli at it as well:
|
||||
##
|
||||
## etcdctl --debug --endpoints http://0.0.0.0:2381 member list
|
||||
##
|
||||
|
||||
# debug
|
||||
set -x
|
||||
set -v
|
||||
|
||||
# Change depending on the cluster size
|
||||
NUMPEERS=1
|
||||
|
||||
# Start a local etcd for bootstrapping
|
||||
NAME=etcd-bootstrap
|
||||
PORT=2381
|
||||
|
||||
#UUID=$(uuidgen)
|
||||
UUID=6c007a14875d53d9bf0ef5a6fc0257c817f0fb83
|
||||
|
||||
ID=$(docker run -d --rm --name ${NAME} \
|
||||
-p ${PORT}:${PORT} \
|
||||
quay.io/coreos/etcd:v3.1.5 /usr/local/bin/etcd \
|
||||
--debug \
|
||||
--name ${NAME} \
|
||||
--listen-client-urls http://0.0.0.0:${PORT} \
|
||||
--advertise-client-urls http://0.0.0.0:$PORT,http://192.168.65.2:$PORT \
|
||||
--initial-cluster-token ${NAME} \
|
||||
--initial-cluster-state new \
|
||||
--auto-compaction-retention 0)
|
||||
|
||||
trap "docker kill ${ID}" 2
|
||||
|
||||
# Could poll until returns without error, but sleep for 2s for now
|
||||
sleep 2
|
||||
docker exec -t ${ID} etcdctl --endpoints http://0.0.0.0:${PORT} mk discovery/${UUID}/_config/size ${NUMPEERS}
|
||||
|
||||
echo "KEY: ${UUID}"
|
||||
|
||||
docker logs -f ${ID}
|
22
projects/demo/etcd/etcd.sh
Executable file
22
projects/demo/etcd/etcd.sh
Executable file
@ -0,0 +1,22 @@
|
||||
#! /bin/sh
|
||||
|
||||
# debug
|
||||
set -x
|
||||
set -v
|
||||
|
||||
# Needs to come from metadata
|
||||
UUID=6c007a14875d53d9bf0ef5a6fc0257c817f0fb83
|
||||
DISCOVER_URL=http://192.168.65.2:2381/v2/keys/discovery/${UUID}
|
||||
|
||||
IP=$(ifconfig eth0 2>/dev/null|awk '/inet addr:/ {print $2}'|sed 's/addr://')
|
||||
NAME=$(hostname)
|
||||
|
||||
/usr/local/bin/etcd \
|
||||
--name ${NAME} \
|
||||
--debug \
|
||||
--log-package-levels etcdmain=DEBUG,etcdserver=DEBUG \
|
||||
--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 \
|
||||
--discovery ${DISCOVER_URL}
|
31
projects/demo/etcd/etcd.yml
Normal file
31
projects/demo/etcd/etcd.yml
Normal file
@ -0,0 +1,31 @@
|
||||
kernel:
|
||||
image: "mobylinux/kernel:4.9.x"
|
||||
cmdline: "console=ttyS0 console=tty0 page_poison=1"
|
||||
init: "mobylinux/init:00c3a5bbfd9794f4a3187fcc4a9f0c826c46d474"
|
||||
system:
|
||||
- name: sysctl
|
||||
image: "mobylinux/sysctl:2cf2f9d5b4d314ba1bfc22b2fe931924af666d8c"
|
||||
net: host
|
||||
pid: host
|
||||
ipc: host
|
||||
capabilities:
|
||||
- CAP_SYS_ADMIN
|
||||
readonly: true
|
||||
daemon:
|
||||
- name: rngd
|
||||
image: "mobylinux/rngd:3dad6dd43270fa632ac031e99d1947f20b22eec9@sha256:1c93c1db7196f6f71f8e300bc1d15f0376dd18e8891c8789d77c8ff19f3a9a92"
|
||||
capabilities:
|
||||
- CAP_SYS_ADMIN
|
||||
oomScoreAdj: -800
|
||||
readonly: true
|
||||
- name: etcd
|
||||
image: "mobylinux/etcd"
|
||||
capabilities:
|
||||
- CAP_NET_BIND_SERVICE
|
||||
- CAP_CHOWN
|
||||
- CAP_SETUID
|
||||
- CAP_SETGID
|
||||
- CAP_DAC_OVERRIDE
|
||||
net: host
|
||||
outputs:
|
||||
- format: kernel+initrd
|
30
projects/demo/infrakit/infrakit.json
Normal file
30
projects/demo/infrakit/infrakit.json
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"ID": "cattle",
|
||||
"Properties": {
|
||||
"Allocation": {
|
||||
"Size": 5
|
||||
},
|
||||
"Instance": {
|
||||
"Plugin": "instance-hyperkit",
|
||||
"Properties": {
|
||||
"Moby": "nginx-4.10",
|
||||
"Disk" : 512,
|
||||
"CPUs" : 2,
|
||||
"Memory" : 1024
|
||||
}
|
||||
},
|
||||
"Flavor": {
|
||||
"Plugin": "flavor-vanilla",
|
||||
"Properties": {
|
||||
"Init": [
|
||||
"test1",
|
||||
"test2"
|
||||
],
|
||||
"Tags": {
|
||||
"tier": "sample",
|
||||
"project": "infrakit"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
27
projects/demo/infrakit/nginx-4.10.yml
Normal file
27
projects/demo/infrakit/nginx-4.10.yml
Normal file
@ -0,0 +1,27 @@
|
||||
kernel:
|
||||
image: "mobylinux/kernel:4.10.x"
|
||||
cmdline: "console=ttyS0 console=tty0 page_poison=1"
|
||||
init: "mobylinux/init:00c3a5bbfd9794f4a3187fcc4a9f0c826c46d474"
|
||||
system:
|
||||
- name: sysctl
|
||||
image: "mobylinux/sysctl:2cf2f9d5b4d314ba1bfc22b2fe931924af666d8c"
|
||||
net: host
|
||||
pid: host
|
||||
ipc: host
|
||||
capabilities:
|
||||
- CAP_SYS_ADMIN
|
||||
readonly: true
|
||||
daemon:
|
||||
- name: nginx
|
||||
image: "nginx:alpine"
|
||||
capabilities:
|
||||
- CAP_NET_BIND_SERVICE
|
||||
- CAP_CHOWN
|
||||
- CAP_SETUID
|
||||
- CAP_SETGID
|
||||
- CAP_DAC_OVERRIDE
|
||||
net: host
|
||||
outputs:
|
||||
- format: kernel+initrd
|
||||
- format: iso-bios
|
||||
- format: iso-efi
|
27
projects/demo/infrakit/nginx.yml
Normal file
27
projects/demo/infrakit/nginx.yml
Normal file
@ -0,0 +1,27 @@
|
||||
kernel:
|
||||
image: "mobylinux/kernel:4.9.x"
|
||||
cmdline: "console=ttyS0 console=tty0 page_poison=1"
|
||||
init: "mobylinux/init:00c3a5bbfd9794f4a3187fcc4a9f0c826c46d474"
|
||||
system:
|
||||
- name: sysctl
|
||||
image: "mobylinux/sysctl:2cf2f9d5b4d314ba1bfc22b2fe931924af666d8c"
|
||||
net: host
|
||||
pid: host
|
||||
ipc: host
|
||||
capabilities:
|
||||
- CAP_SYS_ADMIN
|
||||
readonly: true
|
||||
daemon:
|
||||
- name: nginx
|
||||
image: "nginx:alpine"
|
||||
capabilities:
|
||||
- CAP_NET_BIND_SERVICE
|
||||
- CAP_CHOWN
|
||||
- CAP_SETUID
|
||||
- CAP_SETGID
|
||||
- CAP_DAC_OVERRIDE
|
||||
net: host
|
||||
outputs:
|
||||
- format: kernel+initrd
|
||||
- format: iso-bios
|
||||
- format: iso-efi
|
27
projects/demo/intro/intro.yml
Normal file
27
projects/demo/intro/intro.yml
Normal file
@ -0,0 +1,27 @@
|
||||
kernel:
|
||||
image: "mobylinux/kernel:4.9.x"
|
||||
cmdline: "console=ttyS0 console=tty0 page_poison=1"
|
||||
init: "mobylinux/init:00c3a5bbfd9794f4a3187fcc4a9f0c826c46d474"
|
||||
system:
|
||||
- name: sysctl
|
||||
image: "mobylinux/sysctl:2cf2f9d5b4d314ba1bfc22b2fe931924af666d8c"
|
||||
net: host
|
||||
pid: host
|
||||
ipc: host
|
||||
capabilities:
|
||||
- CAP_SYS_ADMIN
|
||||
readonly: true
|
||||
daemon:
|
||||
- name: nginx
|
||||
image: "nginx:alpine"
|
||||
capabilities:
|
||||
- CAP_NET_BIND_SERVICE
|
||||
- CAP_CHOWN
|
||||
- CAP_SETUID
|
||||
- CAP_SETGID
|
||||
- CAP_DAC_OVERRIDE
|
||||
net: host
|
||||
outputs:
|
||||
- format: kernel+initrd
|
||||
- format: iso-bios
|
||||
- format: iso-efi
|
Loading…
Reference in New Issue
Block a user