Skip to content

Commit dbabf1a

Browse files
committed
chore(confd): remove confd in favor env vars that can configure things
New Env Vars are: * REGISTRATION_MODE which defaults to enabled * RESERVED_NAME which defaults to deis Gunicorn reload script was left behind just to have an easy script to reload the process if that is desired instead of cycling the pod Fixes #358
1 parent c3bc5a5 commit dbabf1a

8 files changed

Lines changed: 12 additions & 58 deletions

File tree

rootfs/Dockerfile

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@ FROM alpine:3.3
33
# install common packages
44
RUN apk add --update-cache curl bash openssl sudo && rm -rf /var/cache/apk/*
55

6-
# install etcdctl and confd
7-
RUN apk add --update-cache curl tar \
8-
&& curl -sSL -o /usr/local/bin/confd https://github.com/kelseyhightower/confd/releases/download/v0.12.0-alpha3/confd-0.12.0-alpha3-linux-amd64 \
9-
&& chmod +x /usr/local/bin/confd \
10-
&& apk del --purge curl tar \
11-
&& rm -rf /var/cache/apk/*
12-
136
# define execution environment
147
CMD ["/app/bin/boot"]
158
EXPOSE 8000

rootfs/bin/boot

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ echo system information:
1313
echo "Django Version: $(./manage.py --version)"
1414
python --version
1515

16-
# spawn confd in the background to update services based on changes
17-
confd -backend env --confdir /app --log-level error --interval 5 &
18-
1916
mkdir -p /app/data/logs
2017
chmod -R 777 /app/data/logs
2118

@@ -27,18 +24,18 @@ else
2724
fi
2825

2926
echo "Django checks:"
30-
python /app/manage.py check --deploy api
27+
python /app/manage.py check --settings deis.production --deploy api
3128

3229
echo "Health Checks:"
33-
python /app/manage.py healthchecks
30+
python /app/manage.py healthchecks --settings deis.production
3431

3532
echo "Database Migrations:"
36-
sudo -E -u deis python /app/manage.py migrate --noinput
33+
sudo -E -u deis python /app/manage.py migrate --settings deis.production --noinput
3734

3835
# spawn a gunicorn server in the background
3936
sudo -E -u deis gunicorn -c /app/deis/gconf.py deis.wsgi &
4037

41-
python /app/manage.py load_db_state_to_k8s
38+
python /app/manage.py load_db_state_to_k8s --settings deis.production
4239

4340
# smart shutdown on SIGTERM (SIGINT is handled by gunicorn)
4441
function on_exit() {

rootfs/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ adduser deis -D -h /app -s /bin/bash
3333
# create a /app directory for storing application data
3434
mkdir -p /app && chown -R deis:deis /app
3535

36-
# create directory for confd templates
37-
mkdir -p /templates && chown -R deis:deis /templates
36+
# create directory for configurations
37+
mkdir -p /configs && chown -R deis:deis /configs
3838

3939
# install dependencies
4040
pip install --disable-pip-version-check --no-cache-dir -r /app/requirements.txt

rootfs/conf.d/gconf.toml

Lines changed: 0 additions & 10 deletions
This file was deleted.

rootfs/conf.d/local_settings.toml

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import os
2+
13
bind = '0.0.0.0'
24
try:
3-
workers = int({{ if exists "/deis/controller/workers" }}{{ getv "/deis/controller/workers" }}{{ else }}"not set"{{end}})
5+
workers = int(os.environ.get('GUNICORN_WORKERS', 'not set'))
46
if workers < 1:
57
raise ValueError()
68
except (NameError, ValueError):
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import os
2-
3-
from .settings import *
1+
from deis.settings import * # noqa
42

53
# security keys and auth tokens
64
with open('/var/run/secrets/api/builder/auth/builder-key') as f:
@@ -16,9 +14,3 @@
1614
DATABASES['default']['PASSWORD'] = f.read().strip()
1715

1816
DATABASES['default']['NAME'] = DATABASES['default']['USER']
19-
20-
REGISTRATION_MODE = '{{ getv "/deis/controller/registration/mode" "enabled" }}'
21-
22-
{{ if exists "/deis/controller/subdomain" }}
23-
DEIS_RESERVED_NAMES = ['{{ getv "/deis/controller/subdomain" }}']
24-
{{ end }}

rootfs/deis/settings.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@
250250
TEMPDIR = tempfile.mkdtemp(prefix='deis')
251251

252252
# names which apps cannot reserve for routing
253-
DEIS_RESERVED_NAMES = ['deis']
253+
DEIS_RESERVED_NAMES = [os.environ.get('RESERVED_NAMES', 'deis')]
254254

255255
# default scheduler settings
256256
SCHEDULER_MODULE = 'scheduler'
@@ -276,7 +276,7 @@
276276
LOGGER_PORT = os.environ.get('DEIS_LOGGER_SERVICE_PORT_HTTP', 80)
277277

278278
# check if we can register users with `deis register`
279-
REGISTRATION_ENABLED = True
279+
REGISTRATION_MODE = os.environ.get('REGISTRATION_MODE', 'enabled')
280280

281281
DATABASES = {
282282
'default': {
@@ -290,13 +290,3 @@
290290
}
291291

292292
APP_URL_REGEX = '[a-z0-9-]+'
293-
294-
# Create a file named "local_settings.py" to contain sensitive settings data
295-
# such as database configuration, admin email, or passwords and keys. It
296-
# should also be used for any settings which differ between development
297-
# and production.
298-
# The local_settings.py file should *not* be checked in to version control.
299-
try:
300-
from .local_settings import * # noqa
301-
except ImportError:
302-
pass

0 commit comments

Comments
 (0)