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 > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the knowledge of "kubernetes's namespace container quota limit". Many people will encounter this dilemma in the operation of actual cases, 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!
Create a namespace:
Kubectl create namespace my-namespace
Resource limits that need to be configured:
Configure the container default memory limit
Configure container default CPU limits
Configure namespace container total memory and CPU limits
The xxx/default-resource-limit.yaml file is as follows:
# if you create a container in a namespace that has a default memory limit and the container does not specify its own memory limit Then the container will be assigned a default memory limit apiVersion: v1kind: LimitRangemetadata: name: default-mem-limitspec: limits: # default memory limit is 2G # if the container specifies resources.limit.memory but not resources.requests.memory # then both values are the specified value resources.limit.memory-default: memory: 2048Mi # default memory request is 512m # if the container specifies resources.requests. Memory without specifying resources.limit.memory # then resources.requests.memory follows the specified Resources.limit.memory uses the default defaultRequest: memory: 256Mi type: Container-# if a container is created in a namespace with default CPU restrictions, and the container does not specify its own CPU limit Then the container will be assigned a default CPU limit apiVersion: v1kind: LimitRangemetadata: name: default-cpu-limitspec: limits: # default container CPU limit is 2 # if the container specifies resources.limit.cpu but not resources.requests.cpu # then both values are the specified value resources.limit.cpu-default: cpu: 2 # default container CPU request is 0.5 # if the container specifies resources .requests.cpu without specifying resources.limit.cpu # then resources.requests.cpu follows the specified Resources.limit.cpu configures the total amount of memory and CPU that can be used by all containers running in the entire namespace by default defaultRequest: cpu: 0.5 type: Container-- # apiVersion: v1kind: ResourceQuotametadata: name: default-mem-cpu-total-limitspec: hard: requests.cpu: "8" requests.memory: 16Gi limits.cpu: "8" limits.memory: 16Gi
Apply restrictions to the my-namespace namespace with the following command:
Kubectl apply-f xxx/default-resource-limit.yaml-- namespace=my-namespace
View the created resource limit information:
Kubectl get resourcequota default-mem-cpu-total-limit-output=yaml-namespace=my-namespacekubectl get limitrange default-mem-limit-output=yaml-namespace=my-namespacekubectl get limitrange default-cpu-limit-output=yaml-namespace=my-namespace
Specify the container resource limit sample code when creating a Pod:
ApiVersion: v1kind: Podmetadata: name: resource-limit-pod-demospec: containers:-name: resource-limit-pod-demo image: nginx resources: # specify the upper limit of the Pod container memory and CPU limits: memory: "512Mi" cpu: "2" # specify the Pod container memory and CPU request size requests: memory: "256Mi" cpu: "1"
View Pod container resource information:
Kubectl get pod resource-limit-pod-demo-- output=yaml-- namespace=my-namespace "Namespace Container quota limits for kubernetes" ends here. 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.