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

Add new built-in transformer for resource-quotas (requests/limits) #5173

Closed
2 tasks done
evemorgen opened this issue May 16, 2023 · 4 comments
Closed
2 tasks done

Add new built-in transformer for resource-quotas (requests/limits) #5173

evemorgen opened this issue May 16, 2023 · 4 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. triage/under-consideration

Comments

@evemorgen
Copy link

evemorgen commented May 16, 2023

Eschewed features

  • This issue is not requesting templating, unstuctured edits, build-time side-effects from args or env vars, or any other eschewed feature.

What would you like to have added?

To improve the management of pod resource quotas, I propose adding a new built-in transformer to the Kustomize tool. This transformer will simplify the process of setting resource requests and limits for pods within Kubernetes manifests.

Currently, Kustomize supports a multitude of built-in transformers for common use cases including ReplicaCountTransformer, ImageTagTransformer, etc. Another common use case we often run into is overriding pod resource quotas (requests/limits) - currently done with patching - however, it would be much nicer and make manifests more readable to use a built-in transformer for that.

An example implementation could be:

kustomization.yaml

...
resourceQuotas:
  - name: some-deployment
     requests:
         memory: 1250Mi
         cpu: 100m
     limits:
         memory: 3000Mi
         cpu: 500m 

Why is this needed?

It would provide a more user-friendly simplified syntax to achieve the common task of setting appropriate resource quotas for pods.

By implementing this transformer, Kustomize users will benefit from a more convenient and streamlined approach to managing pod resource quotas. It will simplify the process of setting requests and limits, especially when dealing with a large number of pods or multiple environments.

Can you accomplish the motivating task without this feature, and if so, how?

This can be currently done with both inline patch and patch strategic merge.

An example would be:

kustomization.yaml

...
patchesStrategicMerge:
- patch.yaml

patch.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: some-deployment
spec:
  template:
    spec:
      containers:
        - name: some-deployment
          resources:
            limits:
              memory: 1250Mi
            requests:
              memory: 1250Mi

What other solutions have you considered?

I briefly research if it could be done with existing tools but couldn't find an elegant solution.

Anything else we should know?

No response

Feature ownership

  • I am interested in contributing this feature myself! 🎉

Thank you for considering this enhancement proposal. I look forward to hearing your thoughts and collaborating on this feature addition.

@evemorgen evemorgen added the kind/feature Categorizes issue or PR as related to a new feature. label May 16, 2023
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label May 16, 2023
@seh
Copy link
Contributor

seh commented May 16, 2023

The "replicas" field is already hard to use for anything but the simplest kustomizations. The new field proposed here would pose the same problem: To which manifests does this patch apply? Once you learn the answer, you then start asking how to exclude some manifests from its too-broad coverage.

@natasha41575
Copy link
Contributor

For use cases such as this, I would highly recommend you first experiment by writing your own custom transformer. If we see broad adoption of particular custom transformers, we can consider making them builtin.

I'd like to be careful about broadening the scope of builtin transformers and instead prioritize making it easy for users to write their own custom ones. This will help keep kustomize flexible, powerful, and maintainable.

@natasha41575 natasha41575 added triage/under-consideration and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jun 2, 2023
@evemorgen
Copy link
Author

Thanks @natasha41575, that makes a lot of sense. I'll try this approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. triage/under-consideration
Projects
None yet
Development

No branches or pull requests

4 participants