繁体   English   中英

Kubernetes:如何将Pod分配给具有特定标签的所有节点

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM