文档

将Pod调度到VNode

更新时间:

对于自建的Kubernetes集群,即混合使用普通节点和虚拟节点(VNode)的模式下,您可以通过配置nodeSelector和tolerations,或者指定nodeName的方式,将Pod调度到VNode上,以ECI来运行。本文介绍如何将Pod调度到VNode。

调度方式概述

VNode对标原生kubernetes节点,在混合使用普通节点和VNode的模式下,一般可以通过以下几种方式将Pod调度到VNode:

说明

下述方式均需要对存量资源做一定的修改,无法做到零侵入,建议您部署eci-profile组件,可以自定义配置Selector,将满足条件的Pod自动调度到VNode。具体操作,请参见使用eci-profile调度Pod到VNode

  • 配置nodeSelector和tolerations

    VNode默认配置了Label和Taint,因此可以通过配置nodeSelector和tolerations,将Pod调度到VNode,以ECI来运行。

  • 指定nodeName

    支持指定nodeName,将Pod调度到某个特定的VNode,以ECI来运行。

方式一:配置nodeSelector和tolerations

VNode默认配置了Label和Taint:

...
  labels:
    k8s.aliyun.com/vnode: "true"
...
  taints:
  - effect: NoSchedule
    key: k8s.aliyun.com/vnode
    value: "true"

因此可以通过配置nodeSelector和tolerations,将Pod调度到VNode,以ECI来运行。配置示例如下:

  1. 将以下内容保存为deploy-vnode-test1.yaml。

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: vnode-nginx-test1
    spec:
      replicas: 2
      selector:
        matchLabels:
          app: uid
      template:
        metadata:
          labels:
            app: uid
        spec:
          nodeSelector:     #配置特定的nodeSelector
            k8s.aliyun.com/vnode: "true"
          tolerations:      #配置特定的tolerations
          - key: k8s.aliyun.com/vnode
            operator: "Equal"
            value: "true"
            effect: "NoSchedule"
          containers:
          - name: nginx
            image: registry-vpc.cn-hangzhou.aliyuncs.com/eci_open/nginx:1.14.2
  2. 部署Deployment。

    kubectl apply -f deploy-vnode-test1.yaml

方式二:指定nodeName

支持指定nodeName,将Pod调度到某个特定的VNode。配置示例如下:

  1. 查询VNode信息。

    kubectl get nodes

    从返回信息中获取VNode名称。默认情况下,VNode的名称格式为[region].[VNode ID]。返回示例如下:

    NAME                                    STATUS   ROLES                  AGE    VERSION
    cn-hangzhou.vnd-2ze2qhf8lmp5kgsx****    Ready    agent                  132m   v1.20.6
    k8s-master                              Ready    control-plane,master   169m   v1.20.6
  2. 将以下内容保存为deploy-vnode-test2.yaml。

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: vnode-nginx-test2
    spec:
      replicas: 2
      selector:
        matchLabels:
          app: uid
      template:
        metadata:
          labels:
            app: uid
        spec:
          containers:
          - name: nginx
            image: registry-vpc.cn-hangzhou.aliyuncs.com/eci_open/nginx:1.14.2
          nodeName: cn-hangzhou.vnd-2ze2qhf8lmp5kgsx****   #指定VNode名称
  3. 部署Deployment。

    kubectl apply -f deploy-vnode-test2.yaml
  • 本页导读 (1)
文档反馈