k8s namespace绑定节点
- [1. apiserver 启用准入控制 PodNodeSelector](#1. apiserver 启用准入控制 PodNodeSelector)
- [2. namespace 添加注解 scheduler.alpha.kubernetes.io/node-selector](#2. namespace 添加注解 scheduler.alpha.kubernetes.io/node-selector)
- [3. label node](#3. label node)
1. apiserver 启用准入控制 PodNodeSelector
vim /etc/kubernetes/manifests/kube-apiserver.yaml
yaml
spec:
containers:
- command:
- kube-apiserver
- --advertise-address=192.88.1.172
- --enable-admission-plugins=NodeRestriction,PodNodeSelector
2. namespace 添加注解 scheduler.alpha.kubernetes.io/node-selector
bash
kubectl get ns xx -o yaml > xx.yaml
vim xx.yaml
加入 注解
yaml
annotations:
scheduler.alpha.kubernetes.io/node-selector: tenant-xx=true
yaml
kubectl apply -f xx.yaml
最后xx namespace yaml如下:
yaml
apiVersion: v1
kind: Namespace
metadata:
annotations:
scheduler.alpha.kubernetes.io/node-selector: tenant-xx=true
name: xx
spec:
finalizers:
- kubernetes
3. label node
bash
kubectl label nodes node01 tenant-xx=true