Skip to content

Commit

Permalink
73 openshift crashes slightly less often (project-koku#109)
Browse files Browse the repository at this point in the history
* Added sleep to cluster up and a reinit feature to the Makefile that makes the project without a cluster down/up cycle

* Added troubleshooting for OpenShift docker to openshift.rst

* Gave the DB it's own secret and modified db name
  • Loading branch information
adberglund authored May 8, 2018
1 parent 6ba9401 commit 5a93be9
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ help:
@echo " oc-up-all to run app in openshift cluster"
@echo " oc-up-db to run Postgres in an openshift cluster"
@echo " oc-init to start app in initialized openshift cluster"
@echo " oc-reinit to remove existing app and restart app in initialized openshift cluster"
@echo " oc-create-db to create a Postgres DB in an initialized openshift cluster"
@echo " oc-forward-ports to port forward the DB to localhost"
@echo " oc-stop-forwarding-ports to stop port forwarding the DB to localhost"
Expand Down Expand Up @@ -93,6 +94,7 @@ oc-up:
--version=$(OC_VERSION) \
--host-data-dir=$(OC_DATA_DIR) \
--use-existing-config=true
sleep 60

oc-init:
openshift/init-app.sh -n myproject -b `git rev-parse --abbrev-ref HEAD`
Expand All @@ -101,6 +103,12 @@ oc-up-all: oc-up oc-init

oc-up-db: oc-up oc-create-db

oc-reinit:
oc login -u developer
oc delete all -l app=koku && oc delete configmap/koku-env secret/koku-secret secret/koku-pgsql-secret pvc/koku-pgsql
sleep 10
make oc-init

oc-down:
oc cluster down

Expand Down
8 changes: 8 additions & 0 deletions docs/source/openshift.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ Add `172.30.1.1` to the list of proxies to bypass. This can be found at Docker -
.. _`docker-community-edition-17091-ce-mac42-2017-12-11`: https://docs.docker.com/docker-for-mac/release-notes/#docker-community-edition-17091-ce-mac42-2017-12-11
.. _`Test an insecure registry | Docker Documentation`: https://docs.docker.com/registry/insecure/


Troubleshooting
---------------

OpenShift uses Docker to run containers. When running a cluster locally for developement, deployment can be strained by low resource allowances in Docker. For development it is recommended that Docker have at least 4 GB of memory available for use.

Also, if Openshift services misbehave or do not deploy properly, it can be useful to spin the cluster down, restart the Docker service and retry.

Generating the Template
=======================

Expand Down
31 changes: 26 additions & 5 deletions openshift/koku-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,29 @@ objects:
metadata:
labels:
name: ${NAME}
annotations:
template.openshift.io/expose-password: "{.data['database-password']}"
template.openshift.io/expose-username: "{.data['database-user']}"
template.openshift.io/expose-django_secret_key: "{.data['django-secret-key']}"
name: koku-secret
stringData:
database-password: ${DATABASE_PASSWORD}
database-user: ${DATABASE_USER}
django-secret-key: ${DJANGO_SECRET_KEY}
- apiVersion: v1
kind: Secret
metadata:
labels:
name: ${DATABASE_SERVICE_NAME}-secret
annotations:
template.openshift.io/expose-database_name: "{.data['database-name']}"
template.openshift.io/expose-password: "{.data['database-password']}"
template.openshift.io/expose-username: "{.data['database-user']}"
name: ${DATABASE_SERVICE_NAME}-secret
stringData:
database-name: ${DATABASE_NAME}
database-password: ${DATABASE_PASSWORD}
database-user: ${DATABASE_USER}
- apiVersion: v1
metadata:
name: koku-env
Expand Down Expand Up @@ -279,14 +297,17 @@ objects:
valueFrom:
secretKeyRef:
key: database-user
name: koku-secret
name: ${DATABASE_SERVICE_NAME}-secret
- name: POSTGRESQL_PASSWORD
valueFrom:
secretKeyRef:
key: database-password
name: koku-secret
name: ${DATABASE_SERVICE_NAME}-secret
- name: POSTGRESQL_DATABASE
value: ${DATABASE_NAME}
valueFrom:
secretKeyRef:
key: database-name
name: ${DATABASE_SERVICE_NAME}-secret
image: postgresql:9.6
imagePullPolicy: IfNotPresent
livenessProbe:
Expand Down Expand Up @@ -424,9 +445,9 @@ parameters:
- displayName: Database Name
name: DATABASE_NAME
required: true
value: default
value: koku
- displayName: Database Username
from: '[a-zA-Z0-9]{16}'
from: 'user_[a-zA-Z0-9]{12}'
generate: expression
name: DATABASE_USER
required: true
Expand Down

0 comments on commit 5a93be9

Please sign in to comment.