In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the knowledge of "how to adjust the CPU and memory of Kubernetes". In the operation of practical cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Allocating and managing CPU and memory resources in Kubernetes can be tricky, but it is also easy. In this article, I'll show you what Kubernetes resources and limitations are and how to manage them. The goal of this article is simple-how to help you quickly adjust the Kubernetes resource information in the project, mainly in three ways: 1, allocate CPU and memory resources for the container and Pod 2, Resources Quota: limit the resource consumption of namespace 3, Limit Ranges: configure the default CPU request and limit the allocation of CPU and memory resources for the container and Pod the following figure explains the unit of measurement of Kubernetes resources, resource status workflow and how to use resource restrictions.
CPU and memory unit
A cpu in Kubernetes equals: 1, 1 AWS vCPU2, 1 GCP Core3, 1 Azure vCore4, 1 Hyperthread on a bare metal Intel processor with hyperthreading, Deployment uses requests and restrictions on memory resources and CPU resources to allocate CPU and memory requests (request) and memory limits (limit) to a container. We guarantee that the container has the amount of memory it requests, but do not allow the use of more than the limit of CPU and memory. ApiVersion: apps/v1 kind: Deployment metadata: name: aks-application spec: replicas: 1 selector: matchLabels: app: aks-application template: metadata: labels: app: aks-application spec: containers: -name: aks-application image: hubname/aks-application-image:1.0.0 resources: requests: cpu: 100m memory: 128Mi limits: cpu: 250m memory: 256Mi more detailed information and code snippets: allocate memory resources to containers and Pod allocate CPU resources to containers and PodKubernetes best practices resources Best practices for summing restrictions on application developers managing resources in Azure Kubernetes Service (AKS) Resources Quota: limit the resource consumption resource quota for namespace It is defined by the ResourceQuota object, which provides a limit on the total amount of resource consumption per namespace. It can limit the total number of objects of a certain type in namespace or the total amount of computing resources that can be used by Pod in command space.
Resource quotas work as follows: 1. Different teams can work under different namespace, which is currently non-binding, and mandatory constraints may be achieved through ACL (Access Control List access Control list) in future versions. 2. Cluster administrators can create one or more ResourceQuota objects for each namespace. 3. When a user creates resources (such as Pod, Service, etc.) under namespace, Kubernetes's quota system tracks the resource usage of the cluster to ensure that the amount of resources used does not exceed the hard resource limit defined in ResourceQuota. 4. If a resource creation or update request violates a quota constraint, the request will report an error (HTTP 403 FORBIDDEN) and give a possible violation of the constraint in the message. 5. If quotas for computing resources (such as cpu and memory) under namespace are enabled, users must set request values (request) and constraint values (limit) for these resources, otherwise the quota system will reject the creation of Pod. Tip: you can use the LimitRanger admission controller to set default values for Pod that do not set computing resource requirements.
The following is the quota definition for persistent volume declarations and namespace resources. ApiVersion: v1 kind: ResourceQuota metadata: name: backend-storage-quota spec: hard: persistentvolumeclaims: "2" requests.storage: "1Gi"-- apiVersion: v1 kind: ResourceQuota metadata: name: backend-namespace-quota spec: Hard: request.cpu: 400m request.memory: 9600Mi limits.cpu: 1200m limits.memory: 11600Mi you can use this kubectl apply command to set the quota limit for namespace. For more information on how to use quotas for kubectl apply-f resource-quota.yaml-namespace backend, please refer to
Https://kubernetes.io/docs/concepts/policy/resource-quotas/Limit Ranges: configure default CPU requests and limits if your namespace has a resource quota, the default memory limit is helpful.
Adding LimitRange to namespace not only limits cpu and memory, but also forces the minimum and maximum values for the storage request size. The storage is requested through the PersistentVolumeClaim. The admission controller that performs restricted scope control rejects any PVC that is above or below the threshold set by the administrator. ApiVersion: v1 kind: LimitRange metadata: name: backend-limit-range spec: limits:-default: memory: 110Mi cpu: 500m defaultRequest: memory: 20Mi cpu: 100m type: Container-- apiVersion: v1 Kind: LimitRange metadata: name: backend-storage-limits spec: limits:-type: PersistentVolumeClaim max: storage: 5Gi min: storage: 2Gi more detailed information and code snippets. Configure default CPU requests for namespace and limit storage usage restrictions for namespaces Limit Range tools in Kubernetes: the CPU and memory Popeye that manage Kubernetes scan the cluster for problems related to configuration, resources, and network vulnerabilities and generate detailed reports on all issues. Goldilocks scans Pod for resource constraints and creates reports using recommended resources. Kube-advisor is a tool from the Azure team that scans for missing resources in the container and restricts requests. K9s+benchmark provides a command line interface (CLI) that allows you to easily manage, monitor and even benchmark clusters in your favorite terminal software. You can also use these tools in conjunction with Datadog, Grafana + Prometeus,Azure Monitor to improve resources and limit monitoring. Summary setup resource request: gets information about the CPU and memory usage of a particular application / container. Set resource limits: run load tests to detect CPU and memory of containers under high loads. Monitor the container's CPU and memory usage. Monitor persistent volume usage. Check if you can use Limit Range application resources to limit usage quotas (it is not recommended to apply quotas in a production environment)
This is the end of the content of "how to adjust Kubernetes's CPU and memory". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.