Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
[Marketplace] Simplify marketplace setting (#5283)
Browse files Browse the repository at this point in the history
* add prerequisite in marketplace-webportal and marketplace-restserver, auto use config from their prerequisite services

* Fix template

* Fix template

* Fix template

* auto use https in marketplace if pylon.ssl

* auto use https in marketplace if pylon.ssl

* Add deploy marketplace to quickstart

* fix template

* Add config to enable/disable the auto-added marketplace-plugin

* Set marketplace: false in quick-start default services-configuration

* Add enable_marketplace option to config.yaml
  • Loading branch information
yiyione authored Feb 5, 2021
1 parent 82193d4 commit b8fa587
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 19 deletions.
1 change: 1 addition & 0 deletions contrib/kubespray/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ docker_image_tag: v1.5.0
# OpenPAI Customized Settings #
#######################################################################
# enable_hived_scheduler: true
# enable_marketplace: false

#############################################
# Ansible-playbooks' inventory hosts' vars. #
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ cluster:
data-path: "/datastorage"
qos-switch: "{{ env["cfg"]["qos-switch"] | default('false') }}"
docker-data-root: "{{ env['cfg']['docker_data_root'] | default('/mnt/docker') }}"
marketplace: "{{ env["cfg"]["enable_marketplace"] | default('false') }}"

# the docker registry to store docker images that contain system services like frameworklauncher, hadoop, etc.
docker-registry:
Expand Down Expand Up @@ -205,15 +206,15 @@ authentication:
# alertname: PAIJobGpuPercentLowerThan0_3For1h
# customized-receivers: # receivers are combination of several actions
# - name: "pai-email-admin-user-and-stop-job"
# actions:
# actions:
# # the email template for `email-admin` and `email-user `can be chosen from ['general-template', 'kill-low-efficiency-job-alert']
# # if no template specified, 'general-template' will be used.
# email-admin:
# email-user:
# email-user:
# template: 'kill-low-efficiency-job-alert'
# stop-jobs: # no parameters required for stop-jobs action
# tag-jobs:
# tags:
# tags:
# - 'stopped-by-alert-manager'

# uncomment following if you want to customize prometheus
Expand Down
7 changes: 4 additions & 3 deletions deployment/quick-start/services-configuration.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ cluster:
# cluster-type: k8s
# # HDFS, zookeeper data path on your cluster machine.
# data-path: "/datastorage"
# marketplace: "true"

# the docker registry to store docker images that contain system services like frameworklauncher, hadoop, etc.
docker-registry:
Expand Down Expand Up @@ -90,15 +91,15 @@ rest-server:
# alertname: PAIJobGpuPercentLowerThan0_3For1h
# customized-receivers: # receivers are combination of several actions
# - name: "pai-email-admin-user-and-stop-job"
# actions:
# actions:
# # the email template for `email-admin` and `email-user `can be chosen from ['general-template', 'kill-low-efficiency-job-alert']
# # if no template specified, 'general-template' will be used.
# email-admin:
# email-user:
# email-user:
# template: 'kill-low-efficiency-job-alert'
# stop-jobs: # no parameters required for stop-jobs action
# tag-jobs:
# tags:
# tags:
# - 'stopped-by-alert-manager'

# uncomment following if you want to customize prometheus
Expand Down
11 changes: 5 additions & 6 deletions src/marketplace-restserver/config/marketplace-restserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@

service_type: "k8s"

db_user: user
db_password: passwd
db: marketplace
# db_user: user
# db_password: passwd
# db: marketplace
# db_host: postgres
db_port: 9291
# db_port: 9291
server-port: 9292

azure_storage:
type: blob
storage_account: openpaimarketplace
connection_strings:
- '<connection_string>'
connection_strings: []
azure_storage_json: ''
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,32 @@ spec:
image: {{ cluster_cfg["cluster"]["docker-registry"]["prefix"] }}marketplace-restserver:{{ cluster_cfg["cluster"]["docker-registry"]["tag"] }}
imagePullPolicy: Always
env:
- name: DB_HOST
value: {{ cluster_cfg["marketplace-restserver"]["db_host"] }}
- name: DB_USERNAME
{% if 'db_user' in cluster_cfg["marketplace-restserver"] %}
value: {{ cluster_cfg["marketplace-restserver"]["db_user"] }}
{% else %}
value: {{ cluster_cfg["marketplace-db"]["user"] }}
{% endif %}
- name: DB_PASSWORD
{% if 'db_password' in cluster_cfg["marketplace-restserver"] %}
value: {{ cluster_cfg["marketplace-restserver"]["db_password"] }}
{% else %}
value: {{ cluster_cfg["marketplace-db"]["passwd"] }}
{% endif %}
- name: DATABASE
{% if 'db' in cluster_cfg["marketplace-restserver"] %}
value: {{ cluster_cfg["marketplace-restserver"]["db"] }}
- name: DB_HOST
value: {{ cluster_cfg["marketplace-restserver"]["db_host"] }}
{% else %}
value: {{ cluster_cfg["marketplace-db"]["db"] }}
{% endif %}
- name: DB_PORT
value: "{{ cluster_cfg["marketplace-restserver"]["db_port"] }}"
{% if 'db_port' in cluster_cfg["marketplace-restserver"] %}
value: '{{ cluster_cfg["marketplace-restserver"]["db_port"] }}'
{% else %}
value: '{{ cluster_cfg["marketplace-db"]["port"] }}'
{% endif %}
- name: NODE_ENV
value: production
- name: PORT
Expand Down
1 change: 1 addition & 0 deletions src/marketplace-restserver/deploy/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ cluster-type:

prerequisite:
- cluster-configuration
- marketplace-db

template-list:
- marketplace-restserver.yaml
Expand Down
2 changes: 0 additions & 2 deletions src/marketplace-webportal/config/marketplace_webportal.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ def run(self):
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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@ spec:
imagePullPolicy: Always
env:
- name: MARKETPLACE_API_URL
{%- if 'marketplace_api_uri' in cluster_cfg['marketplace-webportal'] %}
value: {{ cluster_cfg["marketplace-webportal"]["marketplace_api_uri"] }}
{%- else %}
{% if "ssl" in cluster_cfg["pylon"] and cluster_cfg["pylon"]["ssl"] %}
value: "{{ cluster_cfg['pylon']['uri-https']}}/marketplace/api"
{% else %}
value: "{{ cluster_cfg['pylon']['uri']}}/marketplace/api"
{% endif %}
{%- endif %}
- name: SERVER_PORT
value: "{{ cluster_cfg["marketplace-webportal"]["server-port"] }}"
- name: NPM_INSTALL_TOKEN
Expand Down
1 change: 1 addition & 0 deletions src/marketplace-webportal/deploy/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ cluster-type:

prerequisite:
- cluster-configuration
- marketplace-restserver

template-list:
- marketplace-webportal.yaml
Expand Down
2 changes: 1 addition & 1 deletion src/webportal/config/webportal.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def apply_config(plugin):
return {
'server-port': server_port,
'uri': uri,
'plugins': json.dumps([apply_config(plugin) for plugin in plugins]),
'plugins': [apply_config(plugin) for plugin in plugins],
'webportal-address': master_ip,
'enable-job-transfer': self.service_configuration['enable-job-transfer'],
}
Expand Down
3 changes: 3 additions & 0 deletions src/webportal/config/webportal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ service_type: "common"
server-port: 9286

enable-job-transfer: false

# Will add the marketplace entries to webportal plugin if set true.
marketplace: true
19 changes: 18 additions & 1 deletion src/webportal/deploy/webportal.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,24 @@ spec:
- name: WEBPORTAL_PLUGINS
# A raw JSON formatted value is required here.
value: |
{{ cluster_cfg['webportal']['plugins'] }}
[
{% if cluster_cfg['cluster']['common']['marketplace'] == "true" and cluster_cfg['webportal']['marketplace'] == "true" %}
{
"id": "marketplace",
"title": "Marketplace",
{% if "ssl" in cluster_cfg["pylon"] and cluster_cfg["pylon"]["ssl"] %}
"uri": "{{ cluster_cfg['pylon']['uri-https']}}/marketplace/plugin.js"
{% else %}
"uri": "{{ cluster_cfg['pylon']['uri']}}/marketplace/plugin.js"
{% endif %}
},
{% endif %}
{% if cluster_cfg['webportal']['plugins']|length > 0 %}
{% for item in cluster_cfg['webportal']['plugins'] %}
{{item}},
{% endfor %}
{% endif %}
]
ports:
- name: webportal
containerPort: 8080
Expand Down

0 comments on commit b8fa587

Please sign in to comment.