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:
Refactored createPod to call a separate function createUserPod which handles the actual creation of a user's pod.
Also created deletePod function for use in WorkflowPodBrainResource.scala.
Created template function sendWorkflow for future implementation.
WorkflowPodBrainResource.scala:
Refactored to use new service function deletePod in terminatePod.
Modified listPods to only list active pods.
Modified terminatePod to only add a termination time to the corresponding terminated pod instead of deleting the row in the texera_db.pod table.
Created template function runWorkflow with endpoint /{uid}/run-workflow for future implementation
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:
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"
, wherehostname
is the name of the pod andsub-domain
is the name of the service (which is namedworkflow-pods
).Changes
KubernetesClientService.scala
:createPod
to call a separate functioncreateUserPod
which handles the actual creation of a user's pod.deletePod
function for use inWorkflowPodBrainResource.scala
.sendWorkflow
for future implementation.WorkflowPodBrainResource.scala
:deletePod
interminatePod
.listPods
to only list active pods.terminatePod
to only add a termination time to the corresponding terminated pod instead of deleting the row in thetexera_db.pod
table.runWorkflow
with endpoint/{uid}/run-workflow
for future implementationTesting
In order to run the hello world example, create a pod by sending an API request.
Then, interacting with the Kubernetes cluster with
kubectl
, create a temporary pod to send a request within the pod.Inside the temporary pod, run the command, assuming the given
uid
in the initial API request was set to 1:A JSON response should be printed in the console, looking like
{"id":1,"content":"Hello, Stranger!"}
.