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

pid limiting documentation #23929

Merged
merged 1 commit into from
Oct 9, 2020

Conversation

SergeyKanzhelev
Copy link
Member

@SergeyKanzhelev SergeyKanzhelev commented Sep 16, 2020

Quickly combined info about pid limiting. It is a follow up from kubernetes/kubernetes#94140 (comment)

It also requires this PR #23883 as it adds the description of the feature flag that this PR refer to.

Related #23906 (issue can be closed once this branch is merged back to master)

/sig node
/assign @sftim
/assign @derekwaynecarr

@k8s-ci-robot k8s-ci-robot added sig/node Categorizes an issue or PR as relevant to SIG Node. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Sep 16, 2020
@k8sio-netlify-preview-bot
Copy link
Collaborator

k8sio-netlify-preview-bot commented Sep 16, 2020

Deploy preview for kubernetes-io-vnext-staging processing.

Building with commit 7b7ed6b

https://app.netlify.com/sites/kubernetes-io-vnext-staging/deploys/5f63963c9331a6000839477b

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 16, 2020
@k8s-ci-robot k8s-ci-robot added language/en Issues or PRs related to English language sig/docs Categorizes an issue or PR as relevant to SIG Docs. labels Sep 16, 2020
@sftim
Copy link
Contributor

sftim commented Sep 16, 2020

node-to-pod PID isolation

What does this mean? I think it's about imposing a resource limit on Pods, where the resource is the number of host system PIDs that the Pod can use.

PIDs are always isolated between Pods. I don't think it's possible for two Pods in the same namespace hierarchy (ie, both running on one Node with a Linux namespaces-and-cgroups container runtime) to have the same host system PID, that just doesn't make sense.

Copy link
Contributor

@sftim sftim left a comment

Choose a reason for hiding this comment

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

Hi @SergeyKanzhelev

Thanks for this PR - here are some suggestions on the wording.

content/en/docs/concepts/policy/pid-limiting.md Outdated Show resolved Hide resolved
content/en/docs/concepts/policy/pid-limiting.md Outdated Show resolved Hide resolved
content/en/docs/concepts/policy/pid-limiting.md Outdated Show resolved Hide resolved
content/en/docs/concepts/policy/pid-limiting.md Outdated Show resolved Hide resolved
content/en/docs/concepts/policy/pid-limiting.md Outdated Show resolved Hide resolved
- derekwaynecarr
title: PID Limiting
content_type: concept
weight: 10
Copy link
Contributor

Choose a reason for hiding this comment

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

I recommend setting a higher value, as there are other documents in the policy section that should come first.

Copy link
Member Author

Choose a reason for hiding this comment

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

I should have read contributing.md. Just copied from other file. Let me take a look

Copy link
Member Author

Choose a reason for hiding this comment

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

this is the doc I found: https://v1-16.docs.kubernetes.io/docs/contribute/style/content-organization/#page-order I updated weight for more articles. Was it the right decision? Or just assign 40 to the new page?

content/en/docs/concepts/policy/pid-limiting.md Outdated Show resolved Hide resolved
content/en/docs/concepts/policy/pid-limiting.md Outdated Show resolved Hide resolved
@SergeyKanzhelev
Copy link
Member Author

node-to-pod PID isolation

What does this mean? I think it's about imposing a resource limit on Pods, where the resource is the number of host system PIDs that the Pod can use.

PIDs are always isolated between Pods. I don't think it's possible for two Pods in the same namespace hierarchy (ie, both running on one Node with a Linux namespaces-and-cgroups container runtime) to have the same host system PID, that just doesn't make sense.

This is isolation form attack perspective. I agree it worth re-phrasing. Looking...

@SergeyKanzhelev
Copy link
Member Author

@sftim thank you very much for review and rewrites!

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 17, 2020
@SergeyKanzhelev
Copy link
Member Author

@tengqm thank you for pointing all uncertainties in a language. PTAL - I rephrased

Copy link
Contributor

@tengqm tengqm left a comment

Choose a reason for hiding this comment

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

LGTM other than some nits.

content/en/docs/concepts/policy/pid-limiting.md Outdated Show resolved Hide resolved
content/en/docs/concepts/policy/pid-limiting.md Outdated Show resolved Hide resolved
@tengqm
Copy link
Contributor

tengqm commented Sep 17, 2020

@annajung
Copy link
Contributor

@kubernetes/sig-node-pr-reviews Hello 👋, 1.20 docs lead here. Can we get a tech review?

Copy link
Contributor

@sftim sftim left a comment

Choose a reason for hiding this comment

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

A bit more feedback. IMO it'd be fine to merge without addressing that, we can pick those nits up later.

content/en/docs/concepts/policy/pid-limiting.md Outdated Show resolved Hide resolved
content/en/docs/concepts/policy/pid-limiting.md Outdated Show resolved Hide resolved
content/en/docs/concepts/policy/pid-limiting.md Outdated Show resolved Hide resolved
content/en/docs/concepts/policy/pid-limiting.md Outdated Show resolved Hide resolved

{{< feature-state for_k8s_version="v1.20" state="stable" >}}

Kubernetes allow you to limit the number of process IDs (PIDs) that a {{< glossary_tooltip term_id="Pod" text="Pod" >}} can use.
Copy link
Contributor

Choose a reason for hiding this comment

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

What do think about adding a heading for the content starting at line 13?
The first heading I see is Node PID limits.

Copy link
Member Author

Choose a reason for hiding this comment

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

I just followed the patter from other files. I think the title will become an H1

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks nice when rendered:

image


