Skip to content

Commit 416d54d

Browse files
Matthewmboersma
authored andcommitted
ref(controller): use kubernetes service discovery, remove publish loop
1 parent 5657ed8 commit 416d54d

3 files changed

Lines changed: 11 additions & 75 deletions

File tree

rootfs/bin/boot

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -53,37 +53,17 @@ etcd_set_default secretKey "${DEIS_SECRET_KEY:-$(openssl rand -base64 64 | tr -d
5353
etcd_set_default builderKey "${DEIS_BUILDER_KEY:-$(openssl rand -base64 64 | tr -d '\n')}"
5454
etcd_set_default registrationMode "enabled"
5555
etcd_set_default webEnabled 0
56-
etcd_set_default unitHostname default
5756

5857
# safely create required keyspaces
5958
etcd_safe_mkdir /deis/domains
6059
etcd_safe_mkdir /deis/platform
6160
etcd_safe_mkdir /deis/scheduler
6261
etcd_safe_mkdir /deis/services
6362

64-
# HACK: set up keys for database
65-
etcd_safe_mkdir /deis/database
66-
ETCD_PATH=/deis/database etcd_set_default engine postgresql_psycopg2
67-
ETCD_PATH=/deis/database etcd_set_default name deis
68-
ETCD_PATH=/deis/database etcd_set_default user deis
69-
ETCD_PATH=/deis/database etcd_set_default password changeme123
70-
ETCD_PATH=/deis/database etcd_set_default host "${DEIS_DATABASE_SERVICE_HOST:-127.0.0.1}"
71-
ETCD_PATH=/deis/database etcd_set_default port "${DEIS_DATABASE_SERVICE_PORT:-5432}"
72-
73-
# HACK: set up keys for logs
74-
etcd_safe_mkdir /deis/logs
75-
ETCD_PATH=/deis/logs etcd_set_default host "${DEIS_LOGS_SERVICE_HOST:-127.0.0.1}"
76-
7763
# HACK: set up keys for platform
7864
etcd_safe_mkdir /deis/platform
7965
ETCD_PATH=/deis/platform etcd_set_default domain localhost
8066

