Node affinity

Photo by Daniele Levis Pelusi on Unsplash
admin@master:~$ kubectl get nodes --show-labels
NAME STATUS ROLES LABELS
master.testlab.local Ready control-plane,master ..hostname=master.testlab.local,os=linux,node-role.control-plane=,node-role.master=,node.exclude-from-external-load-balancers=
worker1.testlab.local Ready ..hostname=worker1.testlab.local,os=linux
worker2.testlab.local Ready ..hostname=worker2.testlab.local,os=linux
admin@master:~$ kubectl label nodes worker2.testlab.local color=blue
node/worker2.testlab.local labeled
admin@master:~$ kubectl get nodes -l color --show-labels
NAME STATUS ROLES AGE VERSION LABELS
master.testlab.local Ready control-plane,master 31h v1.23.1 ..color=black,..
worker1.testlab.local Ready <none> 31h v1.23.1 ..color=red,..
worker2.testlab.local Ready <none> 31h v1.23.1 ..color=blue,..
admin@master:~$ kubectl get nodes -l color=blue
NAME STATUS ROLES AGE VERSION
worker2.testlab.local Ready <none> 31h v1.23.1
admin@master:~$ k get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx 1/1 Running 0 6s 10.244.2.3 worker2.testlab.local <none> <none>
admin@master:~$ k describe pod nginx
Name: nginx
Namespace: default
Priority: 0
Node: worker2.testlab.local/<>
Start Time: Mon, 02 May 2022 08:38:43 +0000
Labels: <none>
Annotations: <none>
Status: Running
IP: 10.244.2.3
IPs:
IP: 10.244.2.3
Containers:
nginx:
Container ID: docker://
Image: nginx
Image ID: docker-pullable://nginx@sha256
Port: <none>
Host Port: <none>
State: Running
Started: Mon, 02 May 2022 08:38:44 +0000
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-55qhf (ro)
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
kube-api-access-55qhf:
Type: Projected (a volume that contains injected data from multiple sources)
TokenExpirationSeconds: 3607
ConfigMapName: kube-root-ca.crt
ConfigMapOptional: <nil>
DownwardAPI: true
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
Type Reason Age From Message
— — — — — — — — — — — — -
Normal Scheduled 107s default-scheduler Successfully assigned default/nginx to worker2.testlab.local
Normal Pulled 106s kubelet Container image “nginx” already present on machine
Normal Created 106s kubelet Created container nginx
Normal Started 106s kubelet Started container nginx

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store