In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
The resource restriction of Kubernetes is actually controlled by cgroup. Cgroup is a collection of related attributes used by the container to control how the kernel runs the process. There is a corresponding cgroup for memory and CPU devices.
By default, Pod runs without CPU and memory restrictions, which means that any pod in the system will be able to consume enough CPU and memory like the node where the pod is executed, and will generally impose resource restrictions on the Pod resources of some applications, which are achieved through resources's limits.
Note: the following is only a fragment of resource restrictions in the yaml file, not a complete yaml file!
1) Resource limits for pod [root@master limit] # vim cgroup-pod.yaml spec: containers:-name: xxx image: xxx ports:-protocol: TCP containerPort: 80 resources: limits: # hard limit cpu: "4" memory: 2Gi requests: # number of resources requested when running pod cpu: 260m memory: 260Mi
Requests: the resource to be allocated. Limits is the highest requested resource value. It can be simply understood as the initial value and the maximum value.
2) Namespace-based resource limit (you can specify a specific namespace limit) 1) Compute resource quota [root@master limit] # vim compute-resource.yaml apiVersion: v1kind: ResourceQuotametadata: name: compute-resourcesspec: hard: pods: "20" # all pod cannot exceed 20 requests.cpu: "20" # the CPU of the initial request cannot exceed 20 20m requests.memory: 100Gi # initial requested memory cannot exceed 100g limits.cpu: "40" # CPU hard limit limits.memory: 200Gi # memory hard limit 2) Resource object quota limit [root@master limit] # vim object-counts.yaml apiVersion: v1kind: ResourceQuotametadata: name: object-countsspec: hard: configmaps: "10" # can be created at most Create 10 configmap persistentvolumeclaims: "4" # can create up to 4 PVC replicationcontrollers: "20" # can create up to 20 RC resource objects secrets: "10" # can create up to 10 secrets service.loadbalancers: "2" # can create up to 2 svc3) configure CPU and memory limitRange [root@master limit] # Vim limitRange.yaml apiVersion: v1kind: LimitRangemetadata: name: mem-limit-rangespec: limits:-default: memory: 50Gi # hard limit cpu: 5 # hard limit defaultRequest: # initial request memory: 1Gi cpu: 1 type: Container # restrict objects to containers
Default is the value of limit, and defaultRequest is the value of request.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.