examples: Add etcd small and large cluster configs

This commit is contained in:
Dalton Hubble
2016-01-06 10:54:06 -08:00
parent c188c2ee59
commit 83330b5e2d
32 changed files with 296 additions and 13 deletions

View File

@@ -30,7 +30,7 @@ The latest image corresponds to the most recent `coreos-baremetal` master commit
Run the container and mount the data and images directories as volumes.
docker run -p 8080:8080 --name=bootcfg --rm -v $PWD/data:/data:Z -v $PWD/images:/images:Z coreos/bootcfg -address=0.0.0.0:8080
docker run -p 8080:8080 --name=bootcfg --rm -v $PWD/examples/dev:/data:Z -v $PWD/images:/images:Z coreos/bootcfg -address=0.0.0.0:8080
## Endpoints

View File

@@ -14,9 +14,9 @@
Binary
./run -address=0.0.0.0:8080 -data-path=./data -images-path=./images -log-level=debug
./run -address=0.0.0.0:8080 -data-path=./examples/dev -images-path=./images -log-level=debug
Container
docker run -p 8080:8080 --name=bootcfg --rm -v $PWD/data:/data:Z -v $PWD/images:/images:Z coreos/bootcfg:latest -address=0.0.0.0:8080 -data-path=./data -images-path=./images -log-level=debug
docker run -p 8080:8080 --name=bootcfg --rm -v $PWD/examples/dev:/data:Z -v $PWD/images:/images:Z coreos/bootcfg:latest -address=0.0.0.0:8080 -data-path=./data -images-path=./images -log-level=debug

View File

@@ -21,7 +21,7 @@ Set up `coreos/bootcfg` according to the [docs](bootcfg.md). Pull the `coreos/bo
Run the `bootcfg` container to serve configs for any of the network environments we'll discuss next.
docker run -p 8080:8080 --net=host --name=bootcfg --rm -v $PWD/data:/data:Z -v $PWD/images:/images:Z coreos/bootcfg:latest -address=0.0.0.0:8080 [-log-level=debug]
docker run -p 8080:8080 --net=host --name=bootcfg --rm -v $PWD/examples/dev:/data:Z -v $PWD/images:/images:Z coreos/bootcfg:latest -address=0.0.0.0:8080 [-log-level=debug]
Note, the kernel options in the [data](../data) `Spec` examples reference 172.17.0.2 (the libvirt case). Your kernel cmdline options should reference the IP or DNS name where `bootcfg` runs.

View File

@@ -14,7 +14,7 @@ Set up `coreos/bootcfg` according to the [docs](bootcfg.md). Pull the `coreos/bo
Run the `bootcfg` container to serve configs for any of the network environments we'll discuss next.
docker run -p 8080:8080 --name=bootcfg --rm -v $PWD/data:/data:Z -v $PWD/images:/images:Z coreos/bootcfg:latest -address=0.0.0.0:8080 -log-level=debug
docker run -p 8080:8080 --name=bootcfg --rm -v $PWD/examples/dev:/data:Z -v $PWD/images:/images:Z coreos/bootcfg:latest -address=0.0.0.0:8080 -log-level=debug
Note, the kernel options in the [data](../data) `Spec` examples reference 172.17.0.2, the first container IP Docker is likely to assign to `bootcfg`. Ensure your kernel options point to where `bootcfg` runs.

View File

