zoukankan      html  css  js  c++  java
  • k8s节点分配nodeSelector, Affinity和Anti-Affinity 亲和性和反亲和性

    节点选择器 nodeSelector

    • 节点选择器 通过匹配一个 节点的Label键值对告诉kube scheduler 将pod调度到哪个节点
      kubectl lable node mynode zzz=xxx #给mynode节点添加 zzz=xxx标签
    apiVersion: v1
    kind: Pod
    metadata:
      name: app01
      labels: 
        app: redis
    spec:
      containers:
      - name: redis
        image: redis
        ports:
        - name: redisport
          containerPort: 6379
          protocol: TCP
      nodeSelector:
        zzz: xxx
    

    节点亲和力和反亲和力 Node Affinity and Anti-Affinity

    • 如果 nodeSelector 与节点上的标签不匹配,则不会调度 pod。Node Affinity and Anti-Affinity

    • spec.affinity.nodeAffinity.preferredDuringSchedulingIgnoredDuringExecution

      • Soft NodeAffinity 和 Anti-Affinity:如果节点标签存在,Pod 将在那里运行。如果没有,那么 Pod 将被重新调度到集群内的其他地方。
    • spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution

      • Hard NodeAffinity 和 Anti-Affinity:如果节点标签不存在,则根本不会调度 Pod。

    pod亲和力和反亲和力 Pod Affinity and Anti-Affinity

    pod亲和力

    • spec.affinity.podAffinity.preferredDuringSchedulingIgnoredDuringExecution
      • 用于Soft Pod Affinity。如果首选选项可用,Pod 将在那里运行。如果没有,Pod 仍然可以安排在其他地方。
    • spec.affinity.podAffinity.requiredDuringSchedulingIgnoredDuringExecution
      • 用于Hard Pod Affinity。如果所需选项不可用,则 Pod 无法运行。

    pod反亲和力

    • spec.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution

      • 用于Soft Pod Anti-Affinity。如果首选选项可用,Pod 将在那里运行。如果没有,Pod 仍然可以被调度到其他地方。
    • spec.affinity.podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecution

      • 用于Hard Pod Anti-Affinity。如果所需选项不可用,则 Pod 无法运行。
        如果节点上有 xxx=yyy的标签,反亲和力Pod anti-affinity 不会将pod调度到该节点
  • 相关阅读:
    visio 2019 激活方法
    sftp 多用户安装与配置
    CentOS configuration uses the SFTP server
    esxi命令行强行关闭虚拟机
    esxi 版本升级命令
    存储分析 开源重复数据删除技术崭露头角
    最简单-转换MBR为GPT
    CentOS 7 搭建本地YUM仓库,并定期同步阿里云源
    uml建模工具介绍
    C/C++中extern关键字详解
  • 原文地址:https://www.cnblogs.com/erhao9767/p/14993510.html
Copyright © 2011-2022 走看看