{{< note >}}
On certain Linux installations, the operating system sets the PIDs limit to a low default,
such as `32768`. Consider raising the value of `/proc/sys/kernel/pid_max`.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is referring to something like:
In order to use the pids controller, set the maximum number of tasks in pids.max (this is not available in the root cgroup for obvious reasons). The number of processes currently in the cgroup is given by pids.current. ?

Copy link
Contributor

@sftim sftim Sep 17, 2020

Choose a reason for hiding this comment

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

It's this tip:
https://www.cyberciti.biz/tips/howto-linux-increase-pid-limits.html

Nothing to do with Kubernetes per se, but relevant if like most people you're using Linux nodes.

Copy link
Member Author

Choose a reason for hiding this comment

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

is it something you want to add to the note? Or replace with?

You can configure a kubelet to limit the number of PIDs a given pod can consume.
For example, if your node's host OS is set to use a maximum of `262144` PIDs and
expect to host less than `250` pods, one can give each pod a budget of `1000`
PIDs to prevent using up that node's overall number of available PIDs. If the
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about this edit?
For example, if your node's host OS is set to use a maximum of 262144 PIDs and
you expect to host less than 250 pods, give each pod a budget of 1000
PIDs to prevent using up that node's overall number of available PIDs.

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 that is fine.

its an operator choice to choose to over-commit or under-commit pids.

the main goal with pid limiting per pod is to stop a simple fork-bomb as we don't require pods to requests pids as a resource in favor of letting an admin set a per pod max.

@SergeyKanzhelev
Copy link
Member Author

Should there be a note that on windows these flags has no effect? I'm not sure what's the best practice here

Copy link
Member

@derekwaynecarr derekwaynecarr left a comment

Choose a reason for hiding this comment

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

thanks for doing this follow-up @SergeyKanzhelev !

the doc looks great.

/lgtm

You can configure a kubelet to limit the number of PIDs a given pod can consume.
For example, if your node's host OS is set to use a maximum of `262144` PIDs and
expect to host less than `250` pods, one can give each pod a budget of `1000`
PIDs to prevent using up that node's overall number of available PIDs. If the
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 that is fine.

its an operator choice to choose to over-commit or under-commit pids.

the main goal with pid limiting per pod is to stop a simple fork-bomb as we don't require pods to requests pids as a resource in favor of letting an admin set a per pod max.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 17, 2020
@derekwaynecarr
Copy link
Member

@SergeyKanzhelev its hard to keep up with the delta among linux and windows nodes, but we could put a piece of text that says pid limiting only applies to kubelets running on linux hosts.

@tengqm
Copy link
Contributor

tengqm commented Sep 18, 2020

LGTM
Defer approval to @sftim to check if all the feedbacks addressed.

@sftim
Copy link
Contributor

sftim commented Sep 21, 2020

Relevant to #23906

@SergeyKanzhelev
Copy link
Member Author

Relevant to #23906

I think it is fixes the issue, correct? I can add to description for auto-closing the issue on PR merge

@sftim
Copy link
Contributor

sftim commented Sep 21, 2020

I think it is fixes the issue, correct? I can add to description for auto-closing the issue on PR merge

This PR targets the v1.20 release. I would hold off on closing #23906 given that the master branch (and live documentation) will not include documentation for this (existing) feature until the v1.20 release. Once this merges, though, we can drop the priority of #23906.

@sftim
Copy link
Contributor

sftim commented Sep 30, 2020

@annajung happy for this to land in dev-1.20?

@annajung
Copy link
Contributor

annajung commented Oct 1, 2020

Yes, that sounds good to me
/milestone 1.20

@k8s-ci-robot
Copy link
Contributor

@annajung: You must be a member of the kubernetes/website-milestone-maintainers GitHub team to set the milestone. If you believe you should be able to issue the /milestone command, please contact your Website milestone maintainers and have them propose you as an additional delegate for this responsibility.

In response to this:

Yes, that sounds good to me
/milestone 1.20

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.

@annajung
Copy link
Contributor

annajung commented Oct 1, 2020

/milestone 1.20

@k8s-ci-robot k8s-ci-robot added this to the 1.20 milestone Oct 1, 2020
@annajung
Copy link
Contributor

annajung commented Oct 2, 2020

/assign @annajung

@sftim
Copy link
Contributor

sftim commented Oct 7, 2020

Hi @SergeyKanzhelev

https://5f63963c9331a6000839477b--kubernetes-io-vnext-staging.netlify.app/docs/reference/command-line-tools-reference/feature-gates/ also needs updating, to mark the related feature gates as graduated.

If you change that, I think this will be good to go.
/lgtm cancel
(tech review stands)

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 7, 2020

{{< note >}}
Before Kubernetes version 1.20, PID resource limiting for Pods required enabling
the [feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it is opened by default since 1.14

SupportPodPidsLimit true Beta 1.14

@irvifa
Copy link
Member

irvifa commented Oct 9, 2020

Looks good to me, thanks!
/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 9, 2020
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 2fa56c7877086b8d0a56541e0b8ce078f9bab5ac

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: irvifa

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

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel 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 Oct 9, 2020
@k8s-ci-robot k8s-ci-robot merged commit 245f8b6 into kubernetes:dev-1.20 Oct 9, 2020
@sftim sftim mentioned this pull request Nov 19, 2020
@SergeyKanzhelev SergeyKanzhelev deleted the pidlimiting branch November 21, 2020 00:10
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. language/en Issues or PRs related to English language lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/docs Categorizes an issue or PR as relevant to SIG Docs. sig/node Categorizes an issue or PR as relevant to SIG Node. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants