In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces how to dispatch Pod in Kubernetes to the designated Node, the content is very detailed, interested friends can refer to, hope to be helpful to you.
Problem description
Kubernetes has its own specific scheduling algorithm and strategy, and it is implemented by Scheduler components in Master. Automatically scheduling the creation of Pod according to the usage of Node resources can usually meet most of our needs. But sometimes we want to be able to schedule some Pod to specific hardware nodes, and here we use the simplest nodeName and nodeSelector to implement Pod scheduling.
assumes the following scenario: there are three Node, 107,108,109, create a Deployments to deploy the Tomcat application, and specify that the Pod is created on the 107node.
Solution
nodeName
Pod.spec.nodeName dispatches the Pod directly to the specified Node node, skipping the scheduling policy of Scheduler, which is a mandatory match.
Tomcatl.yaml file
ApiVersion: extensions/v1beta1
Kind: Deployment
Metadata:
Name: myweb
Spec:
Replicas: 2
Template:
Metadata:
Labels:
App: myweb
Spec:
NodeSelector: 107# dispatching to the specified node directly through the node name
Containers:
-name: myweb
Image: harbor/tomcat:8.5-jre8
Ports:
-containerPort: 80
nodeSelector
Pod.spec.nodeSelector selects nodes through kubernetes's label-selector mechanism, and the scheduler scheduling policy matches label, and then dispatches Pod to the target node. The matching rule is a mandatory constraint.
Set up Node Lable
Kubectl label nodes 107 type=backEndNode1
one
Tomcatl.yaml file
ApiVersion: extensions/v1beta1
Kind: Deployment
Metadata:
Name: myweb
Spec:
Replicas: 2
Template:
Metadata:
Labels:
App: myweb
Spec:
NodeSelector:
Type: backEndNode1
Containers:
-name: myweb
Image: harbor/tomcat:8.5-jre8
Ports:
-containerPort: 80
Create Deployment
Kubectl create-f Tomcat.yaml
This is the end of how to schedule Pod to the specified Node in Kubernetes. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.
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.