@@ -17,8 +17,8 @@ var log = capnslog.NewPackageLogger("github.com/coreos/coreos-baremetal/cmd/boot
func main() {
flags := flag.NewFlagSet("bootcfg", flag.ExitOnError)
address := flags.String("address", "127.0.0.1:8080", "HTTP listen address")
dataPath := flags.String("data-path", "./data", "Path to config data directory")
imagesPath := flags.String("images-path", "./images", "Path to static image assets")
dataPath := flags.String("data-path", "./data", "Path to data directory")
imagesPath := flags.String("images-path", "./images", "Path to static assets")
// available log levels https://godoc.org/github.com/coreos/pkg/capnslog#LogLevel
logLevel := flags.String("log-level", "info", "Set the logging level")
@@ -35,10 +35,10 @@ func main() {
log.Fatal("A valid HTTP listen address is required")
}
if finfo, err := os.Stat(*dataPath); err != nil || !finfo.IsDir() {
log.Fatal("A path to a config data directory is required")
log.Fatal("A path to a data directory is required")
}
if finfo, err := os.Stat(*imagesPath); err != nil || !finfo.IsDir() {
log.Fatal("A path to an image assets directory is required")
log.Fatal("A path to an assets directory is required")
}
// logging setup

View File

@@ -1,4 +0,0 @@
{
"id": "default",
"spec_id": "orion"
}

33
examples/README.md Normal file
View File

@@ -0,0 +1,33 @@
# Examples
Examples contains `bootcfg` data directories showcasing different PXE-bootable baremetal clusters. These examples work with libvirt VMs setup with known hardware attributes by `scripts/libvirt`.
## Clusters
| Name | Description | Type | Docs |
|------------|-------------|------|---------------|
| etcd-small | Cluster with 1 etcd node, 4 proxies | cloud config | [cluster-architecture](https://coreos.com/os/docs/latest/cluster-architectures.html) |
| etcd-large | Cluster with 3 etcd nodes, 2 proxies | cloud config | [cluster-architecture](https://coreos.com/os/docs/latest/cluster-architectures.html) |
## Usage
First, read about the [bootcfg](../Documentation/bootcfg.md) config service. Then setup the config service and network boot environment using the [libvirt guide](../Documentation/virtual-hardware.md).
Create 5 libvirt VM nodes on the `docker0` bridge.
./scripts/libvirt create # create node1 ... node5
Generally, you just need to run the `coreos/bootcfg` container and the `coreos/dnsmasq` container (which runs network boot services).
For `coreos/bootcfg`, mount one of the example directories with `-v $PWD/examples/some-example:/data:Z` and provide the `-data-path` if the mount location differs from `/data`.
Reboot to see nodes boot with PXE and create a cluster.
./scripts/libvirt reboot
Clean up by powering off and destroying the VMs.
./scripts/libvirt shutdown # graceful
./scripts/libvirt poweroff # non-graceful
./scripts/libvirt destroy

View File

@@ -0,0 +1,4 @@
{
"id": "default",
"spec_id": "orion"
}

View File

@@ -0,0 +1,31 @@
#cloud-config
coreos:
etcd2:
name: node1
initial-cluster: node1=http://172.17.0.21:2380,node2=http://172.17.0.22:2380,node3=http://172.17.0.23:2380
initial-advertise-peer-urls: http://172.17.0.21:2380
initial-cluster-state: new
advertise-client-urls: http://172.17.0.21:2379
listen-client-urls: http://0.0.0.0:2379
listen-peer-urls: http://172.17.0.21:2380
units:
- name: etcd2.service
command: start
- name: fleet.service
command: start
- name: 00-ens3.network
runtime: true
content: |
[Match]
Name=ens3
[Network]
Address=172.17.0.21/16
- name: down-interfaces.service
command: start
content: |
[Service]
Type=oneshot
ExecStart=/usr/bin/ip link set ens3 down
ExecStart=/usr/bin/ip addr flush dev ens3
- name: systemd-networkd.service
command: restart

View File

@@ -0,0 +1,31 @@
#cloud-config
coreos:
etcd2:
name: node2
initial-cluster: node1=http://172.17.0.21:2380,node2=http://172.17.0.22:2380,node3=http://172.17.0.23:2380
initial-advertise-peer-urls: http://172.17.0.22:2380
initial-cluster-state: new
advertise-client-urls: http://172.17.0.22:2379
listen-client-urls: http://0.0.0.0:2379
listen-peer-urls: http://172.17.0.22:2380
units:
- name: etcd2.service
command: start
- name: fleet.service
command: start
- name: 00-ens3.network
runtime: true
content: |
[Match]
Name=ens3
[Network]
Address=172.17.0.22/16
- name: down-interfaces.service
command: start
content: |
[Service]
Type=oneshot
ExecStart=/usr/bin/ip link set ens3 down
ExecStart=/usr/bin/ip addr flush dev ens3
- name: systemd-networkd.service
command: restart

View File

@@ -0,0 +1,31 @@
#cloud-config
coreos:
etcd2:
name: node3
initial-cluster: node1=http://172.17.0.21:2380,node2=http://172.17.0.22:2380,node3=http://172.17.0.23:2380
initial-advertise-peer-urls: http://172.17.0.23:2380
initial-cluster-state: new
advertise-client-urls: http://172.17.0.23:2379
listen-client-urls: http://0.0.0.0:2379
listen-peer-urls: http://172.17.0.23:2380
units:
- name: etcd2.service
command: start
- name: fleet.service
command: start
- name: 00-ens3.network
runtime: true
content: |
[Match]
Name=ens3
[Network]
Address=172.17.0.23/16
- name: down-interfaces.service
command: start
content: |
[Service]
Type=oneshot
ExecStart=/usr/bin/ip link set ens3 down
ExecStart=/usr/bin/ip addr flush dev ens3
- name: systemd-networkd.service
command: restart

View File

@@ -0,0 +1,14 @@
#cloud-config
coreos:
etcd2:
initial-cluster: node1=http://172.17.0.21:2380,node2=http://172.17.0.22:2380,node3=http://172.17.0.23:2380
proxy: on
listen-client-urls: http://localhost:2379
fleet:
metadata: "role=worker"
etcd_servers: "http://localhost:2379"
units:
- name: etcd2.service
command: start
- name: fleet.service
command: start

View File

@@ -0,0 +1,16 @@
{
"id": "16e7d8a7-bfa9-428b-9117-363341bb330b",
"spec": {
"boot": {
"kernel": "/images/coreos/835.9.0/coreos_production_pxe.vmlinuz",
"initrd": ["/images/coreos/835.9.0/coreos_production_pxe_image.cpio.gz"],
"cmdline": {
"cloud-config-url": "http://172.17.0.2:8080/cloud?uuid=${uuid}&mac=${net0/mac:hexhyp}",
"coreos.autologin": ""
}
},
"cloud_id": "etcd1.yml",
"ignition_id": ""
},
"spec_id": ""
}

View File

@@ -0,0 +1,16 @@
{
"id": "39d2e747-2648-4d68-ae92-bbc70b245055",
"spec": {
"boot": {
"kernel": "/images/coreos/835.9.0/coreos_production_pxe.vmlinuz",
"initrd": ["/images/coreos/835.9.0/coreos_production_pxe_image.cpio.gz"],
"cmdline": {
"cloud-config-url": "http://172.17.0.2:8080/cloud?uuid=${uuid}&mac=${net0/mac:hexhyp}",
"coreos.autologin": ""
}
},
"cloud_id": "etcd2.yml",
"ignition_id": ""
},
"spec_id": ""
}

View File

@@ -0,0 +1,16 @@
{
"id": "264cd073-ca62-44b3-98c0-50aad5b5f819",
"spec": {
"boot": {
"kernel": "/images/coreos/835.9.0/coreos_production_pxe.vmlinuz",
"initrd": ["/images/coreos/835.9.0/coreos_production_pxe_image.cpio.gz"],
"cmdline": {
"cloud-config-url": "http://172.17.0.2:8080/cloud?uuid=${uuid}&mac=${net0/mac:hexhyp}",
"coreos.autologin": ""
}
},
"cloud_id": "etcd3.yml",
"ignition_id": ""
},
"spec_id": ""
}

View File

@@ -0,0 +1,4 @@
{
"id": "4ed46e8e-db69-471e-b874-0990dd65649d",
"spec_id": "worker"
}

View File

@@ -0,0 +1,4 @@
{
"id": "53683e94-3273-4a49-9a82-d769b88e3ccf",
"spec_id": "worker"
}

View File

@@ -0,0 +1,13 @@
{
"id": "worker",
"boot": {
"kernel": "/images/coreos/835.9.0/coreos_production_pxe.vmlinuz",
"initrd": ["/images/coreos/835.9.0/coreos_production_pxe_image.cpio.gz"],
"cmdline": {
"cloud-config-url": "http://172.17.0.2:8080/cloud?uuid=${uuid}&mac=${net0/mac:hexhyp}",
"coreos.autologin": ""
}
},
"cloud_id": "worker.yml",
"ignition_id": ""
}

View File

@@ -0,0 +1,28 @@
#cloud-config
coreos:
etcd2:
name: etcdserver
initial-cluster: etcdserver=http://172.17.0.21:2380
initial-advertise-peer-urls: http://172.17.0.21:2380
advertise-client-urls: http://172.17.0.21:2379
listen-client-urls: http://0.0.0.0:2379
listen-peer-urls: http://0.0.0.0:2380
units:
- name: etcd2.service
command: start
- name: 00-ens3.network
runtime: true
content: |
[Match]
Name=ens3
[Network]
Address=172.17.0.21/16
- name: down-interfaces.service
command: start
content: |
[Service]
Type=oneshot
ExecStart=/usr/bin/ip link set ens3 down
ExecStart=/usr/bin/ip addr flush dev ens3
- name: systemd-networkd.service
command: restart

View File

@@ -0,0 +1,13 @@
#cloud-config
coreos:
etcd2:
proxy: on
listen-client-urls: http://localhost:2379
initial-cluster: etcdserver=http://172.17.0.21:2380
fleet:
etcd_servers: "http://localhost:2379"
units:
- name: etcd2.service
command: start
- name: fleet.service
command: start

View File

@@ -0,0 +1,16 @@
{
"id": "16e7d8a7-bfa9-428b-9117-363341bb330b",
"spec": {
"boot": {
"kernel": "/images/coreos/835.9.0/coreos_production_pxe.vmlinuz",
"initrd": ["/images/coreos/835.9.0/coreos_production_pxe_image.cpio.gz"],
"cmdline": {
"cloud-config-url": "http://172.17.0.2:8080/cloud?uuid=${uuid}&mac=${net0/mac:hexhyp}",
"coreos.autologin": ""
}
},
"cloud_id": "etcd.yml",
"ignition_id": ""
},
"spec_id": ""
}

View File

@@ -0,0 +1,4 @@
{
"id": "default",
"spec_id": "worker"
}

View File

@@ -0,0 +1,13 @@
{
"id": "worker",
"boot": {
"kernel": "/images/coreos/835.9.0/coreos_production_pxe.vmlinuz",
"initrd": ["/images/coreos/835.9.0/coreos_production_pxe_image.cpio.gz"],
"cmdline": {
"cloud-config-url": "http://172.17.0.2:8080/cloud?uuid=${uuid}&mac=${net0/mac:hexhyp}",
"coreos.autologin": ""
}
},
"cloud_id": "worker.yml",
"ignition_id": ""
}