0

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?

BMW
  • 42,880
  • 12
  • 99
  • 116
Mike_H
  • 11
  • Job seems like a valid option here. Can you add the job yaml you used to your question? – Matt May 20 '20 at 08:57

2 Answers2

2

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.

suren
  • 7,817
  • 1
  • 30
  • 51
0

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.

Fritz Duchardt
  • 11,026
  • 4
  • 41
  • 60
  • yea, I would try this if I cannot find other choice. thanks – Mike_H May 20 '20 at 18:42
  • @Mike_H Since I thought the problem rather interesting, I create a GitHub project that allows for deploying to k8s controlled by a simple Rest service: https://github.com/fritzduchardt/k8scrud – Fritz Duchardt Jun 13 '20 at 14:02
  • wow, that looks quite nice. my final resolution was also using rest api. many thanks for this great repo – Mike_H Jun 15 '20 at 13:10