diff --git a/docker/Dockerfile.j2 b/docker/Dockerfile.j2 index f328cd6..170264d 100644 --- a/docker/Dockerfile.j2 +++ b/docker/Dockerfile.j2 @@ -1,10 +1,12 @@ 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 \ libapache2-mod-wsgi \ + netcat \ && ln -s ../mods-available/headers.load /etc/apache2/mods-enabled/headers.load RUN curl -o horizon-{{ branch }}.tar.gz http://tarballs.openstack.org/horizon/horizon-{{ branch }}.tar.gz \ @@ -18,7 +20,7 @@ RUN mv horizon*/ horizon-{{ branch }}/ \ && /var/lib/microservices/venv/bin/pip --no-cache-dir install --upgrade -c /horizon-{{ branch }}/requirements.txt /horizon-{{ branch }} \ && useradd --user-group horizon \ && ln -s /etc/openstack-dashboard/local_settings /var/lib/microservices/venv/lib/python2.7/site-packages/openstack_dashboard/local/local_settings.py \ - && cp -r /horizon-source/openstack_dashboard/conf/* /etc/openstack-dashboard/ \ + && cp -r /horizon-{{ branch }}/openstack_dashboard/conf/* /etc/openstack-dashboard/ \ && cp /horizon-{{ branch }}/manage.py /var/lib/microservices/venv/bin/manage.py \ && /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 }} diff --git a/docker/start.sh b/docker/start.sh index 52e7d1c..649d3c9 100644 --- a/docker/start.sh +++ b/docker/start.sh @@ -1,10 +1,20 @@ #!/bin/bash -/var/lib/microservices/venv/bin/python /var/lib/microservices/venv/bin/manage.py compress --force +/var/lib/microservices/venv/bin/python \ + /var/lib/microservices/venv/bin/manage.py compress --force source /etc/apache2/envvars -sed -i "s/Secret_String/${HORIZON_SECRET_KEY}" /etc/openstack-dashboard/local_settings -sed -i "s/KEYSTONE_ADDRESS/${KEYSTONE_ADDRESS}" /etc/openstack-dashboard/local_settings +sed -i "s/Secret_String/${HORIZON_SECRET_KEY}" \ + /etc/openstack-dashboard/local_settings +sed -i "s/KEYSTONE_ADDRESS/${KEYSTONE_ADDRESS}" \ + /etc/openstack-dashboard/local_settings + +#check does keyston is alive +nc -z -v -w5 ${KEYSTONE_ADDRESS} 5000 +if [ $? -ne 0 ];then + exit 1 +fi + exec /usr/sbin/apache2 -DNO_DETACH diff --git a/service/horizon.yaml.j2 b/service/horizon.yaml.j2 new file mode 100644 index 0000000..7bba428 --- /dev/null +++ b/service/horizon.yaml.j2 @@ -0,0 +1,17 @@ +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 + imagePullPolicy: Always + ports: + - containerPort: 80 + hostPort: 80 diff --git a/service/service-horizon.yaml.j2 b/service/service-horizon.yaml.j2 new file mode 100644 index 0000000..3bd94af --- /dev/null +++ b/service/service-horizon.yaml.j2 @@ -0,0 +1,23 @@ +{ + "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" + } +} +