当前位置:网站首页>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
边栏推荐
- Classic illustration of K-line diagram (Collection Edition)
- [proteus simulation] matrix keyboard interrupt scanning
- 【Proteus仿真】矩阵键盘中断扫描
- static静态成员变量使用@Value注入方式
- 数据安全解决方案的大时代
- 数据链路层
- Koa 源码剖析
- Freemaker template framework generates images
- QC protocol + Huawei fcp+ Samsung AFC fast charging 5v9v chip fs2601 application
- 2022年深圳市福田区支持先进制造业发展若干措施
猜你喜欢

@Sneakythlows annotation
![[boutique] detailed explanation of Pinia](/img/94/d332e32dba54be3c2d3f6ff08a85fa.png)
[boutique] detailed explanation of Pinia

JVM (4) bytecode technology + runtime optimization

QC protocol + Huawei fcp+ Samsung AFC fast charging 5v9v chip fs2601 application

物理验证LVS流程和技术点滴(上)

4-2 port banner information acquisition
![[network orientation training] - Enterprise Park Network Design - [had done]](/img/12/17f95378fcc6d0fef15feb99cc4f49.png)
[network orientation training] - Enterprise Park Network Design - [had done]

4-2端口Banner信息获取

Common knowledge of ECS security settings

【精品】pinia详解
随机推荐
How to install and use computer SSD hard disk
JVM (2) garbage collection
云服务器的安全设置常识
【摸鱼神器】UI库秒变低代码工具——表单篇(一)设计
[boutique] detailed explanation of Pinia
jfinal中如何使用过滤器监控Druid监听SQL执行?
How to solve the problem of insufficient memory space in Apple iPhone upgrade system?
一小时构建示例场景 声网发布灵隼物联网云平台
With these four security testing tools, software security testing can be said so easy!
There are more than 20 databases in a MySQL with 3306 ports. How can I backup more than 20 databases with one click and do system backup to prevent data from being deleted by mistake?
As the "only" privacy computing provider, insight technology is the "first" to settle in the Yangtze River Delta data element circulation service platform
lock4j--分布式锁中间件--自定义获取锁失败的逻辑
Regular expression series of mobile phone numbers
【软件测试】01 -- 软件生命周期、软件开发模型
3-2主机发现-三层发现
ASP. Net core creates razor page and uploads multiple files (buffer mode) (Continued)
Nacos problem
k线图经典图解(收藏版)
Koa 源码剖析
docker compose 部署Flask项目并构建redis服务