Assigning Kubernetes pods to specific nodes

By using worker groups, you can assign a pod in Kubernetes to specific nodes. When you create a custom worker group, its nodes are added a label with the group name. If you want your pod to be scheduled on a node from a specific worker group, add the node selector section with the node label to the pod's configuration file.

To create a pod that will be scheduled on a specific node

Click + Create on the Kubernetes dashboard and specify a YAML file that defines this object. For example:

apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    env: test
spec:
  containers:
  - name: nginx
    image: nginx
    imagePullPolicy: IfNotPresent
  nodeSelector:
    magnum.openstack.org/nodegroup: mygroup

This manifest describes the pod nginx that will be assigned to a node from the node group mygroup.

When the pod is created, check that the hosting node belongs to the specified worker group.