Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

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

Shulou Source: shulou.com Published: 2022-06-02 04:00:32 09月25日 Update

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!

Tags: Node application label container run business component cluster information content tag learning scheduling utility deeper interested practical practical simple operation mode Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology MySQL Shulou Information Shulou Tech Info Docker