81-
# HACK: set up keys for registry
82-
etcd_safe_mkdir /deis/registry
83-
ETCD_PATH=/deis/registry etcd_set_default protocol "${DEIS_REGISTRY_SERVICE_PROTOCOL:-http}"
84-
ETCD_PATH=/deis/registry etcd_set_default host "${DEIS_REGISTRY_SERVICE_HOST:-127.0.0.1}"
85-
ETCD_PATH=/deis/registry etcd_set_default port "${DEIS_REGISTRY_SERVICE_PORT:-5000}"
86-
8767
# run etcd data migrations
8868
echo "controller: running etcd data migrations..."
8969
for script in /app/migrations/data/*.sh;
@@ -133,28 +113,4 @@ confd -node "$ETCD" --confdir /app --log-level error --interval 5 &
133113

134114
echo deis-controller running...
135115

136-
# publish the service to etcd using the injected EXTERNAL_PORT
137-
if [[ ! -z $EXTERNAL_PORT ]]; then
138-
139-
# configure service discovery
140-
PORT=${PORT:-8000}
141-
PROTO=${PROTO:-tcp}
142-
143-
set +e
144-
145-
# wait for the service to become available on PORT
146-
sleep 1 && while [[ -z $(netstat -lnt | awk "\$6 == \"LISTEN\" && \$4 ~ \".$PORT\" && \$1 ~ \"$PROTO.?\"") ]] ; do sleep 1; done
147-
148-
# while the port is listening, publish to etcd
149-
while [[ ! -z $(netstat -lnt | awk "\$6 == \"LISTEN\" && \$4 ~ \".$PORT\" && \$1 ~ \"$PROTO.?\"") ]] ; do
150-
etcdctl --no-sync -C "$ETCD" set "$ETCD_PATH/host" "$HOST" --ttl "$ETCD_TTL" >/dev/null
151-
etcdctl --no-sync -C "$ETCD" set "$ETCD_PATH/port" "$EXTERNAL_PORT" --ttl "$ETCD_TTL" >/dev/null
152-
sleep $((ETCD_TTL/2)) # sleep for half the TTL
153-
done
154-
155-
# if the loop quits, something went wrong
156-
exit 1
157-
158-
fi
159-
160116
wait

rootfs/deis/settings.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -305,25 +305,28 @@
305305
BUILDER_KEY = os.environ.get('DEIS_BUILDER_KEY', 'CHANGEME_sapm$s%upvsw5l_zuy_&29rkywd^78ff(qi')
306306

307307
# registry settings
308-
REGISTRY_URL = 'http://localhost:5000'
309-
REGISTRY_HOST = 'localhost'
310-
REGISTRY_PORT = 5000
308+
REGISTRY_HOST = os.environ.get('DEIS_REGISTRY_SERVICE_HOST', '127.0.0.1')
309+
REGISTRY_PORT = os.environ.get('DEIS_REGISTRY_SERVICE_PORT', 5000)
310+
REGISTRY_URL = '{}:{}'.format(REGISTRY_HOST, REGISTRY_PORT)
311311

312312
# logger settings
313-
LOGGER_HOST = 'localhost'
314-
LOGGER_PORT = 8088
313+
LOGGER_HOST = os.environ.get('DEIS_LOGGER_SERVICE_HOST', '127.0.0.1')
314+
LOGGER_PORT = os.environ.get('DEIS_LOGGER_SERVICE_PORT', 8088)
315315

316316
# check if we can register users with `deis register`
317317
REGISTRATION_ENABLED = True
318318

319319
# check if we should enable the web UI module
320320
WEB_ENABLED = False
321321

322-
# default to sqlite3, but allow postgresql config through envvars
323322
DATABASES = {
324323
'default': {
325-
'ENGINE': 'django.db.backends.' + os.environ.get('DATABASE_ENGINE', 'postgresql_psycopg2'),
326-
'NAME': os.environ.get('DATABASE_NAME', 'deis'),
324+
'ENGINE': 'django.db.backends.postgresql_psycopg2',
325+
'NAME': os.environ.get('DEIS_DATABASE_NAME', 'deis'),
326+
'USER': os.environ.get('DEIS_DATABASE_USER', ''),
327+
'PASSWORD': os.environ.get('DEIS_DATABASE_PASSWORD', ''),
328+
'HOST': os.environ.get('DEIS_DATABASE_SERVICE_HOST', '127.0.0.1'),
329+
'PORT': os.environ.get('DEIS_DATABASE_SERVICE_PORT', 5432),
327330
# randomize test database name so we can run multiple unit tests simultaneously
328331
'TEST_NAME': "unittest-{}".format(''.join(
329332
random.choice(string.ascii_letters + string.digits) for _ in range(8)))

rootfs/templates/confd_settings.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,9 @@
66
SCHEDULER_MODULE = 'scheduler.k8s'
77
SCHEDULER_URL = 'kubernetes'
88

9-
# base64-encoded SSH private key to facilitate current version of "deis run"
10-
SSH_PRIVATE_KEY = """{{ if exists "/deis/platform/sshPrivateKey" }}{{ getv "/deis/platform/sshPrivateKey" }}{{ else }}""{{end}}"""
11-
129
# platform domain must be provided
1310
DEIS_DOMAIN = '{{ getv "/deis/platform/domain" }}'
1411

15-
# use the private registry module
16-
REGISTRY_URL = '{{ getv "/deis/registry/protocol" }}://{{ getv "/deis/registry/host" }}:{{ getv "/deis/registry/port" }}' # noqa
17-
REGISTRY_HOST = '{{ getv "/deis/registry/host" }}'
18-
REGISTRY_PORT = '{{ getv "/deis/registry/port" }}'
19-
20-
# default to sqlite3, but allow postgresql config through envvars
21-
# 'ENGINE': 'django.db.backends.{{ getv "/deis/database/engine" }}',
22-
DATABASES = {
23-
'default': {
24-
'ENGINE': 'django.db.backends.postgresql_psycopg2',
25-
'NAME': '{{ getv "/deis/database/name" }}',
26-
'USER': '{{ getv "/deis/database/user" }}',
27-
'PASSWORD': '{{ getv "/deis/database/password" }}',
28-
'HOST': '{{ getv "/deis/database/host" }}',
29-
'PORT': '{{ getv "/deis/database/port" }}',
30-
}
31-
}
32-
33-
LOGGER_HOST = '{{ getv "/deis/logs/host"}}'
34-
3512
{{ if exists "/deis/controller/registrationMode" }}
3613
REGISTRATION_MODE = '{{ getv "/deis/controller/registrationMode" }}'
3714
{{ end }}

0 commit comments

Comments
 (0)