K8S节点选择器案例

1.标签选择器
#给节点打上标签
[root@lecode-k8s-master deployment]# kubectl label no lecode-dev-001 hostname=lecode-dev-001 
[root@lecode-k8s-master deployment]# kubectl get no --show-labels 
NAME                STATUS   ROLES                  AGE   VERSION   LABELS
lecode-dev-001      Ready    <none>                 17d   v1.20.9   beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,hostname=lecode-dev-001,kubernetes.io/arch=amd64,kubernetes.io/hostname=lecode-dev-001,kubernetes.io/os=linux

#yaml文件配置nodeselector

      nodeSelector:
        hostname: lecode-dev-001

2.节点名称选择
[root@test-master ~]# kubectl get no
NAME          STATUS   ROLES                  AGE   VERSION
test-master   Ready    control-plane,master   82d   v1.20.2
test-node1    Ready    <none>                 82d   v1.20.2
test-node2    Ready    <none>                 82d   v1.20.2

#yaml文件配置nodeselector
spec:
·····
  spec:
    nodeName: test-node1
    containers:
posted @ 2022-11-11 14:49  安生丶  阅读(63)  评论(0编辑  收藏  举报