Adding application definition for horizon

Change-Id: I67830e1e7ee2fcf3724de77bf44a2bef88da20aa
This commit is contained in:
Andrey Pavlov 2016-06-08 18:19:48 +03:00 committed by Proskurin Kirill
parent 4106361818
commit 7530f9bf5f
9 changed files with 50 additions and 90 deletions

View File

@ -1,7 +1,6 @@
FROM {{ namespace }}/openstack-base:{{ tag }}
MAINTAINER {{ maintainer }}
#netcat is for test whether keystone is alive
RUN apt-get update \
&& apt-get install --no-install-recommends -q -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \
apache2 \
@ -11,9 +10,6 @@ RUN apt-get update \
RUN curl -o horizon-{{ branch }}.tar.gz http://tarballs.openstack.org/horizon/horizon-{{ branch }}.tar.gz \
&& tar -zxvf horizon-{{ branch }}.tar.gz
ADD openstach-dashboard.conf /etc/apache2/conf-enabled/openstack-dashboard.conf
ADD local_settings /etc/openstack-dashboard/local_settings
RUN mv horizon*/ horizon-{{ branch }}/ \
&& mkdir -p /etc/openstack-dashboard /home/horizon /var/www/cgi-bin/horizon \
&& /var/lib/microservices/venv/bin/pip --no-cache-dir install --upgrade -c /horizon-{{ branch }}/requirements.txt /horizon-{{ branch }} \
@ -24,10 +20,7 @@ RUN mv horizon*/ horizon-{{ branch }}/ \
&& /var/lib/microservices/venv/bin/python /var/lib/microservices/venv/bin/manage.py collectstatic --noinput --clear \
&& chown -R horizon: /etc/openstack-dashboard /home/horizon /var/lib/microservices/venv/lib/python2.7/site-packages/static /horizon-{{ branch }}
COPY start.sh /usr/local/bin/start.sh
RUN chmod 755 /usr/local/bin/start.sh
CMD ["/usr/local/bin/start.sh"]
EXPOSE 80
ENV PATH /var/lib/venv/bin:$PATH
COPY daemon.sh /usr/local/bin/daemon.sh
RUN chmod 755 /usr/local/bin/daemon.sh

4
docker/horizon/daemon.sh Normal file
View File

@ -0,0 +1,4 @@
#!/bin/bash
source /etc/apache2/envvars
/usr/sbin/apache2 -DNO_DETACH

View File

@ -1,35 +0,0 @@
#!/bin/bash
/var/lib/microservices/venv/bin/python \
/var/lib/microservices/venv/bin/manage.py compress --force
source /etc/apache2/envvars
DASHBOARD="/etc/openstack-dashboard/local_settings"
BACKEND="django.core.cache.backends.memcached.MemcachedCache"
if [ -z "$HORIZON_SECRET_KEY" ]; then
KEY=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
HORIZON_SECRET_KEY=$KEY
fi
if [ -z "$KEYSTONE_ADDRESS" ]; then
KEYSTONE_ADDRESS="127.0.0.1"
fi
sed -i "s/Secret_String/${HORIZON_SECRET_KEY}/g" $DASHBOARD
sed -i "s/KEYSTONE_ADDRESS/${KEYSTONE_ADDRESS}/g" $DASHBOARD
if [ -n "$MEMCACHED_LOCATION" ]; then
CONF="{'default':{'BACKEND':'$BACKEND','LOCATION':'$MEMCACHED_LOCATION',},}"
sed -i 's/^CACHES = .*$/CACHES = $CONF/g' $DASHBOARD
fi
#check if keystone is alive
nc -z -v -w5 ${KEYSTONE_ADDRESS} 5000
if [ $? -ne 0 ];then
exit 1
fi
exec /usr/sbin/apache2 -DNO_DETACH

View File

@ -0,0 +1,3 @@
configs:
horizon_port: 80
horizon_secret_key: secret

View File

@ -121,17 +121,17 @@ LOCAL_PATH = os.path.dirname(os.path.abspath(__file__))
# (usually behind a load-balancer). Either you have to make sure that a session
# gets all requests routed to the same dashboard instance or you set the same
# SECRET_KEY for all of them.
SECRET_KEY = 'Secret_String'
SECRET_KEY = "{{ horizon_secret_key }}"
# We recommend you use memcached for development; otherwise after every reload
# of the django development server, you will have to login again. To use
# memcached set CACHES to something like
#CACHES = {
# 'default': {
# 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
# 'LOCATION': '127.0.0.1:11211',
# },
#}
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': 'memcached:{{ memcached_port }}',
},
}
CACHES = {'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',},}
@ -152,8 +152,8 @@ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
# ('http://cluster2.example.com:5000/v2.0', 'cluster2'),
#]
OPENSTACK_HOST = "KEYSTONE_ADDRESS"
OPENSTACK_KEYSTONE_URL = "http://%s:5000/v2.0" % OPENSTACK_HOST
OPENSTACK_HOST = "keystone"
OPENSTACK_KEYSTONE_URL = "http://%s:{{ keystone_public_port }}/v3" % OPENSTACK_HOST
OPENSTACK_KEYSTONE_DEFAULT_ROLE = "_member_"
# Enables keystone web single-sign-on if set to True.
@ -226,8 +226,8 @@ OPENSTACK_KEYSTONE_BACKEND = {
# Toggle LAUNCH_INSTANCE_LEGACY_ENABLED and LAUNCH_INSTANCE_NG_ENABLED to
# determine the experience to enable. Set them both to true to enable
# both.
#LAUNCH_INSTANCE_LEGACY_ENABLED = True
#LAUNCH_INSTANCE_NG_ENABLED = False
LAUNCH_INSTANCE_LEGACY_ENABLED = True
LAUNCH_INSTANCE_NG_ENABLED = False
# A dictionary of settings which can be used to provide the default values for
# properties found in the Launch Instance modal.

29
service/horizon.yaml Normal file
View File

@ -0,0 +1,29 @@
service:
name: horizon
ports:
- horizon_port
container:
node-selector:
openstack-controller: "true"
probes:
readiness: "true"
liveness: "true"
pre:
- name: horizon-compress
command: /var/lib/microservices/venv/bin/python /var/lib/microservices/venv/bin/manage.py compress --force
daemon:
dependencies:
- keystone
- memcached
files:
- local-settings
- openstack-dashboard-conf
command: daemon.sh
files:
local-settings:
path: /etc/openstack-dashboard/local_settings
content: local_settings.j2
openstack-dashboard-conf:
path: /etc/apache2/conf-enabled/openstack-dashboard.conf
content: openstack-dashboard.conf.j2

View File

@ -1,19 +0,0 @@
apiVersion: v1
kind: Pod
metadata:
name: horizon
labels:
app: horizon
spec:
containers:
- name: horizon
image: {{ namespace }}/horizon:{{ tag }}
env:
- name: KEYSTONE_ADDRESS
value: keystone-service.default.svc.cluster.local
- name: HORIZON_SECRET_KEY
value: secret
imagePullPolicy: Always
ports:
- containerPort: 80
hostPort: 80

View File

@ -1,15 +0,0 @@
kind: "Service"
apiVersion: "v1"
metadata:
name: "horizon-service"
spec:
selector:
app: "horizon"
ports:
-
name: "www"
protocol: "TCP"
port: 80
targetPort: 80
nodePort: 30080
type: "NodePort"