支持使用 MgmtDriver 部署 HA Kubernetes Master

https://blueprints.launchpad.net/tacker/+spec/mgmt-driver-for-ha-Kubernetes

本文档描述了包含 Kubernetes 集群的 VNF 的 HA 操作增强。

问题描述

Kubernetes 集群可以作为 VNF 实例部署,但在高可用性 (HA) 用例中,Master 节点需要由三个或更多节点组成。本文档规范旨在支持部署具有 HA-Master 节点的 Kubernetes 集群。

提议的变更

Kubernetes 集群可以通过 ETSI NFV-SOL 003 中的 VNF 生命周期管理接口实例化 [1]。根据 ETSI NFV-SOL 001 [2]instantiate_end 操作允许用户使用 MgmtDriver 支持设置他们的 Kubernetes 集群。本文档通过 MgmtDriver 扩展了 instantiate_end 操作,以部署 HA Master 节点。

在 HA 配置中,执行负载均衡的 HAProxy 部署在多个 Master 节点的前面,并且 etcd 安装在每个 Master 节点上以构建内存数据库。如果一个 Master 节点发生故障,etcd 将确保 Kubernetes 集群的服务连续性,通过接管存储在其他 Master 节点上运行的内存数据库中的同步信息。

需要进行以下更改

  1. MgmtDriver 通过以下 instantiate_end 过程支持构建 HA master 节点

    • 识别由 OpenStackInfraDriver 创建的 VM。

    • 调用脚本以配置 HAProxy,以启动信号分发到 Master 节点。

    • 首先安装所有 Master 节点,然后通过调用设置新的 Kubernetes 集群的脚本安装 Worker 节点。

  2. 提供由 MgmtDriver 执行的示例脚本

    • 要安装需要诸如 HAProxy 的 IP 地址等信息的 HA 配置的 Kubernetes 集群。

    • 要配置 HAProxy 以启动信号分发到 Master 节点。

注意

关于 HAProxy 的配置,假设 HAProxy 具有多个 Master 节点的代表地址,并且来自 VNFM 的所有 Kubernetes 集群控制信号都通过 HAProxy 分发到每个 Master 节点。由于 HA Proxy 可能会成为 SPOF,因此最好结合 keepalived 采用 HAProxy 的冗余配置。

注意

HAProxy 可以通过两种方式配置,一种是部署在 Master 节点之外,另一种是与每个 Master 节点共存。下图显示了后者。每个 HAProxy 都有一个代表地址作为 VIP,并配置为向每个 Master 节点分发信号。应注意的是,需要 k8s-api 和 etcd 的信号分发设置。另一方面,HAProxy 路由的冗余可以通过虚拟路由器冗余协议 (VRRP) 实现,并且可以通过 keepalived 实现 HAProxy 的故障监控。

注意

Kubernetes v1.16.0和Kubernetes python客户端v11.0支持Kubernetes VIM。

下图显示了 Kubernetes HA 部署操作

                                   +---------+ +---------+  +---------------+
                                   | Cluster | |         |  | Instantiation |
                                   | Install | |  VNFD   |  | Request with  |
                                   | Script  | |         |  | Additional    |
                                   +---------+ +---------+  | Params        |
                                        |           |       +---------------+
                                        |           v                   |
                                        |      +---------+              |
                                        |      |         |              |
                                        +----->|  CSAR   |------+       |
                                               |         |      |       |
                                               +---------+      |       |
                                                             +--|-------|----+
                                                             |  v       v    |
                                                             |+------------+ |
                                                             ||TackerServer| |
                                                             |+------+-----+ |
                                                             |       |       |
                                                             |       v       |
     3.Kubernetes Cluster                                    |+-------------+|
       Installation to all VMs                               ||+----------+ ||
         +-----------------------------------------------------|MgmtDriver| ||
         |                                                   ||+------+---+ ||
