From 5a93be9f58326e19a9e64161bd88c2e695730c09 Mon Sep 17 00:00:00 2001 From: Andrew Berglund Date: Tue, 8 May 2018 09:36:16 -0400 Subject: [PATCH] 73 openshift crashes slightly less often (#109) * 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 --- Makefile | 8 ++++++++ docs/source/openshift.rst | 8 ++++++++ openshift/koku-template.yaml | 31 ++++++++++++++++++++++++++----- 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 84a3eb2939..fc5e5356bd 100644 --- a/Makefile +++ b/Makefile @@ -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" @@ -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` @@ -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 diff --git a/docs/source/openshift.rst b/docs/source/openshift.rst index b6ae6134ba..49569fd470 100644 --- a/docs/source/openshift.rst +++ b/docs/source/openshift.rst @@ -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 ======================= diff --git a/openshift/koku-template.yaml b/openshift/koku-template.yaml index aaba27a9fb..aad773ddf4 100644 --- a/openshift/koku-template.yaml +++ b/openshift/koku-template.yaml @@ -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 @@ -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: @@ -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