Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does kubernetes assign the container to some nodes to run?

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how kubernetes assigns the container to some nodes to run". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how kubernetes assigns the container to run on certain nodes.

Assume that the deployed kubernetes cluster has five nodes, one master node and four work nodes, the default master node does not schedule Pod, and all Pod dispatch Pod on four work nodes. The simple list is as follows:

Hostname

Role

Node1

Masternode2

Worknode3worknode4worknode5work

Now you need to deploy 2 container applications An and B, where A belongs to business applications (such as springboot web applications) and B belongs to components (such as redis, zookeeper, etc.). You need to assign An applications to node2 and node3 nodes, and application B to node4 and node5 nodes to isolate components from business applications. The specific implementation is as follows:

1. View the label information of the current cluster node:

# View the current cluster node tag information kubectl get nodes-show-labels

# you can see that the default initial label for each node is roughly as follows: beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=node2,kubernetes.io/os=linux

2. Mark node2 and node3 nodes as business applications and node4 and node5 as component applications through deployment type tags:

Kubectl label nodes node2 deploy.type=biz_appkubectl label nodes node3 deploy.type=biz_appkubectl label nodes node4 deploy.type=assembly_appkubectl label nodes node5 deploy.type=assembly_app# confirms whether the tag is valid kubectl get nodes-- show-labels

3. Then Pod specifies the configuration as follows:

ApiVersion: apps/v1kind: Podmetadata: name: nginx-pod namespace: my-namespace labels: app: nginx-podspec: nodeSelector: deploy.type: assembly_app restartPolicy: Always containers:-name: nginx image: "nginx" ports:-containerPort: 80 so far, I believe you have a better understanding of "how kubernetes assigns the container to certain nodes to run". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report