+--------+------------------------------------+              ||       |     ||
|        |                                    | 2.HAProxy    ||       |     ||
|        |                                    | Configuration||       |     ||
|        |         +--------------------------------------------------+     ||
|        v         |                          |              ||             ||
|+-----------------|----------+    +--------+ |              ||             ||
||                 v          |    |        | |              ||+-----------+||
||+---------+    +---------+  |    |        | | 1.Create VMs |||OpenStack  |||
||| VIP -   |    | HAProxy |  |    |        | |<---------------|InfraDriver|||
|||  Active |--->| (Active)|----+  |        | |              |||           |||
|||(keep-   |    +---------+  | |  |        | |              ||+-----------+||
|||  alived)|    +---------+  | |  |        | |              ||             ||
||+---------+    | k8s-api |<---+  |        | |              ||             ||
||       ^       +---------+  | |  |        | |              ||             ||
||       |       +---------+  | |  |        | |              ||             ||
||  VRRP |    +->|  etcd   |  | |  |        | |              ||             ||
||       |    |  +---------+  | |  |Worker01| |              ||             ||
||       |    |   Master01 VM | |  |   VM   | |              ||             ||
|+-------|--- | --------------+ |  +--------+ |              ||             ||
|        |    |                 |             |              ||             ||
|+-------|--- | --------------+ |  +--------+ |              ||             ||
||       v    |               | |  |        | |              ||             ||
||+---------+ |  +---------+  | |  |        | |              ||             ||
||| VIP -   | |  | HAProxy |  | |  |        | |              ||             ||
|||  Standby| |  |(Standby)|  | |  |        | |              ||             ||
|||(keep-   | |  +---------+  | |  |        | |              ||             ||
|||  alived)| |  +---------+  | |  |        | |              ||             ||
||+---------+ |  | k8s-api |<---+  |        | |              ||             ||
||       ^    |  +---------+  | |  |        | |              ||             ||
||       |    |  +---------+  | |  |        | |              ||             ||
||  VRRP |    +->|  etcd   |  | |  |        | |              ||             ||
||       |    |  +---------+  | |  |Worker02| |              ||             ||
||       |    |   Master02 VM | |  |   VM   | |              ||             ||
|+-------|--- | --------------+ |  +--------+ |              ||             ||
|        |    |                 |             |              ||             ||
|+-------|--- | --------------+ |  +--------+ |              ||             ||
||       v    |               | |  |        | |              ||             ||
||+---------+ |  +---------+  | |  |        | |              ||             ||
||| VIP -   | |  | HAProxy |  | |  |        | |              ||             ||
|||  Standby| |  |(Standby)|  | |  |        | |              ||             ||
|||(keep-   | |  +---------+  | |  |        | |              ||             ||
|||  alived)| |  +---------+  | |  |        | |              ||             ||
||+---------+ |  | k8s-api |<---+  |        | |              ||             ||
||            |  +---------+  |    |        | |              ||             ||
||            |  +---------+  |    |        | |              ||             ||
||            +->|  etcd   |  |    |        | |              ||             ||
||               +---------+  |    |Worker03| |              ||             ||
||                Master03 VM |    |   VM   | |              ||             ||
|+----------------------------+    +--------+ |              ||  Tacker     ||
+---------------------------------------------+              ||  Conductor  ||
+---------------------------------------------+              |+-------------+|
|             Hardware Resources              |              |     VNFM      |
+---------------------------------------------+              +---------------+

该图显示了本规范提案的相关组件以及以下处理的概述

  1. OpenStackInfraDriver 创建 VM。

  2. MgmtDriver 调用脚本以配置 HAProxy。

  3. MgmtDriver 在 instantiate_end 中构建 HA Kubernetes 集群。

    1. MgmtDriver 使用 shell 脚本在多个 Master 和 Worker 节点上安装 Kubernetes。

注意

在这种配置中,由于 HA Proxy 位于 Master 节点中,因此必须单独配置端口,以避免 k8s-api 上的接收端口与 HAProxy 侧上的接收端口之间的冲突。

Kubernetes HA 部署操作的 VNFD

VNFD 需要具有以下示例中的 instantiate_end 定义

node_templates:
  VNF:
    ...
    interfaces:
      Vnflcm:
        instantiate: []
        instantiate_start: []
        instantiate_end:
          implementation: mgmt-drivers-kubernetes
    artifacts:
      mgmt-drivers-kubernetes:
        description: Management driver for Kubernetes cluster
        type: tosca.artifacts.Implementation.Python
        file: /.../mgmt_drivers/kubernetes_mgmt.py]

  masterNode:
    type: tosca.nodes.nfv.Vdu.Compute
    properties:
      name: masterNode
      description: masterNode
      vdu_profile:
        min_number_of_instances: 3
        max_number_of_instances: 3

  workerNode:
    type: tosca.nodes.nfv.Vdu.Compute
    properties:
      name: workerNode
      description: workerNode
      vdu_profile:
        min_number_of_instances: 1
        max_number_of_instances: 3

