From da3abef491dbccc791fa5441a5562c39d5518fbb Mon Sep 17 00:00:00 2001 From: yiyione Date: Thu, 12 Nov 2020 13:59:03 +0800 Subject: [PATCH] [Marketplace] Deploy scripts and config (#5066) * update * update * update * update * add marketplace-db * update * update * fix * fix * add marketplace-restserver * update * update * fix * update pylon * update * update * update * update * update * update --- .../build/marketplace-db.k8s.dockerfile | 4 ++ src/marketplace-db/config/marketplace-db.yaml | 11 +++++ src/marketplace-db/config/marketplace_db.py | 27 ++++++++++++ src/marketplace-db/deploy/delete.sh | 10 +++++ .../deploy/marketplace-db.yaml.template | 43 +++++++++++++++++++ src/marketplace-db/deploy/refresh.sh | 11 +++++ src/marketplace-db/deploy/service.yaml | 20 +++++++++ src/marketplace-db/deploy/start.sh.template | 13 ++++++ src/marketplace-db/deploy/stop.sh | 6 +++ .../marketplace-restserver.k8s.dockerfile | 4 ++ .../config/marketplace-restserver.yaml | 11 +++++ .../config/marketplace_restserver.py | 28 ++++++++++++ src/marketplace-restserver/deploy/delete.sh | 10 +++++ .../marketplace-restserver.yaml.template | 39 +++++++++++++++++ src/marketplace-restserver/deploy/refresh.sh | 11 +++++ .../deploy/service.yaml | 20 +++++++++ .../deploy/start.sh.template | 13 ++++++ src/marketplace-restserver/deploy/stop.sh | 6 +++ .../marketplace-webportal.k8s.dockerfile | 4 ++ .../config/marketplace-webportal.yaml | 8 ++++ .../config/marketplace_webportal.py | 29 +++++++++++++ src/marketplace-webportal/deploy/delete.sh | 10 +++++ .../marketplace-webportal.yaml.template | 29 +++++++++++++ src/marketplace-webportal/deploy/refresh.sh | 11 +++++ src/marketplace-webportal/deploy/service.yaml | 20 +++++++++ .../deploy/start.sh.template | 13 ++++++ src/marketplace-webportal/deploy/stop.sh | 6 +++ .../pylon-config/location.conf.template | 32 ++++++++++++++ src/pylon/deploy/pylon.yaml.template | 8 ++++ 29 files changed, 457 insertions(+) create mode 100644 src/marketplace-db/build/marketplace-db.k8s.dockerfile create mode 100644 src/marketplace-db/config/marketplace-db.yaml create mode 100644 src/marketplace-db/config/marketplace_db.py create mode 100644 src/marketplace-db/deploy/delete.sh create mode 100644 src/marketplace-db/deploy/marketplace-db.yaml.template create mode 100644 src/marketplace-db/deploy/refresh.sh create mode 100644 src/marketplace-db/deploy/service.yaml create mode 100644 src/marketplace-db/deploy/start.sh.template create mode 100644 src/marketplace-db/deploy/stop.sh create mode 100644 src/marketplace-restserver/build/marketplace-restserver.k8s.dockerfile create mode 100644 src/marketplace-restserver/config/marketplace-restserver.yaml create mode 100644 src/marketplace-restserver/config/marketplace_restserver.py create mode 100644 src/marketplace-restserver/deploy/delete.sh create mode 100644 src/marketplace-restserver/deploy/marketplace-restserver.yaml.template create mode 100644 src/marketplace-restserver/deploy/refresh.sh create mode 100644 src/marketplace-restserver/deploy/service.yaml create mode 100644 src/marketplace-restserver/deploy/start.sh.template create mode 100644 src/marketplace-restserver/deploy/stop.sh create mode 100644 src/marketplace-webportal/build/marketplace-webportal.k8s.dockerfile create mode 100644 src/marketplace-webportal/config/marketplace-webportal.yaml create mode 100644 src/marketplace-webportal/config/marketplace_webportal.py create mode 100644 src/marketplace-webportal/deploy/delete.sh create mode 100644 src/marketplace-webportal/deploy/marketplace-webportal.yaml.template create mode 100644 src/marketplace-webportal/deploy/refresh.sh create mode 100644 src/marketplace-webportal/deploy/service.yaml create mode 100644 src/marketplace-webportal/deploy/start.sh.template create mode 100644 src/marketplace-webportal/deploy/stop.sh diff --git a/src/marketplace-db/build/marketplace-db.k8s.dockerfile b/src/marketplace-db/build/marketplace-db.k8s.dockerfile new file mode 100644 index 0000000000..9a57b59d2c --- /dev/null +++ b/src/marketplace-db/build/marketplace-db.k8s.dockerfile @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +FROM docker.io/postgres:12.0 diff --git a/src/marketplace-db/config/marketplace-db.yaml b/src/marketplace-db/config/marketplace-db.yaml new file mode 100644 index 0000000000..aa67b4bdca --- /dev/null +++ b/src/marketplace-db/config/marketplace-db.yaml @@ -0,0 +1,11 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +service_type: "k8s" + +user: user +passwd: passwd +db: marketplace +port: 9291 +max-connection: 1000 +data-path: /mnt/marketplace diff --git a/src/marketplace-db/config/marketplace_db.py b/src/marketplace-db/config/marketplace_db.py new file mode 100644 index 0000000000..c4da3f9b11 --- /dev/null +++ b/src/marketplace-db/config/marketplace_db.py @@ -0,0 +1,27 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +import copy + +class MarketplaceDb(object): + def __init__(self, cluster_conf, service_conf, default_service_conf): + self.cluster_conf = cluster_conf + self.service_conf = dict(default_service_conf, **service_conf) + + def validation_pre(self): + machine_list = self.cluster_conf['machine-list'] + if len([host for host in machine_list if host.get('pai-master') == 'true']) < 1: + return False, '"pai-master=true" machine is required to deploy the marketplace-db service' + return True, None + + def run(self): + result = copy.deepcopy(self.service_conf) + machine_list = self.cluster_conf['machine-list'] + master_ip = [host['hostip'] for host in machine_list if host.get('pai-master') == 'true'][0] + result['host'] = master_ip + result['connection-str'] = 'postgresql://{}:{}@{}:{}/{}'.format( + result['user'], result['passwd'], result['host'], result['port'], result['db']) + return result + + def validation_post(self, conf): + return True, None diff --git a/src/marketplace-db/deploy/delete.sh b/src/marketplace-db/deploy/delete.sh new file mode 100644 index 0000000000..5ceb907e38 --- /dev/null +++ b/src/marketplace-db/deploy/delete.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +pushd $(dirname "$0") > /dev/null + +/bin/bash stop.sh || exit $? + +popd > /dev/null diff --git a/src/marketplace-db/deploy/marketplace-db.yaml.template b/src/marketplace-db/deploy/marketplace-db.yaml.template new file mode 100644 index 0000000000..abe51a8325 --- /dev/null +++ b/src/marketplace-db/deploy/marketplace-db.yaml.template @@ -0,0 +1,43 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: marketplace-db-ds +spec: + selector: + matchLabels: + app: marketplace-db + template: + metadata: + name: marketplace-db + labels: + app: marketplace-db + spec: + hostNetwork: true + containers: + - name: marketplace-db + image: {{ cluster_cfg["cluster"]["docker-registry"]["prefix"] }}marketplace-db:{{ cluster_cfg["cluster"]["docker-registry"]["tag"] }} + imagePullPolicy: Always + env: + - name: POSTGRES_USER + value: {{ cluster_cfg["marketplace-db"]["user"] }} + - name: POSTGRES_PASSWORD + value: {{ cluster_cfg["marketplace-db"]["passwd"] }} + - name: POSTGRES_DB + value: {{ cluster_cfg["marketplace-db"]["db"] }} + - name: PGDATA + value: /var/lib/postgresql/data/pgdata + args: ['-c', 'port={{- cluster_cfg["marketplace-db"]["port"] }}', '-N', '{{ cluster_cfg["marketplace-db"]["max-connection"] }}'] + volumeMounts: + - name: marketplace-data-dir + mountPath: /var/lib/postgresql/data/pgdata + mountPropagation: "None" + volumes: + - name: marketplace-data-dir + hostPath: + path: '{{ cluster_cfg["marketplace-db"]["data-path"] }}' + type: DirectoryOrCreate + imagePullSecrets: + - name: {{ cluster_cfg["cluster"]["docker-registry"]["secret-name"] }} diff --git a/src/marketplace-db/deploy/refresh.sh b/src/marketplace-db/deploy/refresh.sh new file mode 100644 index 0000000000..bd50ad3ded --- /dev/null +++ b/src/marketplace-db/deploy/refresh.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +pushd $(dirname "$0") > /dev/null + +bash stop.sh +bash start.sh + +popd > /dev/null diff --git a/src/marketplace-db/deploy/service.yaml b/src/marketplace-db/deploy/service.yaml new file mode 100644 index 0000000000..22f84dcd60 --- /dev/null +++ b/src/marketplace-db/deploy/service.yaml @@ -0,0 +1,20 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +cluster-type: + - k8s + +prerequisite: + - cluster-configuration + +template-list: + - marketplace-db.yaml + - start.sh + +start-script: start.sh +stop-script: stop.sh +delete-script: delete.sh +refresh-script: refresh.sh + +deploy-rules: + - in: pai-master diff --git a/src/marketplace-db/deploy/start.sh.template b/src/marketplace-db/deploy/start.sh.template new file mode 100644 index 0000000000..0251fdc7da --- /dev/null +++ b/src/marketplace-db/deploy/start.sh.template @@ -0,0 +1,13 @@ +#!/bin/bash + +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +pushd $(dirname "$0") > /dev/null + +kubectl apply --overwrite=true -f marketplace-db.yaml || exit $? + +# Wait until the service is ready. +PYTHONPATH="../../../deployment" python -m k8sPaiLibrary.monitorTool.check_pod_ready_status -w -k app -v marketplace-db || exit $? + +popd > /dev/null diff --git a/src/marketplace-db/deploy/stop.sh b/src/marketplace-db/deploy/stop.sh new file mode 100644 index 0000000000..4f1c496084 --- /dev/null +++ b/src/marketplace-db/deploy/stop.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +kubectl delete --ignore-not-found --now "daemonset/marketplace-db-ds" diff --git a/src/marketplace-restserver/build/marketplace-restserver.k8s.dockerfile b/src/marketplace-restserver/build/marketplace-restserver.k8s.dockerfile new file mode 100644 index 0000000000..005c719740 --- /dev/null +++ b/src/marketplace-restserver/build/marketplace-restserver.k8s.dockerfile @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +FROM docker.io/openpai/pai-marketplace-restserver:v1.2.0 diff --git a/src/marketplace-restserver/config/marketplace-restserver.yaml b/src/marketplace-restserver/config/marketplace-restserver.yaml new file mode 100644 index 0000000000..03352991fe --- /dev/null +++ b/src/marketplace-restserver/config/marketplace-restserver.yaml @@ -0,0 +1,11 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +service_type: "k8s" + +db_user: user +db_password: passwd +db: marketplace +# db_host: postgres +db_port: 9291 +server-port: 9292 diff --git a/src/marketplace-restserver/config/marketplace_restserver.py b/src/marketplace-restserver/config/marketplace_restserver.py new file mode 100644 index 0000000000..457466ca90 --- /dev/null +++ b/src/marketplace-restserver/config/marketplace_restserver.py @@ -0,0 +1,28 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +import copy + +class MarketplaceRestserver(object): + def __init__(self, cluster_conf, service_conf, default_service_conf): + self.cluster_conf = cluster_conf + self.service_conf = dict(default_service_conf, **service_conf) + + def validation_pre(self): + machine_list = self.cluster_conf['machine-list'] + if len([host for host in machine_list if host.get('pai-master') == 'true']) < 1: + return False, '"pai-master=true" machine is required to deploy the marketplace-restserver service' + return True, None + + def run(self): + result = copy.deepcopy(self.service_conf) + machine_list = self.cluster_conf['machine-list'] + server_port = self.service_conf['server-port'] + master_ip = [host['hostip'] for host in machine_list if host.get('pai-master') == 'true'][0] + result['uri'] = 'http://{0}:{1}'.format(master_ip, server_port) + if 'db_host' not in result: + result['db_host'] = master_ip + return result + + def validation_post(self, conf): + return True, None diff --git a/src/marketplace-restserver/deploy/delete.sh b/src/marketplace-restserver/deploy/delete.sh new file mode 100644 index 0000000000..5ceb907e38 --- /dev/null +++ b/src/marketplace-restserver/deploy/delete.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +pushd $(dirname "$0") > /dev/null + +/bin/bash stop.sh || exit $? + +popd > /dev/null diff --git a/src/marketplace-restserver/deploy/marketplace-restserver.yaml.template b/src/marketplace-restserver/deploy/marketplace-restserver.yaml.template new file mode 100644 index 0000000000..45cb1c735c --- /dev/null +++ b/src/marketplace-restserver/deploy/marketplace-restserver.yaml.template @@ -0,0 +1,39 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: marketplace-restserver-ds +spec: + selector: + matchLabels: + app: marketplace-restserver + template: + metadata: + name: marketplace-restserver + labels: + app: marketplace-restserver + spec: + hostNetwork: true + containers: + - name: marketplace-restserver + image: {{ cluster_cfg["cluster"]["docker-registry"]["prefix"] }}marketplace-restserver:{{ cluster_cfg["cluster"]["docker-registry"]["tag"] }} + imagePullPolicy: Always + env: + - name: DB_USERNAME + value: {{ cluster_cfg["marketplace-restserver"]["db_user"] }} + - name: DB_PASSWORD + value: {{ cluster_cfg["marketplace-restserver"]["db_password"] }} + - name: DATABASE + value: {{ cluster_cfg["marketplace-restserver"]["db"] }} + - name: DB_HOST + value: {{ cluster_cfg["marketplace-restserver"]["db_host"] }} + - name: DB_PORT + value: "{{ cluster_cfg["marketplace-restserver"]["db_port"] }}" + - name: NODE_ENV + value: production + - name: PORT + value: "{{ cluster_cfg["marketplace-restserver"]["server-port"] }}" + imagePullSecrets: + - name: {{ cluster_cfg["cluster"]["docker-registry"]["secret-name"] }} diff --git a/src/marketplace-restserver/deploy/refresh.sh b/src/marketplace-restserver/deploy/refresh.sh new file mode 100644 index 0000000000..bd50ad3ded --- /dev/null +++ b/src/marketplace-restserver/deploy/refresh.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +pushd $(dirname "$0") > /dev/null + +bash stop.sh +bash start.sh + +popd > /dev/null diff --git a/src/marketplace-restserver/deploy/service.yaml b/src/marketplace-restserver/deploy/service.yaml new file mode 100644 index 0000000000..8b22188561 --- /dev/null +++ b/src/marketplace-restserver/deploy/service.yaml @@ -0,0 +1,20 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +cluster-type: + - k8s + +prerequisite: + - cluster-configuration + +template-list: + - marketplace-restserver.yaml + - start.sh + +start-script: start.sh +stop-script: stop.sh +delete-script: delete.sh +refresh-script: refresh.sh + +deploy-rules: + - in: pai-master diff --git a/src/marketplace-restserver/deploy/start.sh.template b/src/marketplace-restserver/deploy/start.sh.template new file mode 100644 index 0000000000..93d0d7753c --- /dev/null +++ b/src/marketplace-restserver/deploy/start.sh.template @@ -0,0 +1,13 @@ +#!/bin/bash + +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +pushd $(dirname "$0") > /dev/null + +kubectl apply --overwrite=true -f marketplace-restserver.yaml || exit $? + +# Wait until the service is ready. +PYTHONPATH="../../../deployment" python -m k8sPaiLibrary.monitorTool.check_pod_ready_status -w -k app -v marketplace-restserver || exit $? + +popd > /dev/null diff --git a/src/marketplace-restserver/deploy/stop.sh b/src/marketplace-restserver/deploy/stop.sh new file mode 100644 index 0000000000..ea204f1378 --- /dev/null +++ b/src/marketplace-restserver/deploy/stop.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +kubectl delete --ignore-not-found --now "daemonset/marketplace-restserver-ds" diff --git a/src/marketplace-webportal/build/marketplace-webportal.k8s.dockerfile b/src/marketplace-webportal/build/marketplace-webportal.k8s.dockerfile new file mode 100644 index 0000000000..a2f12ff94a --- /dev/null +++ b/src/marketplace-webportal/build/marketplace-webportal.k8s.dockerfile @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +FROM docker.io/openpai/pai-marketplace-webportal:v1.2.0 diff --git a/src/marketplace-webportal/config/marketplace-webportal.yaml b/src/marketplace-webportal/config/marketplace-webportal.yaml new file mode 100644 index 0000000000..de69d0be87 --- /dev/null +++ b/src/marketplace-webportal/config/marketplace-webportal.yaml @@ -0,0 +1,8 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +service_type: "k8s" + +# marketplace_api_uri: marketplace_api_uri +api-port: 9292 +server-port: 9293 diff --git a/src/marketplace-webportal/config/marketplace_webportal.py b/src/marketplace-webportal/config/marketplace_webportal.py new file mode 100644 index 0000000000..7a807e4b3c --- /dev/null +++ b/src/marketplace-webportal/config/marketplace_webportal.py @@ -0,0 +1,29 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +import copy + +class MarketplaceWebportal(object): + def __init__(self, cluster_conf, service_conf, default_service_conf): + self.cluster_conf = cluster_conf + self.service_conf = dict(default_service_conf, **service_conf) + + def validation_pre(self): + machine_list = self.cluster_conf['machine-list'] + if len([host for host in machine_list if host.get('pai-master') == 'true']) < 1: + return False, '"pai-master=true" machine is required to deploy the marketplace-webportal service' + return True, None + + def run(self): + result = copy.deepcopy(self.service_conf) + machine_list = self.cluster_conf['machine-list'] + server_port = self.service_conf['server-port'] + api_port = self.service_conf['api-port'] + master_ip = [host['hostip'] for host in machine_list if host.get('pai-master') == 'true'][0] + result['uri'] = 'http://{0}:{1}'.format(master_ip, server_port) + if 'marketplace_api_uri' not in result: + result['marketplace_api_uri'] = 'http://{0}:{1}/api'.format(master_ip, api_port) + return result + + def validation_post(self, conf): + return True, None diff --git a/src/marketplace-webportal/deploy/delete.sh b/src/marketplace-webportal/deploy/delete.sh new file mode 100644 index 0000000000..5ceb907e38 --- /dev/null +++ b/src/marketplace-webportal/deploy/delete.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +pushd $(dirname "$0") > /dev/null + +/bin/bash stop.sh || exit $? + +popd > /dev/null diff --git a/src/marketplace-webportal/deploy/marketplace-webportal.yaml.template b/src/marketplace-webportal/deploy/marketplace-webportal.yaml.template new file mode 100644 index 0000000000..2f4876d7d4 --- /dev/null +++ b/src/marketplace-webportal/deploy/marketplace-webportal.yaml.template @@ -0,0 +1,29 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: marketplace-webportal-ds +spec: + selector: + matchLabels: + app: marketplace-webportal + template: + metadata: + name: marketplace-webportal + labels: + app: marketplace-webportal + spec: + hostNetwork: true + containers: + - name: marketplace-webportal + image: {{ cluster_cfg["cluster"]["docker-registry"]["prefix"] }}marketplace-webportal:{{ cluster_cfg["cluster"]["docker-registry"]["tag"] }} + imagePullPolicy: Always + env: + - name: MARKETPLACE_API_URL + value: {{ cluster_cfg["marketplace-webportal"]["marketplace_api_uri"] }} + - name: SERVER_PORT + value: "{{ cluster_cfg["marketplace-webportal"]["server-port"] }}" + imagePullSecrets: + - name: {{ cluster_cfg["cluster"]["docker-registry"]["secret-name"] }} diff --git a/src/marketplace-webportal/deploy/refresh.sh b/src/marketplace-webportal/deploy/refresh.sh new file mode 100644 index 0000000000..bd50ad3ded --- /dev/null +++ b/src/marketplace-webportal/deploy/refresh.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +pushd $(dirname "$0") > /dev/null + +bash stop.sh +bash start.sh + +popd > /dev/null diff --git a/src/marketplace-webportal/deploy/service.yaml b/src/marketplace-webportal/deploy/service.yaml new file mode 100644 index 0000000000..d4f9879c06 --- /dev/null +++ b/src/marketplace-webportal/deploy/service.yaml @@ -0,0 +1,20 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +cluster-type: + - k8s + +prerequisite: + - cluster-configuration + +template-list: + - marketplace-webportal.yaml + - start.sh + +start-script: start.sh +stop-script: stop.sh +delete-script: delete.sh +refresh-script: refresh.sh + +deploy-rules: + - in: pai-master diff --git a/src/marketplace-webportal/deploy/start.sh.template b/src/marketplace-webportal/deploy/start.sh.template new file mode 100644 index 0000000000..acd1954dc8 --- /dev/null +++ b/src/marketplace-webportal/deploy/start.sh.template @@ -0,0 +1,13 @@ +#!/bin/bash + +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +pushd $(dirname "$0") > /dev/null + +kubectl apply --overwrite=true -f marketplace-webportal.yaml || exit $? + +# Wait until the service is ready. +PYTHONPATH="../../../deployment" python -m k8sPaiLibrary.monitorTool.check_pod_ready_status -w -k app -v marketplace-webportal || exit $? + +popd > /dev/null diff --git a/src/marketplace-webportal/deploy/stop.sh b/src/marketplace-webportal/deploy/stop.sh new file mode 100644 index 0000000000..0eae959b5d --- /dev/null +++ b/src/marketplace-webportal/deploy/stop.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +kubectl delete --ignore-not-found --now "daemonset/marketplace-webportal-ds" diff --git a/src/pylon/deploy/pylon-config/location.conf.template b/src/pylon/deploy/pylon-config/location.conf.template index 19b144b0e9..a89e6d717e 100644 --- a/src/pylon/deploy/pylon-config/location.conf.template +++ b/src/pylon/deploy/pylon-config/location.conf.template @@ -143,6 +143,28 @@ location ~ ^/dshuttle/(.*)$ { } {%- endif %} +{%- if MARKETPLACE_API_URI %} +# marketplace rest server +location ~ ^/marketplace/api$ { + # Add '/' to the end of the URL, otherwise there will be a 404 error. + return 301 $scheme://$http_host$request_uri/; +} +location ~ ^/marketplace/api/(.*)$ { + proxy_pass {{MARKETPLACE_API_URI}}/$1$is_args$args; +} +{%- endif %} + +{%- if MARKETPLACE_WEBPORTAL_PLUGIN %} +# marketplace webportal plugin +location ~ ^/marketplace$ { + # Add '/' to the end of the URL, otherwise there will be a 404 error. + return 301 $scheme://$http_host$request_uri/; +} +location ~ ^/marketplace/(.*)$ { + proxy_pass {{MARKETPLACE_WEBPORTAL_PLUGIN}}/$1; +} +{%- endif %} + # PAI web portal location ~ ^(.*)$ { proxy_pass {{PAI_WEB_PORTAL_URI}}$1$is_args$args; @@ -186,6 +208,16 @@ location ~ ^(.*)$ { '{{DSHUTTLE_URI}}' '/dshuttle'; {%- endif %} +{%- if MARKETPLACE_API_URI %} + sub_filter + '{{MARKETPLACE_API_URI}}' + '/marketplace/api'; +{%- endif %} +{%- if MARKETPLACE_WEBPORTAL_PLUGIN %} + sub_filter + '{{MARKETPLACE_WEBPORTAL_PLUGIN}}' + '/marketplace'; +{%- endif %} proxy_set_header If-None-Match $request_if_none_match; add_header Etag $response_etag; diff --git a/src/pylon/deploy/pylon.yaml.template b/src/pylon/deploy/pylon.yaml.template index 65f14cd942..7f6e804d2d 100644 --- a/src/pylon/deploy/pylon.yaml.template +++ b/src/pylon/deploy/pylon.yaml.template @@ -82,6 +82,14 @@ spec: {% if cluster_cfg['cluster']['common']['dshuttle'] == 'true' %} - name: DSHUTTLE_URI value: {{ cluster_cfg['dshuttle']['uri'] }} +{% endif %} +{% if cluster_cfg['cluster']['common']['marketplace'] == 'true' %} + - name: MARKETPLACE_API_URI + value: {{ cluster_cfg['marketplace-restserver']['uri']}} +{% endif %} +{% if cluster_cfg['cluster']['common']['marketplace'] == 'true' %} + - name: MARKETPLACE_WEBPORTAL_PLUGIN + value: {{ cluster_cfg['marketplace-webportal']['uri']}} {% endif %} ports: - name: pylon