当前位置:网站首页>How to set a pod to run on a specified node
How to set a pod to run on a specified node
2022-06-29 19:47:00 【Chenshaowen's website】
1. When creating a load , adopt nodeSelector Appoint Node
- Label nodes
| |
- Appoint nodeSelector Create a workload
| |
- View workload
| |
In line with expectations ,Pod Run on the specified node node2 On .
- Clean up the environment
| |
actually , There is another node selection parameter nodeName, Specify the node name directly . But this setting is too blunt , And beyond Kubernetes Its own scheduling mechanism , Very little is used in actual production .
2. Bind namespaces to nodes through admission control
Specify... When creating a load nodeSelector, You can set Pod Running nodes . But if you want to bind all under the namespace Pod Run under the specified node , It seems to be out of hand . While using kube-apiserver Access control can achieve this goal , This is a Kubernetes 1.5 Enter when alpha Characteristics of the stage .
2.1 modify kube-apiserver Parameters
edit kube-apiserver file :
| |
stay admission-plugins Newly added PodNodeSelector:
| |
there NodeRestriction Is turned on by default . If it is a highly available cluster , Then you need to modify each kube-apiserver. After the modification is completed , Just a moment kube-apiserver Will complete the restart process .
2.2 to Namespace adding annotations
Edit namespace , Add notes :
| |
| |
scheduler.alpha.kubernetes.io/node-selector It can be the node name , It can also be label Key value pair .
2.3 Add the specified for the node label
to node3 The node is marked with project=A The label of :
| |
Here the namespace default Load on , Bound to node node3 On .
2.4 Create a payload
- Create a load to test
| |
- View load distribution
| |
You can see , Although there are 4 Available nodes , however default The loads in the space are running in node3 Under node .
2.5 Clean up the environment
- clear label
| |
- Clean load
| |
- Clean up annotations
kubectl edit ns default It should be noted that , If the namespace is already open scheduler.alpha.kubernetes.io/node-selector, The node has no associated label , here ,Pod Will always be in Pending state , Unable to get scheduled , Until there is one that meets the label Node appear .
3. Use topology domain to group nodes
Here's the picture , adopt kube-apiserver Access control plug-ins for , We can build models , One namespace per project , Each namespace contains the specified node . This will satisfy , Business isolation 、 Requirements for cost accounting . But as the cluster gets bigger , The project needs to divide several availability zones under the cluster , It is used to ensure the availability of the business .

The topology domain is mainly used to solve Pod In the cluster distribution problem , Can be used to implement Pod The need for directional selection of nodes .Kubernetes The topology domain characteristics of the cluster scheduler are 1.16 Get into Alpha Stage , stay 1.18 Get into Beta Stage . Let's do some experiments :
- Divide nodes into different topological domains
Here, the nodes node2 into zone a, take node3、node4 into zone b.
| |
| |
- Create a payload
| |
here topologyKey Used to specify the partition of the topology domain Key,maxSkew It means that zone=a、zone=b in Pod The quantity difference cannot exceed 1, whenUnsatisfiable: DoNotSchedule It means that the condition is not satisfied , No scheduling .
- see Pod Distribution
| |
Among them in node2 node 10 individual Pod、node3 node 7 Nodes 、node4 node 3 Nodes . You can see ,Pod Evenly distributed in zone=a、zone=b On .
- Clean up the environment
| |
4. summary
As clusters get bigger , Isolation between businesses 、 Problems such as the monopolization of business to nodes will emerge . Usually , Each business has a separate namespace , therefore , We can bind namespaces to nodes .
This paper mainly gives two methods , One is when creating a load , Set up directly nodeSelector, The trick is to use the namespace value as value; Another way is , With the help of kube-apiserver Provided access control plug-ins , By way of annotation , When creating a payload under a namespace , Specify nodes by label filtering , Complete the binding between namespace and node .
Think about it further , If the number of nodes is very large , It is necessary to divide the available zones to distribute the load , Then we can use the topological domain to realize . Through the topology domain , We can make the load , It is evenly distributed in the specified availability zone according to the configured policy 、 On the cabinet .
5. Reference resources
边栏推荐
- Luoqingqi: has high-end household appliances become a red sea? Casati took the lead in breaking the game
- Canonical engineers are trying to solve the performance problem of Firefox snap
- IP error problem of PHP laravel using AWS load balancer
- 剑指 Offer 41. 数据流中的中位数
- idea中方法上没有小绿色三角
- [USB flash disk test] in order to transfer the data at the bottom of the pressure box, I bought a 2T USB flash disk, and the test result is only 47g~
- Win11 system component cannot be opened? Win11 system widget cannot be opened solution
- 【精品】pinia详解
- 有了这4个安全测试工具,对软件安全测试say so easy!
- The era of data security solutions
猜你喜欢

Koa 源码剖析

【摸鱼神器】UI库秒变低代码工具——表单篇(一)设计

做白银k线图有多重要?

ETCD数据库源码分析——服务端PUT流程

Performance improvement at the cost of other components is not good
![[observation] softcom power liutianwen: embrace change and](/img/d8/a367c26b51d9dbaf53bf4fe2a13917.png)
[observation] softcom power liutianwen: embrace change and "follow the trend" to become an "enabler" of China's digital economy

Physical verification LVS process and Technology (Part I)

How important is it to make a silver K-line chart?

Classic illustration of K-line diagram (Collection Edition)

Where is the win11 installation permission set? Win11 installation permission setting method
随机推荐
凌云出海记 | 文华在线&华为云:打造非洲智慧教学新方案
Game Maker 基金会呈献:归属之谷
Canonical的工程师们正努力解决Firefox Snap的性能问题
Common knowledge of ECS security settings
CorelDRAW最新24.1.0.360版本更新介绍讲解
[observation] softcom power liutianwen: embrace change and "follow the trend" to become an "enabler" of China's digital economy
QC protocol + Huawei fcp+ Samsung AFC fast charging 5v9v chip fs2601 application
Static static member variables use @value injection
Go: how to write a correct UDP server
关于印发宝安区重点产业项目和总部项目遴选及用地保障实施细则(2022修订版)的通知
【剑指Offer】51. 数组中的逆序对
NLP - GIZA++ 实现词对齐
WPS和Excele
有了这4个安全测试工具,对软件安全测试say so easy!
数据安全解决方案的大时代
ASP.Net Core创建Razor页面上传多个文件(缓冲方式)(续)
AI scene Storage Optimization: yunzhisheng supercomputing platform storage practice based on juicefs
nacos 问题
Exploration and practice of NLP problem modeling scheme
童年经典蓝精灵之百变蓝爸爸数字藏品中奖名单公布