kubeless icon indicating copy to clipboard operation
kubeless copied to clipboard

Pod initialization fails due to unavailable resources spec

Open gkarthiks opened this issue 5 years ago • 7 comments

Is this a BUG REPORT or FEATURE REQUEST?: Kind of both. What happened: I have "quota restriction" in my namespace and I deployed a kubeless function using the --cpu and --memory flag. But the resources spec are not getting passed to initContainers ie., prepare and install but only to the main container. Because of that the pods are not getting created.

What you expected to happen: Either of the below:

  • A possible way to send the resource (request and limits) to the initContainer
  • Worst case, apply the same resources to initContainers as well passed via --cpu and --memory flags

How to reproduce it (as minimally and precisely as possible):

  • Deploy a ResourceQuota to a namespace with both requests and limits set as hard.
  • Deploy a function to that namespace using kubeless function deploy command with --cpu and --memory flag.

Environment:

  • Kubernetes version (use kubectl version): 1.9
  • Kubeless version (use kubeless version): 0.5
  • Cloud provider or physical cluster: OpenShift 3.9

gkarthiks avatar Nov 16 '18 21:11 gkarthiks

Hi @gkarthiks,

I agree that would be convenient to use at least the same values for the initContainers than the ones set for the runtime container. That have the disadvantage that the initContainers are more likely to have a spike in the resources consumption if it requires to compile code. Can you try to manually edit a function deployment and set the same limits than the runtime container for the init containers? Just to check if that works in your case.

andresmgot avatar Nov 19 '18 08:11 andresmgot

@andresmgot if you mean after kubeless function deploy, yes. That's how I am doing as of now. Patching the function deployment for the initContainers's resource deploys the pod and works as expected. IMHO, that shouldn't be the way.

gkarthiks avatar Nov 19 '18 15:11 gkarthiks

Agree, we should fix that using the function spec. Thanks for confirming.

andresmgot avatar Nov 20 '18 08:11 andresmgot

Hi @andresmgot I also tried with cronjob trigger for the function, it seems that the resources spec are not getting passed to the job as well, and the trigger- pod can't be created. Is it possible to apply the same function resources specs to the cronjob?

hwa123 avatar Nov 21 '18 14:11 hwa123

hi @hwa123,

that would be quite a different issue. The cronjob will spin up a pod that does a single curl command to the function service so we can just hardcode some low requirements. Maybe you want to give it a try? The code is here:

https://github.com/kubeless/cronjob-trigger/blob/master/pkg/utils/kubelessutil.go#L34

I don't have time right now to work on this but I will be happy to help with any contribution.

andresmgot avatar Nov 21 '18 14:11 andresmgot

FYI, you have to add resources to the Deployment in three places, for each init container (by hand while the feature is in the works)

create a patch

kubectl edit deployment my-function --output-patch=true

copy the JSON output (not the Patch: part) into a patch.json, pretty the json with jq or equivalent

apply a patch

kubectl patch deployment my-function -p "$(cat patch.json)"

You can then just apply the patch on each deploy / update, as well as edit the patch itself and apply to change resource requirements. I found the Golang compile step needed more memory than I expected.

verdverm avatar Nov 21 '18 20:11 verdverm

Any move on original issue?

abinet avatar Aug 15 '19 09:08 abinet