[英]Kubernetes: how to assign pods to all nodes with sepcific label
I want to run certain job on every single node in specific node groups. 我想在特定节点组中的每个单个节点上运行某些作业。
Can kubernetes do the same thing like Swarm global mode? kubernetes可以做与Swarm全局模式一样的事情吗?
To complete @David Maze answer: 要完成@David Maze答案:
A DaemonSet is used to create a Pod on each Node. DaemonSet用于在每个节点上创建Pod。 More information here . 更多信息在这里 。
Example: 例:
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: fluentd-elasticsearch
namespace: kube-system
labels:
k8s-app: fluentd-logging
spec:
selector:
matchLabels:
name: fluentd-elasticsearch
template:
metadata:
labels:
name: fluentd-elasticsearch
spec:
tolerations:
- key: node-role.kubernetes.io/master
effect: NoSchedule
containers:
- name: fluentd-elasticsearch
image: k8s.gcr.io/fluentd-elasticsearch:1.20
resources:
limits:
memory: 200Mi
requests:
cpu: 100m
memory: 200Mi
volumeMounts:
- name: varlog
mountPath: /var/log
- name: varlibdockercontainers
mountPath: /var/lib/docker/containers
readOnly: true
terminationGracePeriodSeconds: 30
volumes:
- name: varlog
hostPath:
path: /var/log
- name: varlibdockercontainers
hostPath:
path: /var/lib/docker/containers
If you want to schedule Pods not on every Node, you can use Taints and Tolerations concept. 如果您不希望在每个节点上计划Pod,则可以使用“ 污染和容忍”概念。 Taints and tolerations work together to ensure that pods are not scheduled onto inappropriate nodes. 污渍和容忍度共同作用,以确保未将豆荚安排在不适当的节点上。 For more information, look through the link . 有关更多信息,请通过链接查看。
For example: 例如:
You can add a Taint to a Node: 您可以将污染添加到节点:
kubectl taint nodes <Node_name> key=value:NoSchedule
After that, Pods will have no opportunity to schedule on that Node, even from a DaemonSet. 之后,即使从DaemonSet,Pods也将没有机会在该Node上进行调度。 You can add toleration to a Pod (or to a DaemonSet in your case) to allow it schedule on the Node with the toleration: 您可以向Pod(或您的情况下的DaemonSet)添加容差,以允许其在具有容差的Node上进行调度:
tolerations:
- key: "key"
operator: "Equal"
value: "value"
effect: "NoSchedule"
您正在寻找DaemonSet 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.