Created
July 28, 2023 19:25
-
-
Save neil-hickey/3f507707e2fee8abd068eefc94e59c8f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: meow | |
namespace: default | |
spec: | |
template: | |
spec: | |
containers: | |
- image: nginx | |
name: nginx | |
resources: | |
requests: | |
memory: "100Mi" | |
cpu: "100m" | |
limits: | |
memory: "200Mi" | |
cpu: "200m" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: woof | |
namespace: default | |
spec: | |
template: | |
spec: | |
containers: | |
- image: nginx | |
name: nginx | |
resources: | |
requests: | |
memory: "400Mi" | |
cpu: "400m" | |
limits: | |
memory: "800Mi" | |
cpu: "800m" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#@ load("@ytt:data", "data") | |
#@ load("@ytt:overlay", "overlay") | |
#! Reconfigures memory/cpu for requests and limits based on user's input | |
#@ def reconfigure_resource(old, new): | |
#@ if new == "": | |
#@ return old | |
#@ else: | |
#@ return new | |
#@ end | |
#@ end | |
#@ if data.values.resource_management: | |
#@ for r in range(len(data.values.resource_management)): | |
#@overlay/match by=overlay.subset({"kind": "Deployment", "metadata": {"name": data.values.resource_management[r].name, "namespace": "default"}}) | |
--- | |
spec: | |
template: | |
spec: | |
containers: | |
#@overlay/match by=overlay.all, expects="1+" | |
#@overlay/match-child-defaults missing_ok=True | |
- | |
resources: | |
requests: | |
#@overlay/replace via=lambda old, new: new or old | |
memory: #@ data.values.resource_management[r].requests.memory | |
#@overlay/replace via=lambda old, new: new or old | |
cpu: #@ data.values.resource_management[r].requests.cpu | |
limits: | |
#@overlay/replace via=lambda old, new: new or old | |
memory: #@ data.values.resource_management[r].limits.memory | |
#@overlay/replace via=lambda old, new: new or old | |
cpu: #@ data.values.resource_management[r].limits.cpu | |
#@ end | |
#@ end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#@data/values-schema | |
--- | |
#@schema/nullable | |
resource_management: | |
- | |
#@schema/validation one_of=["meow", "woof", "quack"] | |
name: "" | |
#@schema/nullable | |
requests: | |
#@schema/nullable | |
memory: "" | |
#@schema/nullable | |
cpu: "" | |
#@schema/nullable | |
limits: | |
#@schema/nullable | |
memory: "" | |
#@schema/nullable | |
cpu: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#@data/values | |
--- | |
resource_management: | |
- name: "meow" | |
requests: | |
memory: "111Mi" | |
cpu: "111m" | |
limits: | |
memory: "222Mi" | |
- name: "woof" | |
requests: | |
memory: "555Mi" | |
limits: | |
memory: "5555Mi" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment