In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is to share with you about how to use Kubernetes resource quotas. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
When the Kubernetes cluster has been running for a period of time or is heavily used by developers, problems with the control of Kubernetes resources (such as CPU and memory) will emerge. In most cases, we will not realize the importance of resource control until something goes wrong with the cluster.
Resource class problems are common if future scalability is not fully taken into account in the Kubernetes deployment process, which is related to the experience of cluster management and deployment teams.
If not properly controlled, a violent application or developer may affect all the businesses that share the cluster, so people will blame each other, blame each other, and seize resources protectively. This is a very difficult scenario for both cluster managers and developers.
There are many ways to control the use of computing resources for applications in a Kubernetes environment. In most cases, we can use "resource control" and "limits". Note that storage management is not within the scope of our discussion. Storage management can achieve different storage control requirements by persisting volume Persistent Volume parts.
Resource quotas are a way to control Kubernetes computing resources. This article shows you how to use this feature to manage developer behavior and control the application's resource usage.
What is resource quota?
In short, resource quotas provide constraints that limit resource consumption per namespace, which can only be applied at the namespace level, which means they can be applied to compute resources and limit the number of objects within the namespace.
Kubernetes resource quotas set resource quotas for each namespace through ResourceQuota objects, limiting CPU and memory for the following object types:
Pod Pod
Service Service
Confidential information Secret
Persistent volume assertion Persistent Volume Claim (PVC)
Configure Mapping ConfigMap
Kubernetes limits CPU and memory through two parameters, request and limit (see the LimitRange documentation). The former represents the minimum guaranteed resources of the container, while the latter represents the maximum available resources of the container. In fact, the maximum available resources are also limited by the actual use of other containers.
The next picture explains the difference between request and limit in quotas:
Requests and limits in Kubernetes resource quotas below we use an example to illustrate how to set resource quotas to create constraints, limit applications to certain resources, and demonstrate the usefulness of implementing resource quotas to gain control over Kubernetes.
Prepare the environment
First, you need a Kubernetes environment. The following is my use of the Kubernetes environment:
Minikube v1.14.2
Fedora 33 operating system
Internet access
If you want to build a Kubernetes test environment through Minikube on a Linux machine, you can refer to Bryant Son's article "getting started with Minikube". Window or macOS users can refer to this article.
Set resource quota
Here we only show the CPU quota setting steps, configuring memory quotas or a combination of both.
In the production environment, CPU is the resource that needs to be controlled most, especially in multi-application scenarios, we need to pay special attention to prevent some applications from consuming too much CPU and affecting other applications.
First, let's create a namespace in which to set the CPU quota:
$kubectl create namespace quota-test namespace/quota-test created
Prepare the cpu-quota.yaml file as follows:
ApiVersion: v1 kind: ResourceQuota metadata: name: test-cpu-quota spec: hard: requests.cpu: "100m" limits.cpu: "200m"
Apply CPU quotas to the Kubernetes cluster:
$kubectl apply-f cpu-qouta.yaml resourcequota/test-cpu-quota created
Use kubectl describe to check the quota configuration:
$kubectl describe resourcequota/test-cpu-quota-- namespace quota-test Name: test-cpu-quota Namespace: quota-test Resource Used Hard-limits.cpu 0 200m requests.cpu 0 100m
The current situation is shown in the Used resources column, which varies with the deployment of the pod Pod.
The following is a scenario where we validate quota management. We will deploy three different pods under the same namespace and configure them with different resource restrictions as follows:
PodA: the first one is instantiated, using 50% available CPU resources
PodB: the second is instantiated, using the remaining 50% available CPU resources
PodC: there are no CPU resources available, so they will not be deployed
Deploy the pod
PodA:
$kubectl create-n quota-test-f-
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.