Skip to content

Commit 62006c4

Browse files
feat(*): Scalable registry
Allow the deis registry to be scaled across multiple cluster nodes
1 parent 1cb0655 commit 62006c4

5 files changed

Lines changed: 27 additions & 16 deletions

File tree

deisctl/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ deis-store-gateway.service: loaded
4343
Control plane...
4444
deis-cache.service: loaded
4545
deis-database.service: loaded
46-
deis-registry.service: loaded
46+
deis-registry@1.service: loaded
4747
deis-controller.service: loaded
4848
deis-builder.service: loaded
4949
Data plane...
@@ -70,7 +70,7 @@ deis-store-gateway.service: running
7070
Control plane...
7171
deis-cache.service: running
7272
deis-database.service: running
73-
deis-registry.service: running
73+
deis-registry@1.service: running
7474
deis-controller.service: running
7575
deis-builder.service: running
7676
Data plane...
@@ -84,7 +84,7 @@ Done.
8484

8585
Note that the default start command activates 1 of each component.
8686
You can scale components with `deisctl scale router=3`, for example.
87-
The router is the only component that _currently_ scales beyond 1 unit.
87+
The router and the registry are the only component that _currently_ scales beyond 1 unit.
8888

8989
You can also use the `deisctl uninstall` command to destroy platform units:
9090

