forked from microsoft/AIOpsLab
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathastronomy_shop.py
More file actions
49 lines (39 loc) · 1.49 KB
/
astronomy_shop.py
File metadata and controls
49 lines (39 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""Interface to the OpenTelemetry Astronomy Shop application"""
import time
from aiopslab.service.helm import Helm
from aiopslab.service.kubectl import KubeCtl
from aiopslab.service.apps.base import Application
from aiopslab.paths import ASTRONOMY_SHOP_METADATA
class AstronomyShop(Application):
def __init__(self):
super().__init__(ASTRONOMY_SHOP_METADATA)
self.load_app_json()
self.kubectl = KubeCtl()
self.create_namespace()
def load_app_json(self):
super().load_app_json()
metadata = self.get_app_json()
self.frontend_service = "frontend-proxy"
self.frontend_port = 8080
def deploy(self):
"""Deploy the Helm configurations."""
self.kubectl.create_namespace_if_not_exist(self.namespace)
Helm.add_repo(
"open-telemetry",
"https://open-telemetry.github.io/opentelemetry-helm-charts",
)
Helm.install(**self.helm_configs)
Helm.assert_if_deployed(self.helm_configs["namespace"])
def delete(self):
"""Delete the Helm configurations."""
Helm.uninstall(**self.helm_configs)
self.kubectl.delete_namespace(self.helm_configs["namespace"])
time.sleep(30)
def cleanup(self):
Helm.uninstall(**self.helm_configs)
self.kubectl.delete_namespace(self.helm_configs["namespace"])
# Run this code to test installation/deletion
# if __name__ == "__main__":
# shop = AstronomyShop()
# shop.deploy()
# shop.delete()