From 9fa4be55037ccf047e12bee4df73dc5719ee595f Mon Sep 17 00:00:00 2001 From: Shahbaz Nazir Date: Wed, 21 Feb 2018 16:43:28 +0100 Subject: [PATCH] Added update config before starting nginx Signed-off-by: Shahbaz Nazir --- k8s/3scale-apicast/apicast-conf.yaml | 8 ---- k8s/3scale-apicast/apicast-dep.yaml | 34 ++++++++++++----- k8s/3scale-apicast/apicast-svc.yaml | 2 +- .../container/docker_build_and_push.bash | 2 +- .../container/nginx_openresty_entrypoint.bash | 37 +++++++++---------- 5 files changed, 44 insertions(+), 39 deletions(-) delete mode 100644 k8s/3scale-apicast/apicast-conf.yaml diff --git a/k8s/3scale-apicast/apicast-conf.yaml b/k8s/3scale-apicast/apicast-conf.yaml deleted file mode 100644 index 02fec5e1..00000000 --- a/k8s/3scale-apicast/apicast-conf.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: v1 -kind: Secret -metadata: - name: apicast-secret - namespace: default -type: Opaque -data: - portal-endpoint: "aHR0cHM6Ly9jNzQzOTRhM2M1NzQ5OWE5ZWIxNGI4YzYzZWZjNmVkNUBiaWdjaGFpbmRiLWFkbWluLjNzY2FsZS5uZXQ" \ No newline at end of file diff --git a/k8s/3scale-apicast/apicast-dep.yaml b/k8s/3scale-apicast/apicast-dep.yaml index b1a6d1e9..9fab4967 100644 --- a/k8s/3scale-apicast/apicast-dep.yaml +++ b/k8s/3scale-apicast/apicast-dep.yaml @@ -13,24 +13,38 @@ spec: containers: - name: nginx-openresty image: bigchaindb/nginx_3scale:unstable - imagePullPolicy: IfNotPresent + imagePullPolicy: Always env: - - name: RESOLVER - valueFrom: - configMapKeyRef: - name: vars - key: cluster-dns-server-ip - name: THREESCALE_PORTAL_ENDPOINT valueFrom: secretKeyRef: name: apicast-secret key: portal-endpoint + - name: RESOLVER + valueFrom: + configMapKeyRef: + name: vars + key: cluster-dns-server-ip - name: APICAST_LOG_LEVEL - value: "debug" - - name: APICAST_CONFIGURATION_LOADER - value: "boot" + valueFrom: + configMapKeyRef: + name: apicast-config + key: api-log-level - name: APICAST_MANAGEMENT_API - value: "debug" + valueFrom: + configMapKeyRef: + name: apicast-config + key: mgmt-api-mode + - name: BIGCHAINDB_BACKEND_HOST + valueFrom: + configMapKeyRef: + name: vars + key: bdb-instance-name + - name: BIGCHAINDB_API_PORT + valueFrom: + configMapKeyRef: + name: vars + key: bigchaindb-api-port ports: - containerPort: 8080 protocol: TCP diff --git a/k8s/3scale-apicast/apicast-svc.yaml b/k8s/3scale-apicast/apicast-svc.yaml index 835ab37e..d8259151 100644 --- a/k8s/3scale-apicast/apicast-svc.yaml +++ b/k8s/3scale-apicast/apicast-svc.yaml @@ -16,7 +16,7 @@ spec: ports: - port: 8080 targetPort: 8080 - name: apicast-proxy + name: apicast-svc - port: 8090 targetPort: 8090 name: apicast-mgmt diff --git a/k8s/3scale-apicast/container/docker_build_and_push.bash b/k8s/3scale-apicast/container/docker_build_and_push.bash index 571b9e42..31dbb5e9 100755 --- a/k8s/3scale-apicast/container/docker_build_and_push.bash +++ b/k8s/3scale-apicast/container/docker_build_and_push.bash @@ -2,4 +2,4 @@ docker build -t bigchaindb/nginx_3scale:unstable . -#docker push bigchaindb/nginx_3scale:unstable +docker push bigchaindb/nginx_3scale:unstable diff --git a/k8s/3scale-apicast/container/nginx_openresty_entrypoint.bash b/k8s/3scale-apicast/container/nginx_openresty_entrypoint.bash index 5ad2f181..1511b63c 100755 --- a/k8s/3scale-apicast/container/nginx_openresty_entrypoint.bash +++ b/k8s/3scale-apicast/container/nginx_openresty_entrypoint.bash @@ -5,34 +5,33 @@ BASE_DIR=$(pwd) APICAST_RELEASE="3.1.0" BASE_GIT_URL="https://github.com/3scale/apicast/archive" - -# Sanity Check -if [[ -z "${THREESCALE_PORTAL_ENDPOINT:?THREESCALE_PORTAL_ENDPOINT not specified. Exiting!}" || \ - -z "${BDB_SERVICE_ENDPOINT:?bigchaindb backend service endpoint not specified. Exiting!}" ]]; then - exit 1 -fi - -# Download and Install Apicast -wget "${BASE_GIT_URL}/v${APICAST_RELEASE}.tar.gz" -tar -xvzf "v${APICAST_RELEASE}.tar.gz" - -luarocks make apicast-${APICAST_RELEASE}/apicast/*.rockspec --tree /usr/local/openresty/luajit - - - # Set Default config export APICAST_CONFIGURATION_LOADER="boot" # Overriding apicast default lazy config loader export APICAST_MANAGEMENT_API="debug" # Overriding apicast default fo 'status' mode to be - # able to update service endpoint from https://test.bigchaindb.com - # to local service endpoint + # able to update bigchaindb backen service endpoint + +# Sanity Check +if [[ -z "${THREESCALE_PORTAL_ENDPOINT:?THREESCALE_PORTAL_ENDPOINT not specified. Exiting!}" || \ + -z "${BIGCHAINDB_BACKEND_HOST:?BIGCHAINDB_BACKEND_HOST not specified. Exiting!}" || \ + -z "${BIGCHAINDB_API_PORT:?BIGCHAINDB_API_PORT not specified. Exiting!}" ]]; then + exit 1 +fi + +export THREESCALE_PORTAL_ENDPOINT=`printenv THREESCALE_PORTAL_ENDPOINT` # Print Current Configs echo "Apicast Release: ${APICAST_RELEASE}" echo "Apicast Download URL: ${BASE_GIT_URL}" echo "APICAST_CONFIGURATION_LOADER: ${APICAST_CONFIGURATION_LOADER}" -echo "BDB_SERVICE_ENDPOINT: ${BDB_SERVICE_ENDPOINT}" +echo "BIGCHAINDB_BACKEND_HOST: ${BIGCHAINDB_BACKEND_HOST}" +echo "BIGCHAINDB_API_PORT: ${BIGCHAINDB_API_PORT}" +# Download and Install Apicast +wget "${BASE_GIT_URL}/v${APICAST_RELEASE}.tar.gz" +tar -xvzf "v${APICAST_RELEASE}.tar.gz" + +eval luarocks make apicast-${APICAST_RELEASE}/apicast/*.rockspec --tree /usr/local/openresty/luajit # Start nginx echo "INFO: starting nginx..." -exec apicast-${APICAST_RELEASE}/apicast/bin/apicast -b -e production -v -v -v +exec apicast-${APICAST_RELEASE}/apicast/bin/apicast -b -e production -v -v -v \ No newline at end of file