![](/img/trans.png)
[英]Can Assign two Pods in Replication Controller to the two Different Nodes on Kubernetes?
[英]Kubernetes: how to assign pods to all nodes with sepcific label
我想在特定節點組中的每個單個節點上運行某些作業。
kubernetes可以做與Swarm全局模式一樣的事情嗎?
要完成@David Maze答案:
DaemonSet用於在每個節點上創建Pod。 更多信息在這里 。
例:
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
如果您不希望在每個節點上計划Pod,則可以使用“ 污染和容忍”概念。 污漬和容忍度共同作用,以確保未將豆莢安排在不適當的節點上。 有關更多信息,請通過鏈接查看。
例如:
您可以將污染添加到節點:
kubectl taint nodes <Node_name> key=value:NoSchedule
之后,即使從DaemonSet,Pods也將沒有機會在該Node上進行調度。 您可以向Pod(或您的情況下的DaemonSet)添加容差,以允許其在具有容差的Node上進行調度:
tolerations:
- key: "key"
operator: "Equal"
value: "value"
effect: "NoSchedule"
您正在尋找DaemonSet 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.