Added update config before starting nginx

Signed-off-by: Shahbaz Nazir <shahbaz@bigchaindb.com>
This commit is contained in:
Shahbaz Nazir 2018-02-21 16:43:28 +01:00
parent d577b209e7
commit 9fa4be5503
5 changed files with 44 additions and 39 deletions

View File

@ -1,8 +0,0 @@
apiVersion: v1
kind: Secret
metadata:
name: apicast-secret
namespace: default
type: Opaque
data:
portal-endpoint: "aHR0cHM6Ly9jNzQzOTRhM2M1NzQ5OWE5ZWIxNGI4YzYzZWZjNmVkNUBiaWdjaGFpbmRiLWFkbWluLjNzY2FsZS5uZXQ"

View File

@ -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

View File

@ -16,7 +16,7 @@ spec:
ports:
- port: 8080
targetPort: 8080
name: apicast-proxy
name: apicast-svc
- port: 8090
targetPort: 8090
name: apicast-mgmt

View File

@ -2,4 +2,4 @@
docker build -t bigchaindb/nginx_3scale:unstable .
#docker push bigchaindb/nginx_3scale:unstable
docker push bigchaindb/nginx_3scale:unstable

View File

@ -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