Reputation: 11
I have an application A and application B
application B is not always needed and may be heavy to run. so we want to keep application B down usually
so is there a way to delay the deployment of application B wait until receiving request from application A to launch application B
I was initially looking at kubernetes job, but it seems to be always turned on and restarted after task completion. any idea?
Upvotes: 0
Views: 1106
Reputation: 8766
I used while ago knative, which is a serverless solution on Kubernetes. I didn't like it, honestly, that much becuase back then it was using too much resources. But that was knative 0.3, now 0.14 is available.
So, with knative you create a deployment, and that deployment can be scaled to 0, until a request is made to that backend (pod). When the request is made, it will scale to 1. If there are too many requests, naturally it will scale to even more. And if there are no requests, after certain time, it will scale back to 0. Seems to be what you are looking for.
Fritz's answer is correct. You can configure a pod to have enough privileges to create resources in the cluster, but personally I wouldn't do it. With knative, you just make an http request an it scales.
Upvotes: 2
Reputation: 11860
In practice, what you are suggesting is quite possible. You need to add sufficient RBAC rights to your Pod, e.g.
https://itnext.io/running-kubectl-commands-from-within-a-pod-b303e8176088
Then you have to use an API to send deployments to the API Server, e.g.:
https://github.com/kubernetes-client/java
Having said that, this is not simple to setup and it might be easier to just let this Application run in the background without requested resources.
Upvotes: 0