@@ -103,7 +103,7 @@ deis-controller.service: inactive
103103
deis-builder.service: inactive
104104
deis-cache.service: inactive
105105
deis-database.service: inactive
106-
deis-registry.service: inactive
106+
deis-registry@1.service: inactive
107107
Storage subsystem...
108108
deis-store-gateway.service: inactive
109109
Logging subsystem...
@@ -140,7 +140,7 @@ deis-cache.service f936b7a5.../172.17.8.100 loaded active running
140140
deis-controller.service f936b7a5.../172.17.8.100 loaded active running
141141
deis-database.service f936b7a5.../172.17.8.100 loaded active running
142142
deis-logger.service f936b7a5.../172.17.8.100 loaded active running
143-
deis-registry.service f936b7a5.../172.17.8.100 loaded active running
143+
deis-registry@1.service f936b7a5.../172.17.8.100 loaded active running
144144
deis-router@1.service f936b7a5.../172.17.8.100 loaded active running
145145
```
146146

deisctl/cmd/cmd.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ func ListUnitFiles(argv []string, b backend.Backend) error {
4747
}
4848

4949
// Scale grows or shrinks the number of running components.
50-
// Currently "router" is the only type that can be scaled.
50+
// Currently "router" and "registry" are the only types that can be scaled.
5151
func Scale(argv []string, b backend.Backend) error {
5252
usage := `Grows or shrinks the number of running components.
5353
54-
Currently "router" is the only type that can be scaled.
54+
Currently "router" and "registry" are the only types that can be scaled.
5555
5656
Usage:
5757
deisctl scale [<target>...] [options]
@@ -75,7 +75,7 @@ Usage:
7575
return err
7676
}
7777
// the router is the only component that can scale at the moment
78-
if !strings.Contains(component, "router") {
78+
if !strings.Contains(component, "router") && !strings.Contains(component, "registry") {
7979
return fmt.Errorf("cannot scale %s components", component)
8080
}
8181
b.Scale(component, num, &wg, outchan, errchan)
@@ -186,12 +186,12 @@ func startDefaultServices(b backend.Backend, wg *sync.WaitGroup, outchan chan st
186186

187187
// optimization: start all remaining services in the background
188188
b.Start([]string{
189-
"cache", "database", "registry", "controller", "builder",
189+
"cache", "database", "registry@1", "controller", "builder",
190190
"publisher", "router@1", "router@2", "router@3"},
191191
&_wg, _outchan, _errchan)
192192

193193
outchan <- fmt.Sprintf("Control plane...")
194-
b.Start([]string{"cache", "database", "registry", "controller"}, wg, outchan, errchan)
194+
b.Start([]string{"cache", "database", "registry@1", "controller"}, wg, outchan, errchan)
195195
wg.Wait()
196196
b.Start([]string{"builder"}, wg, outchan, errchan)
197197
wg.Wait()
@@ -270,7 +270,7 @@ func stopDefaultServices(b backend.Backend, wg *sync.WaitGroup, outchan chan str
270270
wg.Wait()
271271

272272
outchan <- fmt.Sprintf("Control plane...")
273-
b.Stop([]string{"controller", "builder", "cache", "database", "registry"}, wg, outchan, errchan)
273+
b.Stop([]string{"controller", "builder", "cache", "database", "registry@1"}, wg, outchan, errchan)
274274
wg.Wait()
275275

276276
outchan <- fmt.Sprintf("Logging subsystem...")
@@ -432,7 +432,7 @@ func installDefaultServices(b backend.Backend, wg *sync.WaitGroup, outchan chan
432432
wg.Wait()
433433

434434
outchan <- fmt.Sprintf("Control plane...")
435-
b.Create([]string{"cache", "database", "registry", "controller", "builder"}, wg, outchan, errchan)
435+
b.Create([]string{"cache", "database", "registry@1", "controller", "builder"}, wg, outchan, errchan)
436436
wg.Wait()
437437

438438
outchan <- fmt.Sprintf("Data plane...")
@@ -512,7 +512,7 @@ func uninstallAllServices(b backend.Backend, wg *sync.WaitGroup, outchan chan st
512512
wg.Wait()
513513

514514
outchan <- fmt.Sprintf("Control plane...")
515-
b.Destroy([]string{"controller", "builder", "cache", "database", "registry"}, wg, outchan, errchan)
515+
b.Destroy([]string{"controller", "builder", "cache", "database", "registry@1"}, wg, outchan, errchan)
516516
wg.Wait()
517517

518518
outchan <- fmt.Sprintf("Logging subsystem...")

deisctl/deisctl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Commands, use "deisctl help <command>" to learn more:
3737
start start compnents
3838
stop stop components
3939
restart stop, then start components
40-
scale grow or shrink the number of routers
40+
scale grow or shrink the number of routers or registries
4141
journal print the log output of a component
4242
config set platform or component values
4343
refresh-units refresh unit files from GitHub

deisctl/units/deis-registry.service

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ RestartSec=5
1313

1414
[Install]
1515
WantedBy=multi-user.target
16+
17+
[X-Fleet]
18+
Conflicts=deis-registry@*.service

registry/bin/boot

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ set -eo pipefail
1313
export ETCD_PORT=${ETCD_PORT:-4001}
1414
export ETCD="$HOST:$ETCD_PORT"
1515
export ETCD_PATH=${ETCD_PATH:-/deis/registry}
16+
export HOST_ETCD_PATH=${HOST_ETCD_PATH:-/deis/registry/hosts/$HOST}
1617
export ETCD_TTL=${ETCD_TTL:-10}
1718

1819
# run.sh requires $REGISTRY_PORT
@@ -86,8 +87,15 @@ if [[ ! -z $EXTERNAL_PORT ]]; then
8687

8788
# while the port is listening, publish to etcd
8889
while [[ ! -z $(netstat -lnt | awk "\$6 == \"LISTEN\" && \$4 ~ \".$PORT\" && \$1 ~ \"$PROTO.?\"") ]] ; do
89-
etcdctl --no-sync -C $ETCD set $ETCD_PATH/host $HOST --ttl $ETCD_TTL >/dev/null
90-
etcdctl --no-sync -C $ETCD set $ETCD_PATH/port $EXTERNAL_PORT --ttl $ETCD_TTL >/dev/null
90+
if etcdctl --no-sync -C $ETCD mk ${ETCD_PATH}/masterLock $HOSTNAME --ttl $ETCD_TTL >/dev/null 2>&1 \
91+
|| [[ `etcdctl --no-sync -C $ETCD get ${ETCD_PATH}/masterLock` == "$HOSTNAME" ]] ; then
92+
etcdctl --no-sync -C $ETCD set $ETCD_PATH/host $HOST --ttl $ETCD_TTL >/dev/null
93+
etcdctl --no-sync -C $ETCD set $ETCD_PATH/port $EXTERNAL_PORT --ttl $ETCD_TTL >/dev/null
94+
etcdctl --no-sync -C $ETCD update ${ETCD_PATH}/masterLock $HOSTNAME --ttl $ETCD_TTL >/dev/null
95+
fi
96+
etcdctl --no-sync -C $ETCD set $HOST_ETCD_PATH/host $HOST --ttl $ETCD_TTL >/dev/null
97+
etcdctl --no-sync -C $ETCD set $HOST_ETCD_PATH/port $EXTERNAL_PORT --ttl $ETCD_TTL >/dev/null
98+
9199
sleep $(($ETCD_TTL/2)) # sleep for half the TTL
92100
done
93101

0 commit comments

Comments
 (0)