This repository has been archived by the owner on Jun 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 549
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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
- Loading branch information
Showing
29 changed files
with
457 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
|
||
FROM docker.io/postgres:12.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"] }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
4 changes: 4 additions & 0 deletions
4
src/marketplace-restserver/build/marketplace-restserver.k8s.dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
|
||
FROM docker.io/openpai/pai-marketplace-restserver:v1.2.0 |
11 changes: 11 additions & 0 deletions
11
src/marketplace-restserver/config/marketplace-restserver.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
28 changes: 28 additions & 0 deletions
28
src/marketplace-restserver/config/marketplace_restserver.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
39 changes: 39 additions & 0 deletions
39
src/marketplace-restserver/deploy/marketplace-restserver.yaml.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"] }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
4 changes: 4 additions & 0 deletions
4
src/marketplace-webportal/build/marketplace-webportal.k8s.dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
|
||
FROM docker.io/openpai/pai-marketplace-webportal:v1.2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
29 changes: 29 additions & 0 deletions
29
src/marketplace-webportal/deploy/marketplace-webportal.yaml.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"] }} |
Oops, something went wrong.