简体   繁体   English

Kube.netes 沿着节点池传播 pod

[英]Kubernetes spread pods along nodepools

I'm running a managed kube.netes cluster in GCP, which has 2 node pools - one on regular VMs, one on spot VMs, autoscaling is configured for both of them.我在 GCP 中运行一个托管的 kube.netes 集群,它有 2 个节点池——一个在常规 VM 上,一个在现场 VM 上,为它们配置了自动缩放。 Currently i'm running batch jobs and async tasks on spot VMs and web apps on regular VMs, but to reduce costs i'd like to move web apps pods mostly to spot VMS.目前,我在 spot VM 上运行批处理作业和异步任务,在常规 VM 上运行 web 应用程序,但为了降低成本,我想将 web 应用程序 pod 主要转移到 spot VMS。 Usually i have 3-5 pods of each app running, so i'd like to leave 1 on regular VMs and 2-4 move to spot.通常我有 3-5 个运行的应用程序 pod,所以我想在常规 VM 上留下 1 个,然后 2-4 个移动到 spot。

I've found a nodeAffinity and podAffinity settings and have set preferred pod placement with preferredDuringSchedulingIgnoredDuringExecution and spot VMs node selector, but now all my pods have moved to spot VMs.我找到了nodeAffinitypodAffinity设置,并使用preferredDuringSchedulingIgnoredDuringExecution和 spot VM 节点选择器设置了首选 pod 放置,但现在我的所有 pod 都已移至 spot VM。

Try something like尝试类似的东西

spec:
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: topology.kubernetes.io/type
            operator: In
            values:
            - regular
            - spot/preemptible
    podAntiAffinity:
      preferredDuringSchedulingIgnoredDuringExecution: 
      - weight: 100  
        podAffinityTerm:
          labelSelector:
            matchExpressions:
            - key: app 
              operator: In 
              values:
              - app-label
          topologyKey: spot-node-label
      

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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