存储架构

Schedule Kubernetes Pods to Nodes

微信扫一扫,分享到朋友圈

Schedule Kubernetes Pods to Nodes
0

In this article, we will see that how to schedule the pod to run in a particular node. You may get a scenario where you want to have more control on a node where a pod runs, such as a pod which may need high resources like heap, storage, cpu core, etc. It can be pointed to higher configuration node in a cluster, which has dependencies that can be executed in a particular node so you may co-locate the pods based on your needs.

I had difficulties in finding the exact steps over to schedule the pod in a node. I hope it will help you. Let’s see the detailed technical steps.

Create the label to run the pod in a particular slave/node using node affinity. Using “kubectl get nodes”, you can get the available nodes. Choose one of the node and replace with
as shown below. Excute the below commands in the shell(Linux platform).

Command:

kubectl label nodes  =

Example:

kubectl label nodes ip-123-12-123-12 thisnode=slavelabel

You can check the created label using the following command.

kubectl get nodes --show-labels

Example:

kubectl get nodes --show-labels | grep slavelabel

To delete label,

kubectl label nodes  -

Below JSON format works fine. To see the result, kubectl run command with the --overrides
option to run the pod in the particular slave node.

kubectl run -i --tty ubuntu --rm --image=ubuntu --restart=Never --overrides='
{
   "apiVersion": "v1",
   "kind": "Pod",
   "metadata": {
      "name": "ubuntutest"
   },
   "spec": {
      "affinity": {
         "nodeAffinity": {
            "requiredDuringSchedulingIgnoredDuringExecution": {
               "nodeSelectorTerms": [
                  {
                     "matchExpressions": [
                        {
                           "key": "thisnode",
                           "operator": "In",
                           "values": [
                              "slavelabel"
                           ]
                        }
                     ]
                  }
               ]
            }
         }
      }
   }
}
'

To know more about pods assignments, please refer this documentation.

阅读原文...


DZone

Open Source Messaging Queue for Lightning-Fast Client Server Comms

上一篇

Machine Learning in a Box (Week 8): SAP HANA EML and TensorFlow Integration

下一篇

您也可能喜欢

评论已经被关闭。

插入图片
Schedule Kubernetes Pods to Nodes

长按储存图像,分享给朋友