本文档规范假定 Master 节点的 min_number_of_instances 数量必须设置为大于或等于 3 的值。

注意

/etc/keepalived/keepalived.conf 的示例 通过更改 priority,更改发生故障时激活的顺序。

Master-node01

vrrp_script chk_haproxy {
    script "killall -0 haproxy"
    interval 3 fall 3
}
vrrp_instance VRRP1 {
    state MASTER
    interface enp0s3
    virtual_router_id 123
    priority 103
    advert_int 1
    virtual_ipaddress {
        192.168.128.80/24
    }
    track_script {
        chk_haproxy
    }
}

Master-node02

vrrp_script chk_haproxy {
    script "killall -0 haproxy"
    interval 3 fall 3
}
vrrp_instance VRRP1 {
    state BACKUP
    interface enp0s3
    virtual_router_id 123
    priority 102
    advert_int 1
    virtual_ipaddress {
        192.168.128.80/24
    }
    track_script {
        chk_haproxy
    }
}

Master-node03

vrrp_script chk_haproxy {
    script "killall -0 haproxy"
    interval 3 fall 3
}
vrrp_instance VRRP1 {
    state BACKUP
    interface enp0s3
    virtual_router_id 123
    priority 101
    advert_int 1
    virtual_ipaddress {
        192.168.128.80/24
    }
    track_script {
        chk_haproxy
    }
}

注意

/etc/haproxy/haproxy.cfg 的示例 以下是 SSL 直通设置的示例。

frontend k8s-api
    bind *:6440
    mode tcp
    default_backend    k8s-api

backend k8s-api
    balance   roundrobin
    mode      tcp
    server    master1  master01:6443  check
    server    master2  master02:6443  check  backup
    server    master3  master03:6443  check  backup

Kubernetes HA 部署操作请求数据

以下是VNF实例化请求POST /vnflcm/v1/vnf_instances/{vnfInstanceId}/instantiate中提供的body示例

{
  "flavourId": "cluster_install",
  "additionalParams": {
    "input_params":""
  },
  "vimConnectionInfo": [
    {
      "id": "8a3adb69-0784-43c7-833e-aab0b6ab4470",
      "vimId": "7dc3c839-bf15-45ac-8dff-fc5b95c2940e",
      "vimType": "openstack"
    }
  ]
}

序列图

以下序列图描述了涉及的组件以及 instantiate_end 中 HA Kubernetes Master 部署的流程

../../_images/0121.png

该过程包括以下步骤,如图所示。以下 No.3 及以后的过程作为 instantiate_end 执行。

  1. 客户端向 Instantiate VNF 发送 POST 请求。

  2. 基本上与 spec “2) VNF 实例实例化流程”章节中描述的相同序列,除了 MgmtDriver 之外。etsi-nfv-sol-rest-api-for-VNF-deployment

    注意

    Heat 模板包含 VM 实例化的资源信息。本文档规范假定 Master 节点的冗余 VM 数量在变量 “desired_capacity” 中指定。此变量必须设置为大于或等于 3 的值。

  3. MgmtDriver从Heat获取新的VM信息。

  4. MgmtDriver 通过使用 RemoteCommandExecutor 调用 shell 脚本来更改 HAProxy 配置。

  5. MgmtDriver 通过使用 RemoteCommandExecutor 调用 shell 脚本来重复设置 Master 节点和 Worker 节点,以获取新创建的 VM 数量。

备选方案

或者,HA Proxy 可以配置在 Master 节点 VM 之外的另一个 VM 中。但是,部署的 VM 数量会增加,并可能导致资源效率低下。

下图显示了使用替代方案的操作

                                   +---------+ +---------+  +---------------+
                                   | Cluster | |         |  | Instantiation |
                                   | Install | |  VNFD   |  | Request with  |
                                   | Script  | |         |  | Additional    |
                                   +---------+ +---------+  | Params        |
                                        |           |        +---------------+
                                        |           v                   |
                                        |      +---------+              |
                                        |      |         |              |
                                        +----->|  CSAR   |------+       |
                                               |         |      |       |
                                               +---------+      |       |
                                                             +--|-------|----+
                                                             |  v       v    |
                                                             |+------------+ |
                                                             ||TackerServer| |
                                                             |+------+-----+ |
                                                             |       |       |
                                                             |       v       |
         3.Kubernetes Cluster                                |+-------------+|
           Installation to Master-nodes and Worker-nodes     ||+----------+ ||
         +-----------------------------------------------------|MgmtDriver| ||
         |                                                   ||+------+---+ ||
