Contents

Kubernetes nodeSelector

Add label to the Node

Commands

Add label to node command structure

1
kubectl label nodes [node-name] [label-key]=[label-value]
NameExample
[node-name]node-1
[label-key]size
[label-value]Large

Add label to node command

1
kubectl label nodes node-1 size=Large

Select the Node in PODSpec

pod-definition.yml

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
apiVersion: v1
kind: Pod
metadata:
  name: myapp-pod
spec:
  containers:
    - name: data-processor
      image: data-processor
  nodeSelector:
    size: Large
1
kubectl apply -f pod-definition.yml