Skip to content

Commit

Permalink
feat(workspace): conditionally create http route
Browse files Browse the repository at this point in the history
  • Loading branch information
joaoferrao committed Mar 29, 2024
1 parent b8fd59d commit ce3a14b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions mage_ai/api/resources/WorkspaceResource.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ def update(self, payload, **kwargs):
workspace.add_to_ingress(**args)
else:
raise Exception('This workspace does not support ingress.')
elif action == 'create_http_route':
if isinstance(workspace, KubernetesWorkspace):
workspace.create_http_route(**args)
else:
raise Exception('This workspace does not support gateway api and http routes.')
except Exception as ex:
error.update(message=str(ex))
raise ApiError(error)
Expand Down
10 changes: 10 additions & 0 deletions mage_ai/cluster_manager/workspace/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ def add_to_ingress(self, **kwargs):
self.name,
)

def create_http_route(self, **kwargs):
if self.config.gateway_name and self.config.gateway_namespace:
self.workload_manager.create_http_route(
self.config.gateway_name,
self.config.gateway_namespace,
self.config.hostname,
f'{self.name}-service',
self.name
)

def to_dict(self):
config = dict(
name=self.name,
Expand Down

0 comments on commit ce3a14b

Please sign in to comment.