DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Schedule Kubernetes Pods to Nodes

Schedule Kubernetes Pods to Nodes

If your pods have a particular need like a high configuration, take a look at how you are able to configure them to run on specific nodes.

Jeyanthi Balakrishnan user avatar by
Jeyanthi Balakrishnan
·
Sep. 30, 18 · Tutorial
Like (2)
Save
Tweet
Share
5.70K Views

Join the DZone community and get the full member experience.

Join For Free

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 <node-name> as shown below. Excute the below commands in the shell(Linux platform).

Command:

kubectl label nodes <node-name> <label-key>=<label-value>

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 <node-name> <label-key>-


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.

pods Schedule (computer science) Kubernetes

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • HTTP vs Messaging for Microservices Communications
  • Full Lifecycle API Management Is Dead
  • Application Architecture Design Principles
  • NoSQL vs SQL: What, Where, and How

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: