0
I have a flask application - A1 - running in a Kubernetes cluster. This application is responsible for receiving HTTP requests and starting another application - A2 - that is also run in this cluster. Note: A2 runs on a fixed port, say 5050. For example:
Suppose the flask application receives a message that should be displayed on the terminal.
{
"message": "Hello World!"
}
From that received json, I need:
- transfer this json to the A2 application
- await the reply of A2.
- return the response of running A2 through A1.
However, I need this second application to be created and destroyed for each HTTP request made. I need to create this A2 pod with different settings, depending on which json the A1 application receives. For example:
- A1 receives:
{
"message":"Hello World!",
"resources":{
"requests":{
"memory":"64Mi",
"cpu":"250m"
},
"limits":{
"memory":"128Mi",
"cpu":"500m"
}
}
}
- A1 starts an A2 pod with the resource settings present in JSON.
- A1 expects A2 to finish.
- A2 pod is destroyed.
- A1 returns a response with the result of running A2.
How do I make the A2 application to be created and destroyed as explained above?
Possible problem: A2 performs on a fixed port, and as it will be created and destroyed on demand, it means that there can only be one pod running at a time on a cluster machine, right?