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

Limit iops per container #70980

Closed

Conversation

Avanpourm
Copy link

What type of PR is this?
/kind feature

What this PR does / why we need it:
I need to limit the read and write iops of rootfs
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 #70364

Special notes for your reviewer:
Thankyou !!!

Does this PR introduce a user-facing change?:

Use the annotation of kubernetes to pass the parameters of the cgroup to control the container blkio
Specifying the device path as "rootfs" indicates that you specify limiting rootfs
For example:
io.kubernetes.container.blkio: '{"weight":200,"weight_device":[{"device":"rootfs","value":"200k"}],"device_read_bps":[{"device":"/dev/sda1","value":"20m"}],"device_write_bps":[{"device":"rootfs","value":"20m"}],"device_read_iops":[{"device":"rootfs","value":"200"}]"device_write_iops":[{"device":"rootfs","value":"300"}]}'

Parameter

parameter type default value means parameter range example corresponds to Cgoup
weight Uint16 0 Weight value for all devices 10-1000 1
weight_device Array nil Weight value for all devices -
weight_device.[*].device String The absolute path of the device /dev/sda1
weight_device.[*].value String Weight value of the device 10-1000
device_read_bps Array nil A device reads the maximum number of bytes per second
device_read_bps.[*].device String The absolute path of the device. You can use "rootfs" for the specified root directory
device_read_bps.[*].value String Value ,like: 1[ K M G ]. Limit the minimum to prevent the process from entering a D state >1k 1M
device_write_bps Array nil Maximum number of bytes per second allowed to write to the device
device_write_bps.[*].device String The absolute path of the device. You can use "rootfs" for the specified root directory
device_write_bps.[*].value String Value ,like: 1[ K M G ]. Limit the minimum to prevent the process from entering a D state >1k
device_read_iops Array nil Max IOPS
device_read_iops.[*].device String The absolute path of the device. You can use "rootfs" for the specified root directory
device_read_iops.[*].value String Value ,like: 1[ K M G ]. Limit the minimum to prevent the process from entering a D state >5
device_write_iops Array nil Max IOPS
device_write_iops.[*].device String The absolute path of the device. You can use "rootfs" for the specified root directory
device_write_iops.[*].value String Value ,like: 1[ K M G ]. Limit the minimum to prevent the process from entering a D state >5

Deployment Example

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: iops-app
  name: iops-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: iops-app
  template:
    metadata:
      labels:
        app: iops-app
      annotations:
        io.kubernetes.container.blkio: '{"weight":200,"weight_device":[{"device":"rootfs","value":"200k"}],"device_read_bps":[{"device":"/dev/sad1","value":"20m"}],"device_write_bps":[{"device":"rootfs","value":"20m"}],"device_read_iops":[{"device":"rootfs","value":"200"}],"device_write_iops":[{"device":"rootfs","value":"300"}]}'
    spec:
      nodeSelector:
        kubernetes.io/hostname: szdc-k8sm-2-2.meitu-inc.com
      containers:
      - image: docker.io/centos:7
        command: ["/bin/sh","-c"]
        args: ["while(true);do /bin/sleep 10;done"]
        name: iops-app
        resources:
          requests:
            memory: "200Mi"
            cpu: 1
          limits:
            memory: "200Mi"
            cpu: 1
        volumeMounts:
        - name: host-time
          mountPath: /etc/localtime
      volumes:
      - name: host-time
        hostPath:
          path: /etc/localtime

@k8s-ci-robot k8s-ci-robot added do-not-merge/cherry-pick-not-approved Indicates that a PR is not yet approved to merge into a release branch. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Nov 13, 2018
@k8s-ci-robot
Copy link
Contributor

@Avanpourm: This PR is not for the master branch but does not have the cherry-pick-approved label. Adding the do-not-merge/cherry-pick-not-approved label.

To approve the cherry-pick, please assign the patch release manager for the release branch by writing /assign @username in a comment when ready.

The list of patch release managers for each release can be found here.

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.

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Nov 13, 2018
@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


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.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Nov 13, 2018
@k8s-ci-robot
Copy link
Contributor

Hi @Avanpourm. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 13, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Avanpourm
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: derekwaynecarr

If they are not already assigned, you can assign the PR to them by writing /assign @derekwaynecarr in a comment when ready.

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 area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Nov 13, 2018
We hope that kubernetes support limiting blkio resources.We use the annotation of kubernetes to pass
the parameters of the cgroup to control the container blkio. The current features apply only to the
Linux devmapper environment.In my production environment, multi-tenancy shares a storage device, we
must isolate the io of each tenant to ensure that the tenants do not interfere with each other. CRI
does not provide an interface for IO resource isolation.
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Nov 13, 2018
@Avanpourm
Copy link
Author

/assign @derekwaynecarr

@k8s-ci-robot
Copy link
Contributor

@Avanpourm: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test all

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.

@lovejoy
Copy link
Contributor

lovejoy commented Dec 11, 2018

@Avanpourm Would you please request this pr to master branch ?

@Avanpourm
Copy link
Author

Avanpourm commented Dec 12, 2018 via email

@feiskyer
Copy link
Member

feiskyer commented Jan 4, 2019

@Avanpourm Thanks for contributing. For new features, please send PRs to master branch instead.

@feiskyer
Copy link
Member

Please create a new PR targeted at master branch. stable branches are only for bug fixes, not for new features.

/close

@k8s-ci-robot
Copy link
Contributor

@feiskyer: Closed this PR.

In response to this:

Please create a new PR targeted at master branch. stable branches are only for bug fixes, not for new features.

/close

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.

@cuericlee
Copy link
Contributor

@Avanpourm did you get chance to request to merge this PR to master branch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/cherry-pick-not-approved Indicates that a PR is not yet approved to merge into a release branch. kind/feature Categorizes issue or PR as related to a new feature. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. 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/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants