Skip to content

Commit

Permalink
Update to get things working with kubernetes
Browse files Browse the repository at this point in the history
This is mostly for the sake of learning: the fact that the sqlite
database is in container means it's fairly useless: you can't scale
horizontally. Future work will explore different ways of dealing
what that.

The Dockerfile is update to reflect the latest placement extraction
changes and to put config in the container rather than using a
shared volume.

The placement-uwsgi.ini is update so it runs http directly.
There's no need for an nginx or apache setup, a k8s LoadBalancer
in deployment.yaml takes care of that.

The uwsgi ini is based on info at:
nginx/kubernetes-ingress#143 (comment)

Using minikube the steps are:

    eval $(minikube docker-env)
    docker build -t placedock:1.0 .
    kubectl apply -f deployment.yaml
    kubectl expose deployment placement-deployment --type=LoadBalancer
    minikube service placement-deployment --url
  • Loading branch information
cdent committed Mar 17, 2018
1 parent 7a89475 commit a2f4b10
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 26 deletions.
23 changes: 12 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,27 @@ RUN pip3 install -r placement-requirements.txt

# Do this all in one big piece otherwise the nova bits are out of date
# Thanks to ingy for figuring out a faster way to do this.
# We must get rid of a symlink which can lead to errors, see:
# https://github.com/python/cpython/pull/4267
RUN git clone --depth=1 https://git.openstack.org/openstack/nova && \
cd nova && \
git fetch --depth=2 --append origin \
refs/changes/62/549862/11 \
refs/changes/66/362766/75 \
refs/changes/35/541435/17 \
refs/changes/62/549862/14 \
refs/changes/66/362766/79 \
refs/changes/35/541435/21 \
refs/changes/57/553857/2 \
refs/changes/62/543262/7 && \
git cherry-pick $(cut -f1 .git/FETCH_HEAD) && \
# get rid of a symlink which can lead to errors, see:
# https://github.com/python/cpython/pull/4267
find . -type l -exec rm {} \; && \
pip3 install --no-deps .



# create the placement db
ADD sync.py /
ADD /shared/etc/nova/nova.conf /
RUN python3 sync.py --config-file nova.conf
ADD /shared/placement-uwsgi.ini /
RUN mkdir /etc/nova
ADD /shared/etc/nova/nova.conf /etc/nova
RUN python3 sync.py --config-file /etc/nova/nova.conf

# Mount nova config and uwsgi config
VOLUME /shared
ENTRYPOINT ["uwsgi", "--ini", "/shared/placement-uwsgi.ini"]
CMD ["/usr/sbin/uwsgi", "--ini", "/placement-uwsgi.ini"]
EXPOSE 80
19 changes: 19 additions & 0 deletions deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
name: placement-deployment
spec:
selector:
matchLabels:
app: placement
replicas: 1
template:
metadata:
labels:
app: placement
spec:
containers:
- name: placement
image: placedock:1.0
ports:
- containerPort: 80
55 changes: 40 additions & 15 deletions shared/placement-uwsgi.ini
Original file line number Diff line number Diff line change
@@ -1,18 +1,43 @@

[uwsgi]
chmod-socket = 666
socket = 172.*:80
lazy-apps = true
add-header = Connection: close
buffer-size = 65535
hook-master-start = unix_signal:15 gracefully_kill_them_all
thunder-lock = true
plugins = python3
enable-threads = true
worker-reload-mercy = 90
exit-on-reload = false
die-on-term = true
master = true
processes = 4
wsgi-file = /usr/bin/nova-placement-api
env = OS_PLACEMENT_CONFIG_DIR=/shared/etc/nova

processes = 2
threads = 10

http-socket = :80
http-enable-proxy-protocol = 1
http-auto-chunked = true
http-keepalive = 75
http-timeout = 75
stats = :1717
stats-http = 1
offload-threads = 10

# Better startup/shutdown in docker:
die-on-term = 1
lazy-apps = 0

vacuum = 1
master = 1
enable-threads = true
thunder-lock = 1
buffer-size = 65535

# Logging
log-x-forwarded-for = true

# Avoid errors on aborted client connections
ignore-sigpipe = true
ignore-write-errors = true
disable-write-exception = true

no-defer-accept = 1

# Limits, Kill requests after 120 seconds
harakiri = 120
harakiri-verbose = true
post-buffering = 4096

# Custom headers
add-header = Connection: Keep-Alive

0 comments on commit a2f4b10

Please sign in to comment.