


技术领域technical field
本申请涉及微服务技术领域,特别涉及一种API网关部署方法及装置。The present application relates to the technical field of microservices, and in particular, to a method and device for deploying an API gateway.
背景技术Background technique
API服务最基本的作用是接受来自客户端的请求并返回响应。然而,在当今蓬勃发展的微服务架构下,情况却并非如此简单。开发者们通常需要考虑API的安全防护、流量控制、分析与监控及计费等问题,而API网关便是解决这些问题的标配方案。The most basic role of an API service is to accept requests from clients and return responses. However, in today's booming microservices architecture, the situation is not so simple. Developers usually need to consider issues such as API security protection, traffic control, analysis and monitoring, and billing, and API gateway is the standard solution to these problems.
API网关是位于客户端与后端服务集合之间的API管理工具,为API调用者提供了统一入口,接受来自客户端的API调用,通过路由机制转发到后端服务。Kong是一款基于Nginx与Lua模块编写的高性能、易扩展的API网关项目,它通过插件的形式提供身份验证,速率限制,负载均衡,日志记录,协议转换等功能。The API gateway is an API management tool located between the client and the backend service collection. It provides a unified entry for API callers, accepts API calls from the client, and forwards them to the backend service through a routing mechanism. Kong is a high-performance and easily extensible API gateway project based on Nginx and Lua modules. It provides authentication, rate limiting, load balancing, logging, protocol conversion and other functions in the form of plug-ins.
单实例的Kong网关很可能会成为系统的性能瓶颈。因此,如何实现一个多实例分布式的高性能高可用的API网关方案,是一个重要的问题。Kong官方给出的一种基于Docker容器技术的部署方案,Kong与PostgreSQL以容器的形式部署在docker环境之中。要实现Kong的集群部署,只需在官方方案的基础上部署多个Kong容器即可。所有的Kong节点均连接至同一个PostgreSQL数据库,以实现API网关配置的数据同步。The single-instance Kong gateway is likely to become the performance bottleneck of the system. Therefore, how to implement a multi-instance distributed, high-performance and high-availability API gateway solution is an important issue. A deployment solution based on Docker container technology officially given by Kong, Kong and PostgreSQL are deployed in the docker environment in the form of containers. To implement Kong's cluster deployment, you only need to deploy multiple Kong containers based on the official solution. All Kong nodes are connected to the same PostgreSQL database for data synchronization of API Gateway configuration.
然而,各Kong实例仅以容器的方式部署,在Kong实例跨服务器部署时,无法有效进行编排、管理和调度,在对Kong实例进行扩容时,需要通过docker命令或者接口来完成,实现过程较复杂。However, each Kong instance is only deployed as a container. When the Kong instance is deployed across servers, it cannot be effectively orchestrated, managed and scheduled. When expanding the Kong instance, it needs to be done through docker commands or interfaces, and the implementation process is complicated. .
发明内容SUMMARY OF THE INVENTION
本申请提供了一种API网关部署方法及装置,用以解决现有技术中存在的各实例无法进行高效管理,调度和扩容的问题。The present application provides an API gateway deployment method and device, which are used to solve the problems existing in the prior art that each instance cannot be efficiently managed, scheduled and expanded.
第一方面,本申请提供了API网关部署方法,所述方法包括:In a first aspect, the present application provides an API gateway deployment method, the method comprising:
基于容器化应用管理平台的helm,创建包括用于部署Kong实例所需的清单文件模板的应用包;Based on the helm of the containerized application management platform, create an application package that includes the manifest file template required to deploy the Kong instance;
轮询预设的针对每一待部署Kong实例配置的参数列表,采用所述应用包中各清单文件模板,分别生成该待部署Kong实例对应的部署文件,其中,一个待部署Kong实例对应的部署文件至少包括针对该待部署Kong实例配置的各参数值;Polling the preset parameter list configured for each Kong instance to be deployed, and using each manifest file template in the application package to respectively generate deployment files corresponding to the Kong instance to be deployed, wherein a deployment file corresponding to a Kong instance to be deployed The file includes at least the parameter values configured for the Kong instance to be deployed;
基于各部署文件,分别生成对应的Kong实例。Based on each deployment file, corresponding Kong instances are generated respectively.
可选地,一个待部署Kong实例对应的参数列表至少包括:为该待部署Kong实例配置的IP地址信息,为该待部署Kong实例配置的端口信息和用于唯一标识该待部署Kong实例的实例名称。Optionally, a parameter list corresponding to a Kong instance to be deployed includes at least: IP address information configured for the Kong instance to be deployed, port information configured for the Kong instance to be deployed, and an instance for uniquely identifying the Kong instance to be deployed. name.
可选地,一个待部署Kong实例对应的参数列表还包括:集群中用于部署Kong实例的节点信息,该待部署Kong实例的CPU及内存的启动限制和运行限制。Optionally, the parameter list corresponding to a Kong instance to be deployed further includes: node information for deploying the Kong instance in the cluster, and the startup limit and running limit of the CPU and memory of the to-be-deployed Kong instance.
可选地,基于各部署文件,分别生成对应的Kong实例的步骤包括:Optionally, based on each deployment file, the steps of respectively generating corresponding Kong instances include:
在接收到Kong实例部署请求时,确定集群中用于部署Kong实例的目标节点;When receiving the Kong instance deployment request, determine the target node in the cluster for deploying the Kong instance;
根据各部署文件,分别在所述目标节点上部署对应Kong实例。According to each deployment file, deploy the corresponding Kong instance on the target node respectively.
可选地,所述方法还包括:Optionally, the method further includes:
将部署至目标节点上的各Kong实例的IP地址添加至所述目标节点的网卡中,以使得该Kong实例启动时,基于所述网卡中的对应的IP地址与外部设备进行通信。The IP address of each Kong instance deployed on the target node is added to the network card of the target node, so that when the Kong instance is started, it communicates with an external device based on the corresponding IP address in the network card.
第二方面,本申请提供了一种API网关部署装置,所述装置包括:In a second aspect, the present application provides an API gateway deployment device, the device comprising:
创建单元,用于基于容器化应用管理平台的helm,创建包括用于部署Kong实例所需的清单文件模板的应用包;Create a unit for creating an application package that includes the manifest file template required for deploying Kong instances based on the helm of the containerized application management platform;
第一生成单元,用于轮询预设的针对每一待部署Kong实例配置的参数列表,采用所述应用包中各清单文件模板,分别生成该待部署Kong实例对应的部署文件,其中,一个待部署Kong实例对应的部署文件至少包括针对该待部署Kong实例配置的各参数值;The first generating unit is configured to poll a preset parameter list configured for each Kong instance to be deployed, and use each manifest file template in the application package to respectively generate deployment files corresponding to the Kong instance to be deployed, wherein one The deployment file corresponding to the to-be-deployed Kong instance includes at least the parameter values configured for the to-be-deployed Kong instance;
第二生成单元,用于基于各部署文件,分别生成对应的Kong实例。The second generating unit is configured to generate corresponding Kong instances based on each deployment file.
可选地,一个待部署Kong实例对应的参数列表至少包括:为该待部署Kong实例配置的IP地址信息,为该待部署Kong实例配置的端口信息和用于唯一标识该待部署Kong实例的实例名称。Optionally, a parameter list corresponding to a Kong instance to be deployed includes at least: IP address information configured for the Kong instance to be deployed, port information configured for the Kong instance to be deployed, and an instance for uniquely identifying the Kong instance to be deployed. name.
可选地,一个待部署Kong实例对应的参数列表还包括:集群中用于部署Kong实例的节点信息,该待部署Kong实例的CPU及内存的启动限制和运行限制。Optionally, the parameter list corresponding to a Kong instance to be deployed further includes: node information for deploying the Kong instance in the cluster, and the startup limit and running limit of the CPU and memory of the to-be-deployed Kong instance.
可选地,基于各部署文件,分别生成对应的Kong实例时,所述第二生成单元具体用于:Optionally, when corresponding Kong instances are respectively generated based on each deployment file, the second generating unit is specifically used for:
在接收到Kong实例部署请求时,确定集群中用于部署Kong实例的目标节点;When receiving the Kong instance deployment request, determine the target node in the cluster for deploying the Kong instance;
根据各部署文件,分别在所述目标节点上部署对应Kong实例。According to each deployment file, deploy the corresponding Kong instance on the target node respectively.
可选地,所述装置还包括:Optionally, the device further includes:
添加单元,用于将部署至目标节点上的各Kong实例的IP地址添加至所述目标节点的网卡中,以使得该Kong实例启动时,基于所述网卡中的对应的IP地址与外部设备进行通信。The adding unit is used to add the IP address of each Kong instance deployed on the target node to the network card of the target node, so that when the Kong instance is started, based on the corresponding IP address in the network card and the external device. communication.
第三方面,本申请实施例提供了一种API网关部署装置,该API网关部署装置包括:In a third aspect, an embodiment of the present application provides an API gateway deployment device, where the API gateway deployment device includes:
存储器,用于存储程序指令;memory for storing program instructions;
处理器,用于调用所述存储器中存储的程序指令,按照获得的程序指令执行如上述第一方面中任一项所述的方法的步骤。The processor is configured to call the program instructions stored in the memory, and execute the steps of the method according to any one of the above-mentioned first aspects according to the obtained program instructions.
第四方面,本申请实施例还提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机可执行指令,所述计算机可执行指令用于使所述计算机执行如上述第一方面中任一项所述方法的步骤。In a fourth aspect, embodiments of the present application further provide a computer-readable storage medium, where the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to cause the computer to execute the above-mentioned first The steps of the method of any one of the aspects.
综上可知,本申请实施例提供的API网关部署方法,基于容器化应用管理平台的helm,创建包括用于部署Kong实例所需的清单文件模板的应用包;轮询预设的针对每一待部署Kong实例配置的参数列表,采用所述应用包中各清单文件模板,分别生成该待部署Kong实例对应的部署文件,其中,一个待部署Kong实例对应的部署文件至少包括针对该待部署Kong实例配置的各参数值;基于各部署文件,分别生成对应的Kong实例。To sum up, the API gateway deployment method provided by the embodiments of the present application creates an application package including the manifest file template required for deploying the Kong instance based on the helm of the containerized application management platform; Deploying the parameter list configured by the Kong instance, using each manifest file template in the application package, respectively generating the deployment file corresponding to the Kong instance to be deployed, wherein the deployment file corresponding to a Kong instance to be deployed at least includes the Kong instance for the to-be-deployed Each parameter value configured; based on each deployment file, the corresponding Kong instance is generated respectively.
采用本申请实施例提供的API网关部署方法,通过helm工具自动部署Kong实例集群,Kong实例以集群的方式管理,调度Kong实例,Kong实例的扩展操作简单灵活,提升了API网关的高可用性。Using the API gateway deployment method provided by the embodiments of the present application, the Kong instance cluster is automatically deployed through the helm tool, the Kong instance is managed in a cluster, and the Kong instance is scheduled. The expansion operation of the Kong instance is simple and flexible, and the high availability of the API gateway is improved.
附图说明Description of drawings
为了更加清楚地说明本申请实施例或者现有技术中的技术方案,下面将对本申请实施例或者现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请中记载的一些实施例,对于本领域普通技术人员来讲,还可以根据本申请实施例的这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings that need to be used in the description of the embodiments of the present application or the prior art. Obviously, the drawings in the following description These are just some embodiments described in this application, and for those of ordinary skill in the art, other drawings can also be obtained according to these drawings in the embodiments of this application.
图1为本申请实施例提供的一种API网关部署方法的详细流程图;1 is a detailed flowchart of a method for deploying an API gateway according to an embodiment of the present application;
图2为本申请实施例提供的一种API网关部署装置的结构示意图;FIG. 2 is a schematic structural diagram of an API gateway deployment apparatus provided by an embodiment of the present application;
图3为本申请实施例提供的另一种API网关部署装置的结构示意图。FIG. 3 is a schematic structural diagram of another apparatus for deploying an API gateway according to an embodiment of the present application.
具体实施方式Detailed ways
在本申请实施例使用的术语仅仅是出于描述特定实施例的目的,而非限制本申请。本申请和权利要求书中所使用的单数形式的“一种”、“所述”和“该”也旨在包括多数形式,除非上下文清楚地表示其它含义。还应当理解,本文中使用的术语“和/或”是指包含一个或多个相关联的列出项目的任何或所有可能组合。The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, rather than limiting the present application. As used in this application and the claims, the singular forms "a," "the," and "the" are intended to include the plural forms as well, unless the context clearly dictates otherwise. It will also be understood that the term "and/or" as used herein is meant to include any and all possible combinations of one or more of the associated listed items.
应当理解,尽管在本申请实施例可能采用术语第一、第二、第三等来描述各种信息,但这些信息不应限于这些术语。这些术语仅用来将同一类型的信息彼此区分开。例如,在不脱离本申请范围的情况下,第一信息也可以被称为第二信息,类似地,第二信息也可以被称为第一信息。取决于语境,此外,所使用的词语“如果”可以被解释成为“在……时”或“当……时”或“响应于确定”。It should be understood that although the terms first, second, third, etc. may be used in the embodiments of the present application to describe various information, the information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information without departing from the scope of the present application. Furthermore, the use of the word "if" can be interpreted as "at the time of" or "when" or "in response to determining", depending on the context.
下面结合具体用于场景对本申请实施例提供的云桌面系统进行详细说明,示例性的,参阅图1所示,为本申请实施例提供的一种API网关部署方法的详细流程图,该方法包括以下步骤:The cloud desktop system provided by the embodiment of the present application will be described in detail below with reference to the specific application scenarios. For example, referring to FIG. 1 , a detailed flowchart of an API gateway deployment method provided by the embodiment of the present application, the method includes: The following steps:
步骤100:基于容器化应用管理平台的helm,创建包括用于部署Kong实例所需的清单文件模板的应用包。Step 100: Based on the helm of the containerized application management platform, create an application package including a manifest file template required for deploying the Kong instance.
实际应用中,Helm是Kubernetes的包管理工具,每个包称为一个Chart,一个Chart中会包含一些模板化的Kubernetes清单文件,它们位于templates目录中。这些模板是一些YAML文件,它们经渲染后会被提交给Kubernetes,从而生成期望的Kubernetes资源,如Service,Deployment(部署文件),Statefulset,Job等。In practical applications, Helm is a package management tool for Kubernetes. Each package is called a Chart. A Chart will contain some templated Kubernetes manifest files, which are located in the templates directory. These templates are YAML files that are rendered and submitted to Kubernetes to generate the expected Kubernetes resources such as Service, Deployment (deployment file), Statefulset, Job, etc.
本申请实施例中,容器化应用管理平台可以是Kubernetes,那么,即可基于Kubernetes的Helm,创建一个Helm Chart,该Helm Chart包含一些位于templates目录的模板化的Kubernetes清单文件,如,kong.yaml,values.yaml文件等。In the embodiment of this application, the containerized application management platform may be Kubernetes, then, based on the Helm of Kubernetes, a Helm Chart can be created, and the Helm Chart includes some templated Kubernetes manifest files located in the templates directory, for example, kong.yaml , the values.yaml file, etc.
步骤110:轮询预设的针对每一待部署Kong实例配置的参数列表,采用上述应用包中各清单文件模板,分别生成该待部署Kong实例对应的部署文件,其中,一个待部署Kong实例对应的部署文件至少包括针对该待部署Kong实例配置的各参数值。Step 110 : poll the preset parameter list configured for each Kong instance to be deployed, and use each manifest file template in the above application package to generate deployment files corresponding to the Kong instance to be deployed, wherein one Kong instance to be deployed corresponds to The deployment file includes at least the parameter values configured for the Kong instance to be deployed.
本申请实施例中,一种较佳的实现方式为,一个待部署Kong实例对应的参数列表至少包括:为该待部署Kong实例配置的IP地址信息,为该待部署Kong实例配置的端口信息和用于唯一标识该待部署Kong实例的实例名称。In the embodiment of the present application, a preferred implementation manner is that a parameter list corresponding to a Kong instance to be deployed includes at least: IP address information configured for the Kong instance to be deployed, port information configured for the Kong instance to be deployed, and The instance name used to uniquely identify the Kong instance to be deployed.
例如,待部署Kong实例包括Kong实例1,Kong实例2和Kong实例3,那么,Kong实例1对应的参数包括:Kong1,KongIP1,kongHttpAdminPort1,kongHttpsAdminPort2,kongHttpProxyPort1,kongHttpsProxyPort2,其中,Kong1用于唯一标识Kong实例1,KongIP1表示Kong实例1的IP地址,kongHttpAdminPort1与kongHttpsAdminPort2分别表示Admin的HTTP与HTTPS端口;kongHttpProxyPort1与kongHttpsProxyPort2分别表示Proxy的HTTP与HTTPS端口。For example, the Kong instance to be deployed includes Kong instance 1, Kong instance 2 and Kong instance 3, then the parameters corresponding to Kong instance 1 include: Kong1, KongIP1, kongHttpAdminPort1, kongHttpsAdminPort2, kongHttpProxyPort1, kongHttpsProxyPort2, where Kong1 is used to uniquely identify the Kong instance 1. KongIP1 represents the IP address of Kong instance 1, kongHttpAdminPort1 and kongHttpsAdminPort2 represent the HTTP and HTTPS ports of the Admin respectively; kongHttpProxyPort1 and kongHttpsProxyPort2 represent the HTTP and HTTPS ports of the Proxy respectively.
本申请实施例中,提供了一种Kong实例名称的简单生成规则:将Kong实例的IPV4地址转换成十六进制作为Kong实例名称的值,如IP为“192.168.1.100”的Kong实例,其Kong实例名称的值为“c0a80164”。那么,Kong实例名称的生成规则可与IP地址相关,从而在删除指定IP的Kong实例或添加Kong实例时,可以方便地实现目标Deployment的增加与删除。In the embodiment of this application, a simple generation rule for the name of the Kong instance is provided: convert the IPV4 address of the Kong instance into hexadecimal as the value of the Kong instance name, such as the Kong instance whose IP is "192.168.1.100", its The value of Kong instance name is "c0a80164". Then, the generation rule of Kong instance name can be related to the IP address, so that when the Kong instance of the specified IP is deleted or the Kong instance is added, the addition and deletion of the target Deployment can be easily realized.
当然,本申请实施例中,上述Kong实例名称生成规则只是用于示例,而并非用于限定本申请。Of course, in the embodiments of the present application, the above Kong instance name generation rules are only used for examples, and are not used to limit the present application.
进一步地,一个待部署Kong实例对应的参数列表还包括:集群中用于部署Kong实例的节点信息,该待部署Kong实例的CPU及内存的启动限制和运行限制。Further, the parameter list corresponding to a Kong instance to be deployed further includes: node information used for deploying the Kong instance in the cluster, and the startup limit and operation limit of the CPU and memory of the to-be-deployed Kong instance.
例如,假设集群包括9个节点,节点1-节点3划分为区域1,节点4-节点6划分为区域2,节点7-节点9划分为区域3,配置的用于部署API网关的区域为区域3,那么,一个待部署Kong实例对应的参数列表中则可以携带用于部署Kong实例的节点信息(如,在节点7-节点9中部署API网关)。For example, suppose the cluster includes 9 nodes, node 1-node 3 is divided into area 1, node 4-node 6 is divided into area 2, node 7-node 9 is divided into area 3, and the configured area for deploying the API gateway is the area 3. Then, the parameter list corresponding to a Kong instance to be deployed may carry node information for deploying the Kong instance (for example, deploying an API gateway in node 7-node 9).
进一步地,本申请实施例中,所谓CPU启动限制(limits)指的是:对应Kong实例最少可使用的CPU资源值,CPU运行限制(requests)指的是:对应Kong实例最多可使用的CPU资源值;内存启动限制指的是:对应Kong实例最少可使用的内存资源,内存运行限制指的是:对应Kong实例最多可使用的内存资源值。Further, in the embodiment of the present application, the so-called CPU startup limit (limits) refers to: the minimum usable CPU resource value of the corresponding Kong instance, and the CPU operation limit (requests) refers to: the maximum usable CPU resource of the corresponding Kong instance Value; the memory startup limit refers to the minimum available memory resource of the corresponding Kong instance, and the memory operation limit refers to the maximum available memory resource value of the corresponding Kong instance.
具体地,上述Helm Chart包括的kong.yaml文件配置了与kong相关的Kubernetes资源模板,通过它可以生成Kong的Deployment,进而控制多实例Pod的生成。在kong.yaml中是通过一段循环语句来灵活控制Deployment的配置的。在进行参数配置时,将各待部署Kong实例的参数值下发至Values.yaml文件中,Values.yaml文件中的Values.kongNodes是自定义配置的Kong实例参数列表,循环遍历该列表,记每个元素为kongNode,它包含了各待部署的Kong实例的IP地址信息,端口信息,实例name等值,这些值分别作用于每个待部署Kong实例对应的Deployment。Specifically, the kong.yaml file included in the above Helm Chart configures the Kubernetes resource template related to Kong, through which Kong's Deployment can be generated, and then the generation of multi-instance Pods can be controlled. In kong.yaml, the configuration of Deployment is flexibly controlled through a loop statement. When configuring parameters, send the parameter values of each Kong instance to be deployed to the Values.yaml file. Values.kongNodes in the Values.yaml file is the custom-configured Kong instance parameter list, loop through the list, and record each The element is kongNode, which contains the IP address information, port information, instance name and other values of each Kong instance to be deployed. These values act on the Deployment corresponding to each Kong instance to be deployed.
Deployment中的参数replicas,是Pod中Kong实例的副本数,在本申请实施例中设置为1,每个kong实例都有一个单独的Deployment来控制。The parameter replicas in Deployment is the number of replicas of Kong instances in the Pod, which is set to 1 in the embodiment of this application, and each Kong instance is controlled by a separate Deployment.
需要说明的是,Deployment中的环境变量KONG_ADMIN_LISTEN与KONG_PROXY_LISTEN,是用来配置Kong实例Admin与Proxy的监听参数。Proxy端口用于代理后端服务,Admin端口用于管理Kong配置,对Kong的配置进行增、删、改、查操作。It should be noted that the environment variables KONG_ADMIN_LISTEN and KONG_PROXY_LISTEN in Deployment are used to configure the monitoring parameters of Kong instance Admin and Proxy. The Proxy port is used to proxy back-end services, and the Admin port is used to manage the Kong configuration, and to add, delete, modify, and check the Kong configuration.
步骤120:基于各部署文件,分别生成对应的Kong实例。Step 120: Based on each deployment file, generate corresponding Kong instances respectively.
本申请实施例中,在基于各部署文件,分别生成对应的Kong实例时,一种较佳的实现方式为,在接收到Kong实例部署请求时,确定集群中用于部署Kong实例的目标节点;根据各部署文件,分别在所述目标节点上部署对应Kong实例。In the embodiment of the present application, when the corresponding Kong instances are respectively generated based on each deployment file, a preferred implementation manner is, when receiving the Kong instance deployment request, determining the target node in the cluster for deploying the Kong instance; According to each deployment file, deploy the corresponding Kong instance on the target node respectively.
由于一个待部署Kong实例对应的参数列表中携带有用于部署Kong实例的节点信息,那么,即可确定集群中用于部署Kong实例的目标节点,然后,基于预设规则,在目标节点上部署Kong实例。Since the parameter list corresponding to a Kong instance to be deployed carries the node information for deploying the Kong instance, the target node for deploying the Kong instance in the cluster can be determined, and then, based on the preset rules, the Kong instance is deployed on the target node instance.
例如,在生成各待部署Kong实例分别对应的部署文件之后,就可以向Helm服务端发送部署请求了。具体地,Tiller Server是Helm的服务端,它使用gRPC与客户端进行通信。当Tiller监听到客户端的“helm install”请求之后,基于各待部署Kong实例的部署文件,与Kubernetes API服务进行交互,完成各Kong实例的部署。For example, after generating the deployment files corresponding to each Kong instance to be deployed, a deployment request can be sent to the Helm server. Specifically, Tiller Server is Helm's server, which uses gRPC to communicate with clients. When Tiller listens to the client's "helm install" request, it interacts with the Kubernetes API service based on the deployment file of each Kong instance to be deployed to complete the deployment of each Kong instance.
进一步地,将部署至目标节点上的各Kong实例的IP地址添加至所述目标节点的网卡中,以使得该Kong实例启动时,基于所述网卡中的对应的IP地址与外部设备进行通信。Further, the IP address of each Kong instance deployed on the target node is added to the network card of the target node, so that when the Kong instance is started, it communicates with an external device based on the corresponding IP address in the network card.
例如,为了使得外部设备能通过指定的IP地址访问API网关,这里将hostNetwork配置为true,这样Pod就可以使用宿主机节点的网络设备了。在Kong实例启动之前,先将待绑定的IP地址(待启动的Kong实例的IP地址)写入到Pod所在宿主机网卡中,从而Kong实例启动的时候就可正常使用此IP地址了。写入的操作可以在Kong镜像里的entrypoint脚本中添加“ip addr add”命令来实现。另外,在Pod终止前调用PreStop回调执行“ip addr del”命令,以完成IP的删除操作。For example, in order to enable external devices to access the API Gateway through the specified IP address, configure hostNetwork to true here, so that the Pod can use the network device of the host node. Before the Kong instance starts, write the IP address to be bound (the IP address of the Kong instance to be started) to the network card of the host where the Pod is located, so that the IP address can be used normally when the Kong instance is started. The write operation can be implemented by adding the "ip addr add" command to the entrypoint script in the Kong image. In addition, call the PreStop callback to execute the "ip addr del" command before the Pod terminates to complete the IP deletion operation.
进一步地,当Kong集群需要添加或删减Kong实例时,就需要对Kong集群进行升级了。升级的步骤与部署基本一致,只需要修改参数配置,在升级时发送“'helm upgrade”请求即可。Further, when the Kong cluster needs to add or delete Kong instances, it is necessary to upgrade the Kong cluster. The upgrade steps are basically the same as the deployment. You only need to modify the parameter configuration and send the "'helm upgrade" request during the upgrade.
基于与上述发明实施例同样的发明构思,示例性的,参阅图2所示,为本申请实施例提供的一种API网关部署装置的结构示意图,该装置包括:Based on the same inventive concept as the above embodiments of the invention, by way of example, referring to FIG. 2 , which is a schematic structural diagram of an API gateway deployment apparatus provided by an embodiment of the present application, the apparatus includes:
创建单元20,用于基于容器化应用管理平台的helm,创建包括用于部署Kong实例所需的清单文件模板的应用包;The
第一生成单元21,用于轮询预设的针对每一待部署Kong实例配置的参数列表,采用所述应用包中各清单文件模板,分别生成该待部署Kong实例对应的部署文件,其中,一个待部署Kong实例对应的部署文件至少包括针对该待部署Kong实例配置的各参数值;The
第二生成单元22,用于基于各部署文件,分别生成对应的Kong实例。The
可选地,一个待部署Kong实例对应的参数列表至少包括:为该待部署Kong实例配置的IP地址信息,为该待部署Kong实例配置的端口信息和用于唯一标识该待部署Kong实例的实例名称。Optionally, a parameter list corresponding to a Kong instance to be deployed includes at least: IP address information configured for the Kong instance to be deployed, port information configured for the Kong instance to be deployed, and an instance for uniquely identifying the Kong instance to be deployed. name.
可选地,一个待部署Kong实例对应的参数列表还包括:集群中用于部署Kong实例的节点信息,该待部署Kong实例的CPU及内存的启动限制和运行限制。Optionally, the parameter list corresponding to a Kong instance to be deployed further includes: node information for deploying the Kong instance in the cluster, and the startup limit and running limit of the CPU and memory of the to-be-deployed Kong instance.
可选地,基于各部署文件,分别生成对应的Kong实例时,所述第二生成单元具体用于:Optionally, when corresponding Kong instances are respectively generated based on each deployment file, the second generating unit is specifically used for:
在接收到Kong实例部署请求时,确定集群中用于部署Kong实例的目标节点;When receiving the Kong instance deployment request, determine the target node in the cluster for deploying the Kong instance;
根据各部署文件,分别在所述目标节点上部署对应Kong实例。According to each deployment file, deploy the corresponding Kong instance on the target node respectively.
可选地,所述装置还包括:Optionally, the device further includes:
添加单元,用于将部署至目标节点上的各Kong实例的IP地址添加至所述目标节点的网卡中,以使得该Kong实例启动时,基于所述网卡中的对应的IP地址与外部设备进行通信。The adding unit is used to add the IP address of each Kong instance deployed on the target node to the network card of the target node, so that when the Kong instance is started, based on the corresponding IP address in the network card and the external device. communication.
以上这些单元可以是被配置成实施以上方法的一个或多个集成电路,例如:一个或多个特定集成电路(Application Specific Integrated Circuit,简称ASIC),或,一个或多个微处理器(digital singnal processor,简称DSP),或,一个或者多个现场可编程门阵列(Field Programmable Gate Array,简称FPGA)等。再如,当以上某个单元通过处理元件调度程序代码的形式实现时,该处理元件可以是通用处理器,例如中央处理器(CentralProcessing Unit,简称CPU)或其它可以调用程序代码的处理器。再如,这些单元可以集成在一起,以片上系统(system-on-a-chip,简称SOC)的形式实现。The above units may be one or more integrated circuits configured to implement the above methods, such as: one or more specific integrated circuits (Application Specific Integrated Circuit, ASIC for short), or one or more microprocessors (digital singnal) processor, DSP for short), or one or more Field Programmable Gate Array (Field Programmable Gate Array, FPGA for short), etc. For another example, when a certain unit above is implemented in the form of a processing element scheduling program code, the processing element may be a general-purpose processor, such as a central processing unit (Central Processing Unit, CPU for short) or other processors that can call program codes. For another example, these units can be integrated together and implemented in the form of a system-on-a-chip (SOC for short).
进一步地,本申请实施例提供的API网关部署装置,从硬件层面而言,所述API网关部署装置的硬件架构示意图可以参见图3所示,所述API网关部署装置可以包括:存储器30和处理器31,Further, in the API gateway deployment apparatus provided by the embodiments of the present application, from a hardware perspective, a schematic diagram of the hardware architecture of the API gateway deployment apparatus may be shown in FIG. 3 , and the API gateway deployment apparatus may include: a
存储器30用于存储程序指令;处理器31调用存储器30中存储的程序指令,按照获得的程序指令执行上述方法实施例。具体实现方式和技术效果类似,这里不再赘述。The
可选地,本申请还提供一种API网关部署设备,包括用于执行上述方法实施例的至少一个处理元件(或芯片)。Optionally, the present application further provides an API gateway deployment device, including at least one processing element (or chip) for executing the foregoing method embodiments.
可选地,本申请还提供一种程序产品,例如计算机可读存储介质,该计算机可读存储介质存储有计算机可执行指令,该计算机可执行指令用于使该计算机执行上述方法实施例。Optionally, the present application further provides a program product, such as a computer-readable storage medium, where the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to cause the computer to execute the foregoing method embodiments.
这里,机器可读存储介质可以是任何电子、磁性、光学或其它物理存储装置,可以包含或存储信息,如可执行指令、数据,等等。例如,机器可读存储介质可以是:RAM(RadomAccess Memory,随机存取存储器)、易失存储器、非易失性存储器、闪存、存储驱动器(如硬盘驱动器)、固态硬盘、任何类型的存储盘(如光盘、dvd等),或者类似的存储介质,或者它们的组合。Here, a machine-readable storage medium can be any electronic, magnetic, optical, or other physical storage device that can contain or store information, such as executable instructions, data, and the like. For example, the machine-readable storage medium may be: RAM (Radom Access Memory, random access memory), volatile memory, non-volatile memory, flash memory, storage drive (such as hard disk drive), solid state drive, any type of storage disk ( such as optical discs, DVDs, etc.), or similar storage media, or a combination thereof.
上述实施例阐明的系统、装置、模块或单元,具体可以由计算机芯片或实体实现,或者由具有某种功能的产品来实现。一种典型的实现设备为计算机,计算机的具体形式可以是个人计算机、膝上型计算机、蜂窝电话、相机电话、智能电话、个人数字助理、媒体播放器、导航设备、电子邮件收发设备、游戏控制台、平板计算机、可穿戴设备或者这些设备中的任意几种设备的组合。The systems, devices, modules or units described in the above embodiments may be specifically implemented by computer chips or entities, or by products with certain functions. A typical implementing device is a computer, which may be in the form of a personal computer, laptop computer, cellular phone, camera phone, smart phone, personal digital assistant, media player, navigation device, email sending and receiving device, game control desktop, tablet, wearable device, or a combination of any of these devices.
为了描述的方便,描述以上装置时以功能分为各种单元分别描述。当然,在实施本申请时可以把各单元的功能在同一个或多个软件和/或硬件中实现。For the convenience of description, when describing the above device, the functions are divided into various units and described respectively. Of course, when implementing the present application, the functions of each unit may be implemented in one or more software and/or hardware.
本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请实施例可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。As will be appreciated by those skilled in the art, the embodiments of the present application may be provided as a method, a system, or a computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
本申请是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可以由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其它可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其它可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present application. It will be understood that each process and/or block in the flowchart illustrations and/or block diagrams, and combinations of processes and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to the processor of a general purpose computer, special purpose computer, embedded processor or other programmable data processing device to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing device produce Means for implementing the functions specified in a flow or flow of a flowchart and/or a block or blocks of a block diagram.
而且,这些计算机程序指令也可以存储在能引导计算机或其它可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或者多个流程和/或方框图一个方框或者多个方框中指定的功能。Furthermore, these computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing apparatus to operate in a particular manner, such that the instructions stored in the computer readable memory result in an article of manufacture comprising the instruction means, The instruction means implements the functions specified in a flow or flows of the flowcharts and/or a block or blocks of the block diagrams.
这些计算机程序指令也可装载到计算机或其它可编程数据处理设备上,使得在计算机或者其它可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其它可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded on a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that The instructions provide steps for implementing the functions specified in the flow or blocks of the flowcharts and/or the block or blocks of the block diagrams.
以上所述仅为本申请的较佳实施例而已,并不用以限制本申请,凡在本申请的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本申请保护的范围之内。The above descriptions are only preferred embodiments of the present application, and are not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application shall be included in the present application. within the scope of protection.
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202011527486.6ACN112600931B (en) | 2020-12-22 | 2020-12-22 | A kind of API gateway deployment method and device |
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202011527486.6ACN112600931B (en) | 2020-12-22 | 2020-12-22 | A kind of API gateway deployment method and device |
| Publication Number | Publication Date |
|---|---|
| CN112600931A CN112600931A (en) | 2021-04-02 |
| CN112600931Btrue CN112600931B (en) | 2022-05-24 |
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202011527486.6AActiveCN112600931B (en) | 2020-12-22 | 2020-12-22 | A kind of API gateway deployment method and device |
| Country | Link |
|---|---|
| CN (1) | CN112600931B (en) |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113157339B (en)* | 2021-04-23 | 2023-07-18 | 东云睿连(武汉)计算技术有限公司 | Application service extension method, system, storage medium and device based on OSB |
| CN114221949B (en)* | 2021-11-30 | 2024-04-05 | 北京航天云路有限公司 | API gateway implementation method suitable for public cloud platform |
| CN116095150B (en)* | 2023-01-31 | 2025-06-27 | 云合智网(上海)技术有限公司 | Deployment method, device, equipment and medium of network controller of non-service architecture |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN108270726A (en)* | 2016-12-30 | 2018-07-10 | 杭州华为数字技术有限公司 | Application example dispositions method and device |
| CN108809722A (en)* | 2018-06-13 | 2018-11-13 | 郑州云海信息技术有限公司 | A kind of method, apparatus and storage medium of deployment Kubernetes clusters |
| CN108958927A (en)* | 2018-05-31 | 2018-12-07 | 康键信息技术(深圳)有限公司 | Dispositions method, device, computer equipment and the storage medium of container application |
| CN110457114A (en)* | 2019-07-24 | 2019-11-15 | 杭州数梦工场科技有限公司 | Application cluster dispositions method and device |
| CN111176788A (en)* | 2019-12-24 | 2020-05-19 | 优刻得科技股份有限公司 | Method and system for deploying main nodes of Kubernetes cluster |
| CN111371679A (en)* | 2020-03-09 | 2020-07-03 | 山东汇贸电子口岸有限公司 | Method for realizing API gateway based on kubernets and Kong |
| CN111935312A (en)* | 2020-09-21 | 2020-11-13 | 深圳蜂巢互联(南京)科技研究院有限公司 | Industrial Internet container cloud platform and flow access control method thereof |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN108270726A (en)* | 2016-12-30 | 2018-07-10 | 杭州华为数字技术有限公司 | Application example dispositions method and device |
| CN108958927A (en)* | 2018-05-31 | 2018-12-07 | 康键信息技术(深圳)有限公司 | Dispositions method, device, computer equipment and the storage medium of container application |
| CN108809722A (en)* | 2018-06-13 | 2018-11-13 | 郑州云海信息技术有限公司 | A kind of method, apparatus and storage medium of deployment Kubernetes clusters |
| CN110457114A (en)* | 2019-07-24 | 2019-11-15 | 杭州数梦工场科技有限公司 | Application cluster dispositions method and device |
| CN111176788A (en)* | 2019-12-24 | 2020-05-19 | 优刻得科技股份有限公司 | Method and system for deploying main nodes of Kubernetes cluster |
| CN111371679A (en)* | 2020-03-09 | 2020-07-03 | 山东汇贸电子口岸有限公司 | Method for realizing API gateway based on kubernets and Kong |
| CN111935312A (en)* | 2020-09-21 | 2020-11-13 | 深圳蜂巢互联(南京)科技研究院有限公司 | Industrial Internet container cloud platform and flow access control method thereof |
| Title |
|---|
| 基于容器技术的新型智能网关设计;杨建平等;《自动化博览》;20191115(第11期);全文* |
| 容器网络Calico基本原理和模拟;朱娟等;《信息与电脑(理论版)》;20191225(第24期);全文* |
| Publication number | Publication date |
|---|---|
| CN112600931A (en) | 2021-04-02 |
| Publication | Publication Date | Title |
|---|---|---|
| CN112600931B (en) | A kind of API gateway deployment method and device | |
| CN107145380B (en) | Virtual resource arranging method and device | |
| CN113268308B (en) | Information processing method, device and storage medium | |
| CN112424765B (en) | Container framework for user-defined functions | |
| US20170168813A1 (en) | Resource Provider SDK | |
| CN111752681A (en) | Request processing method, apparatus, server, and computer-readable storage medium | |
| WO2019075773A1 (en) | Data processing method and apparatus, computer device and storage medium | |
| CN108287894B (en) | Data processing method, device, computing equipment and storage medium | |
| US12074918B2 (en) | Network-based Media Processing (NBMP) workflow management through 5G Framework for Live Uplink Streaming (FLUS) control | |
| CN111090423A (en) | Webhook framework system and method for realizing active calling and event triggering | |
| CN111736952A (en) | A method, apparatus, device and readable medium for cloud platform resource pool deployment | |
| CN116303309A (en) | File mounting method and device and electronic equipment | |
| CN106648838B (en) | Resource pool management configuration method and device | |
| US12355835B2 (en) | Asynchronous workflow for cloud based processing | |
| CN108270591A (en) | A kind of method and relevant device of Configuration network equipment | |
| CN107370818A (en) | A kind of distributed conversation method for managing object and system | |
| CN114911421B (en) | Data storage method, system, device and storage medium based on CSI plug-in | |
| CN114070889B (en) | Configuration methods, traffic forwarding methods, equipment, storage media and program products | |
| CN117273924A (en) | Transaction execution method and device and electronic equipment | |
| US11487606B2 (en) | Automated alert augmentation for deployments of software-defined storage | |
| US9934052B1 (en) | Large scale virtual application deployment using system provisioning tools | |
| US11140183B2 (en) | Determining criticality of identified enterprise assets using network session information | |
| CN115016862A (en) | Software startup method, device, server and storage medium based on Kubernetes cluster | |
| CN114564211A (en) | Cluster deployment method, cluster deployment device, equipment and medium | |
| CN114615285A (en) | Physical machine deployment method and device, electronic equipment and storage medium |
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |