cdk8s-team / cdk8s-plus

A software development framework that provides high level abstractions for authoring Kubernetes applications.
https://cdk8s.io/docs/latest/plus/
Apache License 2.0
133 stars 33 forks source link

Setting defaults for container resource values #1988

Open TilBlechschmidt opened 1 year ago

TilBlechschmidt commented 1 year ago

Description of the feature or enhancement:

Being able to set the defaults for Container resource values.

Use Case:

As it stands, every container defaults to hardcoded 1 CPU & 512MB RAM. https://github.com/cdk8s-team/cdk8s-plus/blob/82b26cffb4370e54f87a112e4d0d74bace8a5ed0/src/container.ts#L729-L738 This might be fine in a cloud context or large scale cluster. However, in my case I am using cdk8s to generate manifests for a small home server. Most pods are just idle and don't need any CPU at all, however, each of them is allocated a comparatively large amount of resources. Thus I am unable to schedule additional pods after adding a certain number of containers.

It is possible to change each pod definition in my project as it stands. However, that would be dozens of redundant changes. It would be cool if cdk8s+ supports setting these defaults globally!

Proposed Solution:

Passing in a set of default resources as part of ChartProps or AppProps would be ideal as it keeps the changes scoped. I am not familiar with the code but since labels are already passed down the tree, it should probably be doable with minimal changes.


This is a :rocket: Feature Request

HamishWHC commented 8 months ago

Same scenario here - I'm running k3s on a 4 core CPU, I can't be promising an entire core to every single container! I don't think this would be a breaking change. I might take a crack at this myself. @TilBlechschmidt did you find a workaround in the meantime, or just added the lowered resource requests/limits to everywhere?

TilBlechschmidt commented 8 months ago

Hey @HamishWHC, I just added requests/limits everywhere (or rather abstracted most things and added it there). However, I’d still argue that a proper solution would be worthwhile. I just don’t have the time to commit to it atm.

Also, Merry Christmas! 🎄 If that’s smth you celebrate