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

Set pids limit at pod level #57973

Merged
merged 2 commits into from
Jan 26, 2018

Conversation

dims
Copy link
Member

@dims dims commented Jan 8, 2018

What this PR does / why we need it:

Add a new Alpha Feature to set a maximum number of pids per Pod.
This is to allow the use case where cluster administrators wish
to limit the pids consumed per pod (example when running a CI system).

By default, we do not set any maximum limit, If an administrator wants
to enable this, they should enable SupportPodPidsLimit=true in the
--feature-gates= parameter to kubelet and specify the limit using the
--pod-max-pids parameter.

The limit set is the total count of all processes running in all
containers in the pod.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #43783

Special notes for your reviewer:

Release note:

New alpha feature to limit the number of processes running in a pod. Cluster administrators will be able to place limits by using the new kubelet command line parameter --pod-max-pids. Note that since this is a alpha feature they will need to enable the "SupportPodPidsLimit" feature.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 8, 2018
@dims
Copy link
Member Author

dims commented Jan 8, 2018

/assign @tallclair
/assign @thockin
/assign @dchen1107

cc @BenTheElder

@dims
Copy link
Member Author

dims commented Jan 8, 2018

/test pull-kubernetes-unit

@dims
Copy link
Member Author

dims commented Jan 8, 2018

/test pull-kubernetes-cross

Copy link
Member

@tallclair tallclair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks much cleaner.

@@ -214,6 +214,12 @@ const (
//
// Implement IPVS-based in-cluster service load balancing
SupportIPVSProxyMode utilfeature.Feature = "SupportIPVSProxyMode"

// owner: @dims
// beta: v1.10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alpha

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duh, cut-n-paste error :) fixing

@@ -197,6 +197,8 @@ type KubeletConfiguration struct {
// The CIDR to use for pod IP addresses, only used in standalone mode.
// In cluster mode, this is obtained from the master.
PodCIDR string `json:"podCIDR"`
// PodPidsLimit is the maximum number of pids in any pod.
PodPidsLimit int64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be a pointer, and also it needs a json tag.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -463,6 +470,10 @@ func (m *cgroupManagerImpl) Create(cgroupConfig *CgroupConfig) error {
Resources: resources,
}

if cgroupConfig.ResourceParameters.PodPidsLimit != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should check the featuregate here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -430,6 +433,10 @@ func (m *cgroupManagerImpl) Update(cgroupConfig *CgroupConfig) error {
Paths: cgroupPaths,
}

if cgroupConfig.ResourceParameters.PodPidsLimit != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the feature gate here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@dims dims force-pushed the set-pids-limit-at-pod-level branch 4 times, most recently from 7655504 to b266fdc Compare January 8, 2018 21:40
@dims
Copy link
Member Author

dims commented Jan 9, 2018

/assign @brendandburns

@k8s-ci-robot
Copy link
Contributor

@dims: GitHub didn't allow me to assign the following users: brendanburns.

Note that only kubernetes members can be assigned.

In response to this:

/assign @brendanburns

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.

@derekwaynecarr
Copy link
Member

/cc @sjenning

I did a quick pass and this looks generally good. Will take a deeper look shortly.

@k8s-ci-robot k8s-ci-robot requested a review from sjenning January 9, 2018 13:55
@dchen1107
Copy link
Member

Looks good to me, thanks.

cc/ @mtaufen

@yujuhong yujuhong self-assigned this Jan 9, 2018
@yujuhong
Copy link
Contributor

yujuhong commented Jan 9, 2018

Would like to take a look of this later.

@dims
Copy link
Member Author

dims commented Jan 11, 2018

@yujuhong @mtaufen @sjenning can you please take a look when you get a chance?

cc @kubernetes/sig-node-pr-reviews

@k8s-ci-robot k8s-ci-robot added the sig/node Categorizes an issue or PR as relevant to SIG Node. label Jan 11, 2018
@@ -453,6 +453,8 @@ func AddKubeletConfigFlags(fs *pflag.FlagSet, c *kubeletconfig.KubeletConfigurat
fs.Int32Var(&c.MaxPods, "max-pods", c.MaxPods, "Number of Pods that can run on this Kubelet.")

fs.StringVar(&c.PodCIDR, "pod-cidr", c.PodCIDR, "The CIDR to use for pod IP addresses, only used in standalone mode. In cluster mode, this is obtained from the master.")
fs.Int64Var(c.PodPidsLimit, "pod-max-pids", *c.PodPidsLimit, "<Warning: Alpha feature> Tune a pod's pids limit. Set -1 for unlimited.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit reword: "Set the maximum number of processes per pod"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@sjenning
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 11, 2018
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 22, 2018
@dims
Copy link
Member Author

dims commented Jan 22, 2018

@derekwaynecarr - yep will file one today (at least a WIP). Thanks!

@dims
Copy link
Member Author

dims commented Jan 23, 2018

@derekwaynecarr please see kubernetes/enhancements#546

@brendandburns @dchen1107 @lavalamp @smarterclayton @thockin - Need your approval per list in pkg/OWNERS. PTAL

@dims
Copy link
Member Author

dims commented Jan 23, 2018

/test all

@BenTheElder
Copy link
Member

BenTheElder commented Jan 23, 2018 via email

@dims
Copy link
Member Author

dims commented Jan 24, 2018

/test pull-kubernetes-e2e-kubeadm-gce-canary

@dims
Copy link
Member Author

dims commented Jan 24, 2018

Please ignore "pull-kubernetes-e2e-kubeadm-gce-canary" failure. It's not a required job and there's a race between the build artifacts and when the job starts actually. So totally unrelated.

/test all

@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Jan 24, 2018

@dims: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-kubernetes-e2e-kubeadm-gce-canary 3df1ce5 link /test pull-kubernetes-e2e-kubeadm-gce-canary

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

@dims
Copy link
Member Author

dims commented Jan 25, 2018

@brendandburns @dchen1107 @lavalamp @smarterclayton @thockin - can one of you please approve for "pkg/" thanks!

Please ignore the gce-canary failure, it's not a required test and failing for an unrelated known reason (job depends on output of bazel-build and there's a problem with the stored artifact url)

@smarterclayton
Copy link
Contributor

/approve

Given other feedback and sig consensus, no voiced concerns, benefit for real users with the possibility of a more comprehensive user facing solution later on.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: derekwaynecarr, dims, sjenning, smarterclayton

Associated issue: #43783

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 26, 2018
@dims
Copy link
Member Author

dims commented Jan 26, 2018

thanks @smarterclayton

@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 57973, 57990). If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit bf11116 into kubernetes:master Jan 26, 2018
youkoulayley pushed a commit to youkoulayley/acs-engine that referenced this pull request Apr 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/node Categorizes an issue or PR as relevant to SIG Node. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow setting pids-limit on containers