Commit c670e931 authored by David Mendez's avatar David Mendez
Browse files

Merge branch 'staging' into 'master'

FInish to set up deployment to staging

See merge request !1
parents 98545ffd cc721180
......@@ -25,8 +25,8 @@ stages:
- test_and_qa
- prepare_config_staging
- deploy_to_staging
# - test_staging
# - prepare_config_hx
- test_staging
- prepare_config_hx
# - deploy_to_prod_hx
# - test_prod_hx
# - prepare_config_hh
......@@ -99,8 +99,11 @@ prepare_config_staging:
image:
name: alpine/git
entrypoint: ["/bin/sh", "-c"]
only:
- staging
script:
- set -x
- rm -rf ${CONFIGS_FOLDER} || true
- mkdir -p ${CONFIGS_FOLDER}
- git clone https://${CONFIG_DEPLOY_GITLAB_USERNAME}:${CONFIG_DEPLOY_GITLAB_TOKEN}@${CONFIGURATIONS_REPO} ${CONFIGS_FOLDER}
artifacts:
......@@ -127,9 +130,8 @@ deploy_to_staging:
- kubectl config use-context ${CHEMBL_NS_STAGING}
- echo ${CHEMBL_NS_STAGING} ${KUBE_URL_HX} ${KUBE_CLUS_NAME_HX} ${KUBE_USER_HX}
- kubectl get pods -n ${CHEMBL_NS_STAGING}
- kubectl create secret generic ${RUN_CONFIG_SECRET_NAME_STAGING} --from-file=RUN_CONFIG.yml=${CONFIG_STAGING_FILE_PATH} -o yaml -n ${CHEMBL_NS_STAGING} --dry-run | kubectl apply -f -
- exit 0
- kubectl create secret generic ${GUNICORN_CONFIG_SECRET_NAME_STAGING} --from-file=GUNICORN_CONFIG.py=${CONFIG_GUNICORN_STAGING_FILE_PATH} -o yaml -n ${CHEMBL_NS_STAGING} --dry-run | kubectl replace -f -
- kubectl create secret generic ${RUN_CONFIG_SECRET_NAME_STAGING} --from-file=RUN_CONFIG.yml=${CONFIG_STAGING_FILE_PATH} -o yaml -n ${CHEMBL_NS_STAGING} --dry-run=client | kubectl replace -f -
- kubectl create secret generic ${GUNICORN_CONFIG_SECRET_NAME_STAGING} --from-file=GUNICORN_CONFIG.py=${CONFIG_GUNICORN_STAGING_FILE_PATH} -o yaml -n ${CHEMBL_NS_STAGING} --dry-run=client | kubectl replace -f -
- cat ${CONFIG_STAGING_FILE_PATH}
- cat ${CONFIG_GUNICORN_STAGING_FILE_PATH}
- sed -i "s~<NAMESPACE>~${CHEMBL_NS_STAGING}~" k8s-deployment.yaml
......@@ -137,11 +139,6 @@ deploy_to_staging:
- sed -i "s~<UID>~${CBL_ADM_UID}~" k8s-deployment.yaml
- sed -i "s~<GID>~${CBL_PUB_GID}~" k8s-deployment.yaml
- sed -i "s~<SERVER_IMAGE_TAG>~${SERVER_IMAGE_TAG}~" k8s-deployment.yaml
- sed -i "s~<STATUS_DAEMON_IMAGE_TAG>~${STATUS_DAEMON_IMAGE_TAG}~" k8s-deployment.yaml
- sed -i "s~<NFS_MOUNT_PATH>~${NFS_MOUNT_PATH_STAGING}~" k8s-deployment.yaml
- sed -i "s~<NFS_FQDN>~${NFS_FQDN_HX}~" k8s-deployment.yaml
- sed -i "s~<NFS_PATH>~${NFS_PATH_HX}~" k8s-deployment.yaml
- sed -i "s~<ID_RSA_SECRET_NAME>~${ID_RSA_SECRET_NAME_STAGING}~" k8s-deployment.yaml
- sed -i "s~<RUN_CONFIG_SECRET_NAME>~${RUN_CONFIG_SECRET_NAME_STAGING}~" k8s-deployment.yaml
- sed -i "s~<GUNICORN_CONFIG_SECRET_NAME>~${GUNICORN_CONFIG_SECRET_NAME_STAGING}~" k8s-deployment.yaml
- cat k8s-deployment.yaml
......@@ -151,43 +148,40 @@ deploy_to_staging:
## ----------------------------------------------------------------------------------------------------------------------
## Test staging
## ----------------------------------------------------------------------------------------------------------------------
#functional_tests:
# stage: test_staging
# image:
# name: $SERVER_IMAGE_TAG
# entrypoint: [""]
# only:
# - staging
# except:
# - schedules
# environment:
# name: staging
# url: ${SERVER_URL_STAGING}
# script:
# - set -x
# - sleep 30 # Give some time for the deployment to take effect.
# - functional_tests/run_functional_tests.py ${SERVER_URL_STAGING} ${DJ_SERVER_ADMIN_USERNAME_STAGING} ${DJ_SERVER_ADMIN_PASSWORD_STAGING}
functional_tests:
stage: test_staging
image:
name: $SERVER_IMAGE_TAG
entrypoint: [""]
only:
- staging
environment:
name: staging
url: ${SERVER_URL_STAGING}
script:
- set -x
- exit 0 # disabled temporarily
- sleep 30 # Give some time for the deployment to take effect.
- functional_tests/run_functional_tests.py ${SERVER_URL_STAGING} ${DJ_SERVER_ADMIN_USERNAME_STAGING} ${DJ_SERVER_ADMIN_PASSWORD_STAGING}
#
## ----------------------------------------------------------------------------------------------------------------------
## Deployment to prod hx
## ----------------------------------------------------------------------------------------------------------------------
#prepare_config_prod_hx:
# stage: prepare_config_hx
# image:
# name: alpine/git
# entrypoint: ["/bin/sh", "-c"]
# only:
# - master
# except:
# - schedules
# script:
# - rm -rf ${CONFIGS_FOLDER} || true
# - mkdir -p ${CONFIGS_FOLDER}
# - git clone https://${CONFIG_DEPLOY_GITLAB_USERNAME}:${CONFIG_DEPLOY_GITLAB_TOKEN}@${CONFIGURATIONS_REPO} ${CONFIGS_FOLDER}
# artifacts:
# paths:
# - ${CONFIG_PROD_HX_FILE_PATH}
# - ${CONFIG_GUNICORN_PROD_HX_FILE_PATH}
prepare_config_prod_hx:
stage: prepare_config_hx
image:
name: alpine/git
entrypoint: ["/bin/sh", "-c"]
only:
- master
script:
- rm -rf ${CONFIGS_FOLDER} || true
- mkdir -p ${CONFIGS_FOLDER}
- git clone https://${CONFIG_DEPLOY_GITLAB_USERNAME}:${CONFIG_DEPLOY_GITLAB_TOKEN}@${CONFIGURATIONS_REPO} ${CONFIGS_FOLDER}
artifacts:
paths:
- ${CONFIG_PROD_HX_FILE_PATH}
- ${CONFIG_GUNICORN_PROD_HX_FILE_PATH}
#
#deploy_to_prod_hx:
# stage: deploy_to_prod_hx
......
......@@ -13,6 +13,10 @@ SWAGGER_BLUEPRINT = Blueprint('swagger', __name__)
@SWAGGER_BLUEPRINT.route('/swagger.json')
def get_json():
"""
:return: Responds to the request with the json version of the swagger description
"""
yaml_file_path = Path(Path().absolute()).joinpath('app', 'swagger', 'swagger.yaml')
with open(yaml_file_path, 'r') as stream:
......
......@@ -10,6 +10,7 @@ from app.cache import CACHE
class ContextLoaderError(Exception):
"""Base class for exceptions in this module."""
WEB_RESULTS_SIZE_LIMIT = RUN_CONFIG.get('filter_query_max_clauses')
......@@ -65,4 +66,3 @@ def load_context_index(context_id, id_property, context):
CACHE.set(context_index_key, context_index, 3600)
return context_index
apiVersion: apps/v1
kind: Deployment
metadata:
name: elasticsearch-proxy-api-server
namespace: <NAMESPACE>
spec:
replicas: <NUM_REPLICAS>
selector:
matchLabels:
app: elasticsearch-proxy-api
template:
metadata:
labels:
app: elasticsearch-proxy-api
spec:
securityContext:
runAsUser: <UID>
runAsGroup: <GID>
containers:
- name: elasticsearch-proxy-api
image: <SERVER_IMAGE_TAG>
imagePullPolicy: Always
volumeMounts:
- name: run-config
mountPath: '/etc/run_config/'
readOnly: true
- name: gunicorn-config
mountPath: '/etc/gunicorn_config/'
readOnly: true
volumes:
- name: run-config
secret:
secretName: <RUN_CONFIG_SECRET_NAME>
- name: gunicorn-config
secret:
secretName: <GUNICORN_CONFIG_SECRET_NAME>
---
apiVersion: v1
kind: Service
metadata:
name: elasticsearch-proxy-api
namespace: <NAMESPACE>
spec:
type: NodePort
selector:
app: elasticsearch-proxy-api
ports:
- port: 5000
targetPort: 5000
"""
WSGI config for the Elasticsearch API server.
"""
from app import create_app
FLASK_APP = create_app()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment