-
-
Notifications
You must be signed in to change notification settings - Fork 364
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
Allow setting resources for kubernetes on a per-step basis #1767
Conversation
Deployment of preview was successful: https://woodpecker-ci-woodpecker-pr-1767.surge.sh |
Codecov ReportPatch coverage has no change and project coverage change:
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. Additional details and impacted files@@ Coverage Diff @@
## master #1767 +/- ##
==========================================
- Coverage 39.01% 38.94% -0.08%
==========================================
Files 166 166
Lines 10343 10349 +6
==========================================
- Hits 4035 4030 -5
- Misses 6045 6055 +10
- Partials 263 264 +1
☔ View full report in Codecov by Sentry. |
In general a really nice, clean and thoughtful PR. Thanks for that. |
Ah great! I was just playing around with this a few days ago without success... Would it be hard to add a global resource definition? Which is overwritten by definitions in individual steps? |
It certainly sounds like a good idea, how does a top-level ---
backend_options:
kubernetes:
resources:
request:
cpu: 1000m
memory: 1024Mi
pipeline:
my-step:
image: golang
backend_options:
kubernetes:
resources:
request:
cpu: 2000m # Requests 2000m CPU
# Requests 1024 Mi memory |
I would not add a top level definition feature as you can do that already with: https://woodpecker-ci.org/docs/next/usage/advanced-yaml-syntax#map-merges-and-overwrites if it's an agent config that do overwrite step config ... if step.limit>agent.limit that's of course another request and valid |
Are you sure this is possible? To my knowledge this is not parsed to |
f48c685
to
f5e3a09
Compare
That's what I get for working with tools that scaffold YAML for me all day, I completely blanked on the native features. 😞
I thought about adding this, but kubernetes already has native tools for setting default/limit ranges (although only on a per-namespace basis): https://kubernetes.io/docs/concepts/policy/limit-range/
I tested it and it should work, e.g. variables:
- &resources
requests:
memory: "4Gi"
cpu: "250m"
limits:
memory: "8Gi"
cpu: "1000m"
pipeline:
build:
image: golang
backend_options:
kubernetes:
# Gets 4Gi & 250m requests, 2000m limits
resources:
<<: *resources
limits:
cpu: "2000m" |
But does it work without explicit mapping? I.e. usually I would like to write it as follows variables:
- &resources
requests:
memory: "4Gi"
cpu: "250m"
limits:
memory: "8Gi"
cpu: "1000m"
pipeline:
build:
image: golang and this should result in the step honoring the top-level resources unless they are explicitly set/overwritten in the respective step. Imagine a pipeline with many steps: it should be possible that each step follows a global resource definition without a redundant resources mapping within each step. @6543 Given that other top-level arguments like |
82d9861
to
b56c2a1
Compare
I understand the desire for the feature, but can you explain the use case which requires it to be part of the woodpecker code? Specifically, I'm trying to avoid re-implementing LimitRanges, which are very powerful and native to kubernetes, but do require application at the namespace level. |
@smuth4, yeah, you're right. Cool feature. |
b56c2a1
to
359068d
Compare
well it does exist but I consider this an legacy and we do move to labels ... witch can filter backend, platform, ... so there might come the time where it will be deprecated in favour of a simpler and more generic solution but that's something for the #567 to talk about :D |
This add a simple implementation of requests/limits for individual steps. There is no validation of what the resource actually is beyond checking that it can successfully be converted to a Quantity, so it can be used for things other than just memory/CPU.
close #1809