+--------+------------------------------------+              ||       |     ||
|        |          +------------------------+|              ||       |     ||
|        |          |                        ||              ||       |     ||
|        |          |+---------+  +---------+|| 2.HAProxy    ||       |     ||
|        |          || HAProxy |  | VIP -   ||| Configuration||       |     ||
|        |       +---|(Active) |<-|  Active |<------------------------+     ||
|        |       |  ||         |  |(keep-   |||              ||             ||
|        |       |  ||         |  |  alived)|||              ||+-----------+||
|        |       |  |+---------+  +---------+|| 1.Create VMs |||OpenStack  |||
|        |       |  |                    ^   ||<---------------|InfraDriver|||
|        |       |  |     HAProxy01 VM   |   ||              |||           |||
|        |       |  +--------------------|---+|              ||+-----------+||
|        |       |                  VRRP |    |              ||             ||
|        |       |  +--------------------|---+|              ||             ||
|        |       |  |                    v   ||              ||             ||
|        |       |  |+---------+  +---------+||              ||             ||
|        |       |  || HAProxy |  | VIP -   |||              ||             ||
|        |       |  ||(Standby)|  |  Standby|||              ||             ||
|        |       |  ||         |  |(keep-   |||              ||             ||
|        |       |  ||         |  |  alived)|||              ||             ||
|        |       |  |+---------+  +---------+||              ||             ||
|        |       |  |     HAProxy02 VM       ||              ||             ||
|        v       |  +------------------------+|              ||             ||
|+-------------+ |  +--------+                |              ||             ||
||+---------+  | |  |        |                |              ||             ||
||| k8s-api |<---+  |        |                |              ||             ||
||+---------+  | |  |        |                |              ||             ||
||+---------+  | |  |        |                |              ||             ||
|||  etcd   |<----+ |        |                |              ||             ||
||+---------+  | || |Worker01|                |              ||             ||
|| Master01 VM | || |   VM   |                |              ||             ||
|+-------------+ || +--------+                |              ||             ||
|                ||                           |              ||             ||
|+-------------+ || +--------+                |              ||             ||
||+---------+  | || |        |                |              ||             ||
||| k8s-api |<---+| |        |                |              ||             ||
||+---------+  | || |        |                |              ||             ||
||+---------+  | || |        |                |              ||             ||
|||  etcd   |<----+ |        |                |              ||             ||
||+---------+  | || |Worker02|                |              ||             ||
|| Master02 VM | || |   VM   |                |              ||             ||
|+-------------+ || +--------+                |              ||             ||
|                ||                           |              ||             ||
|+-------------+ || +--------+                |              ||             ||
||+---------+  | || |        |                |              ||             ||
||| k8s-api |<---+| |        |                |              ||             ||
||+---------+  |  | |        |                |              ||             ||
||+---------+  |  | |        |                |              ||             ||
|||  etcd   |<----+ |        |                |              ||             ||
||+---------+  |    |Worker03|                |              ||             ||
|| Master03 VM |    |   VM   |                |              ||             ||
|+-------------+    +--------+                |              ||  Tacker     ||
+---------------------------------------------+              ||  Conductor  ||
+---------------------------------------------+              |+-------------+|
|             Hardware Resources              |              |     VNFM      |
+---------------------------------------------+              +---------------+

数据模型影响

REST API 影响

安全影响

通知影响

其他最终用户影响

性能影响

其他部署者影响

开发人员影响

实现

负责人

主要负责人

伊藤良人 <yoshito.itou.dr@hco.ntt.co.jp>

其他贡献者

Shotaro Banno <banno.shotaro@fujitsu.com>

Ayumu Ueha <ueha.ayumu@fujitsu.com>

陆梁 <lu.liang@fujitsu.com>

工作项

  • MgmtDriver将被修改以实现

    • 在“instantiate_end”中支持构建 HA Master 节点。

    • 提供由 MgmtDriver 执行的示例脚本,以安装和/或配置 Kubernetes 集群和 HAProxy。

  • 添加新的单元和功能测试。

依赖项

instantiate_end 在“Proposed change”中引用的是基于 mgmt-driver-for-k8s-cluster 的规范。

测试

将添加单元和功能测试,以涵盖规范所需的用例。

文档影响

将添加完整的用户指南,以解释如何从 VNF LCM API 的角度构建 Kubernetes HA。

参考资料