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
[Marketplace] Deploy scripts and config #5066
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
8c4a1de
update
yiyione b839446
update
yiyione 23f71de
update
yiyione cc5e3cb
update
yiyione 53f8ad0
add marketplace-db
yiyione 7ac951b
update
yiyione e0b523a
update
yiyione 2057812
fix
yiyione 12f769e
fix
yiyione cfc17f7
add marketplace-restserver
yiyione c9ad18d
update
yiyione f6b50c0
update
yiyione eae904d
fix
yiyione 8bc05a7
update pylon
yiyione 5b360af
update
yiyione 983ea52
update
yiyione fcb9faf
update
yiyione 15b1756
update
yiyione 1895c39
update
yiyione ac4e9a8
update
yiyione File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how to change the version tag