Demo setup for a federated Nomad cluster in Google Cloud Platform in EU, US and AS (Asia) regions.
The latest gcloud Comand Line Interface should be installed and the folowing environment variables should be set:
GCLOUD_PROJECT=global-datacenter
GCLOUD_REGION=europe-west1
Authorization to manage the 'global-datacenter' (or your) project. See https://cloud.google.com/sdk/gcloud/reference/auth/ for details.
use
cd scripts/
./install-servers.sh
Or perform the steps manually:
cd scripts/
gcloud compute instances create nomad-eu-1 --zone europe-west1-b \
--machine-type g1-small \
--image-project coreos-cloud \
--image-family coreos-stable \
--metadata-from-file startup-script=server-script&
gcloud compute instances create nomad-eu-2 --zone europe-west1-c \
--machine-type g1-small \
--image-project coreos-cloud \
--image-family coreos-stable \
--metadata-from-file startup-script=server-script&
gcloud compute instances create nomad-eu-3 --zone europe-west1-d \
--machine-type g1-small \
--image-project coreos-cloud \
--image-family coreos-stable \
--metadata-from-file startup-script=server-script&
Wait for completion
watch -d gcloud compute instances list nomad-eu-{1,2,3}
Login to a Nomad server and forward some ports:
./ssh-nomad-eu
See server status:
nomad server-members
Join servers together:
nomad server-join nomad-eu-{1,2,3}
See server status:
nomad server-members
See client node status:
nomad node-status
nomad node-status -self
Schedule nomad-ui as a system job on all Nomad servers:
cd /tmp/devoxx-2016/jobs
nomad plan nomad-ui.nomad
nomad run nomad-ui.nomad
See the results:
nomad status
nomad status nomad-ui
nomad status -verbose nomad-ui
nomad alloc-status _xxx_
Browse to http://localhost:3000/
use
cd scripts/
./install-clients.sh
The clients will automatically join the Nomad cluster
check with
nomad node-status
nomad run helloworld.nomad
Lookup host and port
nomad status helloworld
nomad alloc-status _xxx_
Call helloworld
curl -s http://_ip_:_port_/hello
curl -s http://_ip_:_port_/env | jq .
nomad run consul.nomad
See cluster:
consul members
Check the UI at http://localhost:8500/ui
nomad run fabio.nomad
Check the UI at http://localhost:9998/
Test routing:
curl -s -H 'Host: helloworld.gce.nauts.io' http://localhost:9999/hello
Prerequisites:
- http-fabio health check
- firewall rule to let LB access fabio
- allocated static (
global-dc
) helloword.gce.nauts.io
DNS entry points to static IP.
In GCP console:
- go to Networking / Load Balancer
- click 'create load balancer'
- HTTP(S) load balancing / Start configuration
- Enter name
devoxx
- Backend Configuration / Create a Backend service
- Enter name
farm-backend
- New Backend
farm-eu
- port number:
9999
- Health check
http-fabio
- Leave Host and Path rules as is.
- Frontend configuration / select a static IP
global-dc
for HTTP port 80 - Create
Select 'monitoring' on created LB and wait until backends are healthy. Check helloworld:
curl -s http://helloworld.gce.nauts.io/hello
Create cluster in us-central1
region with zones a
, b
and c
:
cd scripts/
./install-region us-central1 a b c
Add backend to load balancer.
Perform requests to helloworld from US and Asia to see them served by the US cluster. Latency will be lower.