Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set resources (requests and limits) for containers #307

Closed
Alon-Katz opened this issue Feb 7, 2022 · 3 comments
Closed

Set resources (requests and limits) for containers #307

Alon-Katz opened this issue Feb 7, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@Alon-Katz
Copy link

Hi, cdk8s+ is a great library but its missing a basic but a very important feature of setting the resources of the container.

I could not find any reference for it in the documentation, but I did find the option Escape Hatches. This worked great for me when adding nodeSelector, but it does not seem to work with the resources key.

This is the code I tried:

        deployment = Deployment(....)
        kube_deployment = ApiObject.of(deployment)
        kube_deployment.add_json_patch(
            JsonPatch.add("/spec/template/spec/containers/0/resources", {
                "requests": {"cpu": "100m", "memory": "0.2Gi"},
                "limits": {"cpu": "200m", "memory": "0.5Gi"},
            })
        )

When I look at the output json, it does seem to add the resources key and even the limits and requests, but no matter what I tried it keeps adding them with an empty dict inside. This is what is added to the json:
'resources': {'limits': {}, 'requests': {}}

Is there a way to make this work?
Thanks!

@Chriscbr
Copy link
Contributor

Chriscbr commented Feb 7, 2022

Not sure but I think the issue might be related to this bug: cdk8s-team/cdk8s#2172

@Chriscbr Chriscbr added the bug Something isn't working label Feb 7, 2022
@Alon-Katz
Copy link
Author

Looks like it is related, hopefully your idea of how to fix it will soon be applied :)

@iliapolo
Copy link
Member

iliapolo commented Jun 8, 2022

@iliapolo iliapolo closed this as completed Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants