Monday, October 28, 2019

Assign Pods to Nodes - nodeSelector

See current labels in the nodes:
# kubectl get nodes --show-labels

Creating a label for a specific host:
# kubectl label nodes {NODE_NAME} cputype=xeon

Assigning the label cputype=xeon to the pod
# kubectl edit deployment {MY_APP}

apiVersion: v1
kind: Pod
metadata:
    name: superapp
    labels:
      env: test
spec:
    containers:
      - name: superapp
      image: superapp
      imagePullPolicy: IfNotPresent
    nodeSelector:
      cputype=xeon


Check if pod is now in the new node
# kubectl get pods -o wide

Resource: https://kubernetes.io/docs/tasks/configure-pod-container/assign-pods-nodes/

No comments:

Post a Comment