K8S 的 daemonSet控制器:
可以将每个节点都部署一个Pod,可以让每个节点有切只有一个。
参考案例:
cat 01-ds.yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: baimei-ds
spec:
selector:
matchLabels:
apps: v1
template:
metadata:
labels:
apps: v1
spec:
# nodeSelector:
# type: ssd
#
# affinity:
# nodeAffinity:
# requiredDuringSchedulingIgnoredDuringExecution:
# nodeSelectorTerms:
# - matchExpressions:
# - key: school
# values:
# - baimei
# - yitiantain
# operator: In
tolerations:
- key: node-role.kubernetes.io/master
operator: Exists
effect: NoSchedule
containers:
- name: web
image: harbor.baimei.com/baimei-apps/apps:v1
运行
kubectl get pods -o wide --show-labels
kubectl get pods -o wide --show-labels
可以发现,每个节点都有一个 pod 在运行