Texera / texera

Collaborative Machine-Learning-Centric Data Analytics Using Workflows
https://texera.github.io
Apache License 2.0
160 stars 68 forks source link

Workflow Pods Headless Service Implementation #2764

Closed zhaoKelvin closed 1 month ago

zhaoKelvin commented 1 month ago

Purpose of PR

This PR implements a different architecture, transitioning from deployment-created pods to directly creating pods through the Kubernetes API. These changes give us a finer level of control over the lifecycle of pods while also reducing the cost of overhead.

In addition, we have implemented a working hello world example through the use of a headless service, of which every user pod is attached to and subsequently given a simple url which we can send requests through. This url is in the format: "<hostname>.<sub-domain>.<namespace>.svc.cluster.local", where hostname is the name of the pod and sub-domain is the name of the service (which is named workflow-pods).

Changes

KubernetesClientService.scala:

WorkflowPodBrainResource.scala:

Testing

In order to run the hello world example, create a pod by sending an API request.

http://localhost:8888/workflowpod/create

Then, interacting with the Kubernetes cluster with kubectl, create a temporary pod to send a request within the pod.

kubectl run -i --tty --rm curlpod --image=curlimages/curl --restart=Never -- sh

Inside the temporary pod, run the command, assuming the given uid in the initial API request was set to 1:

curl http://user-pod-1.workflow-pods.default.svc.cluster.local:8080/hello-world

A JSON response should be printed in the console, looking like {"id":1,"content":"Hello, Stranger!"}.