-
Notifications
You must be signed in to change notification settings - Fork 39k
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 'kubectl set resources' #27206
Add 'kubectl set resources' #27206
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
@JacobTanenbaum I'll take a look at this next week. It won't get merged until after 1.3 freeze is over. |
@kubernetes/kubectl |
I like the feature. How about 'kubectl set resources' instead? /cc @vishh On Saturday, June 11, 2016, Michail Kargakis notifications@github.com
|
Yeah, to avoid having to have two commands (one for limits, one for resources).
|
allErrs := []error{} | ||
patches := CalculatePatches(o.Infos, o.Encoder, func(info *resource.Info) (bool, error) { | ||
transformed := false | ||
_, err := o.UpdatePodSpecForObject(info.Object, func(spec *api.PodSpec) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other things may have resources besides pods (quota and limits). We should make an argument for or against whether this command should be polymorphic to type. The container selector is probably the main issue - we'd need a different selector for sub quota info.
333194d
to
2efc82e
Compare
CLAs look good, thanks! |
Does everyone like 'kubectl set resources'? |
continue | ||
} | ||
|
||
//no changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smarterclayton I believe that I put the continue where you meant. If I understand correctly an empty patch is not an error so I added a note to stderr when a patch is empty that the resource was not changed
I prefer |
cea9096
to
9691082
Compare
9691082
to
f11796b
Compare
@@ -2211,6 +2242,7 @@ __EOF__ | |||
kubectl delete deployment nginx-deployment "${kube_flags[@]}" | |||
|
|||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why add whitespace?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whitespace removed
@@ -4,3 +4,6 @@ | |||
|
|||
|
|||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/pkg/cloudprovider/providers/openstack/MAINTAINERS.md?pixel)]() | |||
|
|||
|
|||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/_tmp/pkg/cloudprovider/providers/openstack/MAINTAINERS.md?pixel)]() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bug of some sort... should not be here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed entry
f11796b
to
abd67fa
Compare
abd67fa
to
d8c4a5c
Compare
The unit/integration test failure can be reliably recreated doing Apparently:
is the failing line. Before this PR the command returned an error. After the PR the command does not return an error. |
The command should fail and output_message should include instead it is passing and output_message is getting |
d8c4a5c
to
ee27d2c
Compare
7123dfa
to
43e6e16
Compare
Add a way to set resource limits/requests on running pods Ref: kubernetes#21648 I squashed the commits to make rebasing easier Change log: - fixed a typo that caused the command to be run with kubectl set set instead of the correct kubectl set limit - added a ResourcesWithPodTemplates to pkg/kubectl/cmd/util/factory.go instead of hardcoding these resources move there description all in one place - Fixing some of the flow control in kubectl set limit - update the help info - changed the name of ResourcesWithPodTemplates to ResourcesWithPodSpecs to more accuratly describe what it is doing and changed the variable names to lower case to conform to go's variable naming convention - changing the name of the command from 'set limit' to 'set resources' - Adding the new file pkg/kubectl/cmd/set/set_resources.go - changes to the test cases to reflect the change from 'kubectl set limit' to 'kubectl set resources' - comment removed - adding the man page to the git repository attempting to fix Jenkins tests - adding the user guide - fixed a few typos - typo in hack/cmd-test.sh - implamenting suggestions for command help text - adding the dry-run flag - removing the "remove" option in favor of zeroing out request/limits in order to remove them - changed limits/requests to requests/limit - changing ResourcesWithPodSpec - updated generated docs and removed whitespace - change priint on success message from "resource limits/requests updated" to "resource requirements updated" - minor rebasing issues - 'hack/test-cmd.sh' now passes - cmdutil.PrintSuccess added another argument - fixing mungedocs failure - removed whitespace from hack/make-rules/test-cmd.sh and an erroneous entry from pkg/cloudprovider/providers/openstack/MAINTAINERS.md - fixed typo in Short: field of the cobra command - rebased - Creating a new factory in the ResourcesWithPodSpecs() so that the testing will pass - changing ResourcesWithPodSpecs, it doesn't need to be a method of factory
43e6e16
to
901bbee
Compare
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
Jenkins GKE smoke e2e failed for commit 901bbee. Full PR test history. The magic incantation to run this job again is |
Automatic merge from submit-queue |
Add "kubectl set resources" for easier updating container memory/cpu limits/requests (for pods or resources with pod templates).
Usage
kubectl set resources (-f FILENAME | TYPE NAME) ([--limits=LIMITS & --requests=REQUESTS])
Examples
Set a deployments nginx container cpu limits to "200m and memory to "512Mi"
kubectl set resources deployment nginx -c=nginx --limits=cpu=200m,memory=512Mi
Set the limit and requests for all containers in nginx
kubectl set resources deployment nginx --limits=cpu=200m,memory=512Mi --requests=cpu=100m,memory=256Mi
Print the result (in yaml format) of updating nginx container limits from a local, without hitting the server
kubectl set resources -f path/to/file.yaml --limits=cpu=200m,memory=512Mi --local -o yaml
Remove limits on containers in nginx
kubectl set resources deployment nginx --limits=cpu=0,memory=0
Ref: #21648
EDIT: removed the '--remove' flag example
This change is![Reviewable](https://camo.githubusercontent.com/2d899f4291d07d3cd2fa4aaae1e3b243f164c23fce87d30a589ace0d496a444c/68747470733a2f2f72657669657761626c652e6b756265726e657465732e696f2f7265766965775f627574746f6e2e737667)