cdk8s-team / cdk8s

Define Kubernetes native apps and abstractions using object-oriented programming
https://cdk8s.io
Apache License 2.0
4.29k stars 290 forks source link

Resource Unit Should Not Be Converted #1166

Open akefirad opened 1 year ago

akefirad commented 1 year ago

Description of the bug:

Using Size.gibibytes(2) generates 2048Mi instead of 2Gi. This is a bit of a problem in GitOps setup (since it shows there's a diff). Essentially I guess ideally there should be no conversions of such kind at all, if possible.

Reproduction Steps:

My code is like this:

    const deployment = new Deployment(this, "deployment", {
      replicas: props.replicas,
    });

    deployment.addContainer({
      image: props.image,
      portNumber: props.port,
      resources: {
        memory: {
          request: Size.gibibytes(1),
          limit: Size.gibibytes(2),
        },
      },
    });

(Let me know if the above code doesn't work for you. Happy to provide a sample project.)

Error Log:

And the output contains:

apiVersion: apps/v1
kind: Deployment
#... other stuff
          resources:
            limits:
              memory: 2048Mi
            requests:
              memory: 1024Mi
# ... other stuff

Environment:

Other:


This is :bug: Bug Report

joonvena commented 1 year ago

If you use the cdk8s instead of cdk8s-plus you can use eg. Quantity.fromString('512Mi') in resources definitions. You might already know this but wanted to point out as way around 🙂