-
Notifications
You must be signed in to change notification settings - Fork 1
/
preflight.py
43 lines (38 loc) · 1.03 KB
/
preflight.py
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
import logging
from handlers.kube_handler import KubernetesHandler
gateway = {
"apiVersion": "networking.istio.io/v1alpha3",
"kind": "Gateway",
"metadata": {
"name": "microservice-gateway",
"namespace": "istio-system",
},
"spec": {
"selector": {
"istio": "ingressgateway",
},
"servers": [
{
"port": {
"number": 80,
"name": "http",
"protocol": "HTTP",
},
"hosts": ["*"],
}
],
},
}
def run():
try:
kubernetes_handler = KubernetesHandler()
if not kubernetes_handler.get_gateway_by_name(
"microservice-gateway", "istio-system"
):
kubernetes_handler.create_gateway(gateway)
logging.info("Gateway created.")
else:
logging.info("Gateway already exists.")
except Exception as e:
logging.error(f"Error creating gateway: {e}")
raise e