CN113032097A - 一种可自动伸缩实例数量的api网关实现方法及*** - Google Patents

一种可自动伸缩实例数量的api网关实现方法及*** Download PDF

Info

Publication number
CN113032097A
CN113032097A CN202110300076.6A CN202110300076A CN113032097A CN 113032097 A CN113032097 A CN 113032097A CN 202110300076 A CN202110300076 A CN 202110300076A CN 113032097 A CN113032097 A CN 113032097A
Authority
CN
China
Prior art keywords
service
data
application
gateway
mirror image
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110300076.6A
Other languages
English (en)
Inventor
张啸轩
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Inspur Cloud Information Technology Co Ltd
Original Assignee
Inspur Cloud Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Inspur Cloud Information Technology Co Ltd filed Critical Inspur Cloud Information Technology Co Ltd
Priority to CN202110300076.6A priority Critical patent/CN113032097A/zh
Publication of CN113032097A publication Critical patent/CN113032097A/zh
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/66Arrangements for connecting between networks having differing types of switching systems, e.g. gateways
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45562Creating, deleting, cloning virtual machine instances
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45575Starting, stopping, suspending or resuming virtual machine instances
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45595Network integration; Enabling network access in virtual machine instances

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Stored Programmes (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

本发明公开了一种可自动伸缩实例数量的API网关实现方法及***,属于数据互联互通、共享开放技术领域。本发明的可自动伸缩实例数量的API网关实现方法包括以下步骤:S1、构建镜像:将需部署的应用构建为Docker镜像;S2、部署至Kubernetes集群:通过.yaml配置文件将应用部署到Kubernetes集群中;S3、创建HPA:修改应用配置完成自动伸缩。该发明的可自动伸缩实例数量的API网关实现方法能够保证外部的正常调用、请求激增时不影响调用性能,还能节约服务器计算资源,具有很好的推广应用价值。

Description

一种可自动伸缩实例数量的API网关实现方法及***
技术领域
本发明涉及数据互联互通、共享开放技术领域,具体提供一种可自动伸缩实例数量的API网关实现方法及***。
背景技术
传统的应用部署方式是通过插件或脚本来安装应用。这样做的缺点是应用的运行、配置、管理、所有生存周期将与当前操作***绑定,这样做并不利于应用的升级更新/回滚等操作,当然也可以通过创建虚拟机的方式来实现某些功能,但是虚拟机非常重,并不利于可移植性。新的方式是通过部署容器方式实现。容器是一个标准的软件单元,用于打包代码及其所有依赖项,以便应用程序从一个计算环境快速可靠地运行到另一个计算环境。每个容器之间互相隔离,每个容器有自己的文件***,容器之间进程不会相互影响,能区分计算资源。相对于虚拟机,容器能快速部署,由于容器与底层设施、机器文件***解耦的,所以它能在不同云、不同版本操作***间进行迁移。
Docker容器技术在2013年作为开源Docker引擎推出。Docker容器镜像是一个轻量级、独立、可执行的软件包,包含运行应用程序所需的一切:代码、运行时环境、***工具、***库和设置。Docker容器是标准化的,Docker为容器化制定了工业标准,因此可以在多种平台上使用;Docker容器是轻量级的,容器共享机器的操作***内核,因此每个应用程序不需要操作***,提高了服务器效率,降低了服务器和许可成本;Docker容器是安全的,应用程序在容器中更安全,Docker提供了业界最强的隔离能力。
Kubernetes是一个开源***,用于容器化应用程序的自动部署、扩展和管理。它将组成应用程序的容器分组到逻辑单元中,以便于管理和发现。Kubernetes在Google运行生产工作负载的15年经验基础上,结合了来自社区的最佳想法和实践。Kubernetes具有服务发现和负载均衡、存储编排、批量执行、自动伸缩等功能。Kubernetes不需要修改应用程序来使用不熟悉的服务发现机制。Kubernetes为容器提供自己的IP地址和一组容器的单一DNS名称,并且可以在它们之间进行负载平衡。
当某个企业的后台业务应用需要对外部(如互联网用户)提供服务时,需要在业务应用的前端部署API网关,用于外部请求的认证、鉴权、分发,传统模式是将API网关部署在一定数量的服务器上,但是由于外部业务请求量的不确定性,容易导致请求过多导致的网关集群崩溃,或者当用户请求数量较小时,服务器资源闲置浪费。
发明内容
本发明的技术任务是针对上述存在的问题,提供一种能够保证外部的正常调用、请求激增时不影响调用性能,还能节约服务器计算资源的可自动伸缩实例数量的API网关实现方法。
本发明进一步的技术任务是提供一种可自动伸缩实例数量的API网关实现***。
为实现上述目的,本发明提供了如下技术方案:
一种可自动伸缩实例数量的API网关实现方法,包括以下步骤:
S1、构建镜像:将需部署的应用构建为Docker镜像;
S2、部署至Kubernetes集群:通过.yaml配置文件将应用部署到Kubernetes集群中;
S3、创建HPA:修改应用配置完成自动伸缩。
作为优选,步骤S1中,应用在Docker中以容器方式运行,将需部署的应用构建为Docker镜像。
作为优选,部署的应用包括data-service-service和data-service-gateway,使用Spring Boot开发,将应用打包为可执行jar包或war包,通过java-jar命令直接启动Spring Boot应用。
作为优选,构建镜像指定Dockerfile,包括data-service-service的Dockerfile和data-service-gateway的Dockerfile,且Dockerfile放于空的目录下。
作为优选,步骤S2中,由Deployment创建创建Pod,同时创建Service使外界访问到Pod,其中data-service-service配置文件为data-service-service.yaml,data-service-gateway配置文件为data-service-gateway.yaml。
作为优选,步骤S3中,创建HPA前,在Kubernetes集群中添加Metrics Service。
一种可自动伸缩实例数量的API网关实现***,包括镜像构建模块、Kubernetes集群部署模块和HPA创建模块;
镜像构建模块构建镜像,将需部署的应用构建为Docker镜像;
Kubernetes集群部署模块用于通过.yaml配置文件将应用部署到Kubernetes集群中;
HPA创建模块用于创建HPA,修改应用配置完成自动伸缩。
作为优选,镜像构建模块中,应用在Docker中以容器方式运行,将需部署的应用构建为Docker镜像,其中部署的应用包括data-service-service和data-service-gateway,使用Spring Boot开发,将应用打包为可执行jar包或war包,通过java-jar命令直接启动Spring Boot应用,构建镜像指定Dockerfile,包括data-service-service的Dockerfile和data-service-gateway的Dockerfile,且Dockerfile放于空的目录下。
作为优选,Kubernetes集群部署模块,由Deployment创建创建Pod,同时创建Service使外界访问到Pod,其中data-service-service配置文件为data-service-service.yaml,data-service-gateway配置文件为data-service-gateway.yaml。
作为优选,HPA创建模块在创建HPA前,在Kubernetes集群中添加MetricsService。
与现有技术相比,本发明的可自动伸缩实例数量的API网关实现方法具有以下突出的有益效果:所述可自动伸缩实例数量的API网关实现方法,网关集群可以根据请求压力的大小,自动伸缩网关的数量,做到既保证外部的正常调用、请求激增时不影响调用性能,还能节约服务器计算资源,具有良好的推广应用价值。
具体实施方式
下面将结合实施例,对本发明的可自动伸缩实例数量的API网关实现方法及***作进一步详细说明。
实施例一
本发明的可自动伸缩实例数量的API网关实现方法,包括以下步骤:
S1、构建镜像:将需部署的应用构建为Docker镜像。
应用在Docker中以容器方式运行,将需部署的应用构建为Docker镜像。部署的应用包括data-service-service和data-service-gateway,使用Spring Boot开发,将应用打包为可执行jar包或war包,通过java-jar命令直接启动Spring Boot应用。不需要额外的Web环境,因此构建Spring Boot应用镜像所需指令也比较少,构建镜像需要指定Dockerfile,包括data-service-service的Dockerfile和data-service-gateway的Dockerfile,data-service-service的Dockerfile为:
Figure BDA0002985866900000042
应用data-service-gateway的Dockerfile为:
Figure BDA0002985866900000043
在构建镜像时为了避免打包不必要的文件,减小Docker镜像体积,需要将jar包和Dockerfile放在空的目录下,即设定两个空目录data-service-service和data-service-gateway,分别放有data-service-service.jar、Dockerfile和data-service-gateway.jar、Dockerfile。
构建镜像成功后通过docker images查看构建后的镜像,为了在别处能够获取镜像,通过dockerpush将镜像推送到镜像仓库。
S2、部署至Kubernetes集群:通过.yaml配置文件将应用部署到Kubernetes集群中。
由Deployment创建创建Pod,同时创建Service使外界访问到Pod,其中data-service-service配置文件为data-service-service.yaml,data-service-gateway配置文件为data-service-gateway.yaml。
data-service-service.yaml内容为:
Figure BDA0002985866900000041
Figure BDA0002985866900000051
Figure BDA0002985866900000061
S3、创建HPA:修改应用配置完成自动伸缩。
创建HPA前,在Kubernetes集群中添加Metrics Service。
data-service-service HPA配置为:
Figure BDA0002985866900000062
Figure BDA0002985866900000071
data-service-gateway HPA配置为:
Figure BDA0002985866900000072
实施例二
本发明的可自动伸缩实例数量的API网关实现***,包括镜像构建模块、Kubernetes集群部署模块和HPA创建模块。
镜像构建模块构建镜像,将需部署的应用构建为Docker镜像。应用在Docker中以容器方式运行,将需部署的应用构建为Docker镜像,其中部署的应用包括data-service-service和data-service-gateway,使用Spring Boot开发,将应用打包为可执行jar包或war包,通过java-jar命令直接启动Spring Boot应用,构建镜像指定Dockerfile,包括data-service-service的Dockerfile和data-service-gateway的Dockerfile,且Dockerfile放于空的目录下。
Kubernetes集群部署模块用于通过.yaml配置文件将应用部署到Kubernetes集群中。Kubernetes集群部署模块,由Deployment创建创建Pod,同时创建Service使外界访问到Pod,其中data-service-service配置文件为data-service-service.yaml,data-service-gateway配置文件为data-service-gateway.yaml。
HPA创建模块用于创建HPA,修改应用配置完成自动伸缩。HPA创建模块在创建HPA前,在Kubernetes集群中添加Metrics Service。
以上所述的实施例,只是本发明较优选的具体实施方式,本领域的技术人员在本发明技术方案范围内进行的通常变化和替换都应包含在本发明的保护范围内。

Claims (10)

1.一种可自动伸缩实例数量的API网关实现方法,其特征在于:该方法包括以下步骤:
S1、构建镜像:将需部署的应用构建为Docker镜像;
S2、部署至Kubernetes集群:通过.yaml配置文件将应用部署到Kubernetes集群中;
S3、创建HPA:修改应用配置完成自动伸缩。
2.根据权利要求1所述的可自动伸缩实例数量的API网关实现方法,其特征在于:步骤S1中,应用在Docker中以容器方式运行,将需部署的应用构建为Docker镜像。
3.根据权利要求2所述的可自动伸缩实例数量的API网关实现方法,其特征在于:部署的应用包括data-service-service和data-service-gateway,使用Spring Boot开发,将应用打包为可执行jar包或war包,通过java-jar命令直接启动Spring Boot应用。
4.根据权利要求3所述的可自动伸缩实例数量的API网关实现方法,其特征在于:构建镜像指定Dockerfile,包括data-service-service的Dockerfile和data-service-gateway的Dockerfile,且Dockerfile放于空的目录下。
5.根据权利要求4所述的可自动伸缩实例数量的API网关实现方法,其特征在于:步骤S2中,由Deployment创建创建Pod,同时创建Service使外界访问到Pod,其中data-service-service配置文件为data-service-service.yaml,data-service-gateway配置文件为data-service-gateway.yaml。
6.根据权利要求5所述的可自动伸缩实例数量的API网关实现方法,其特征在于:步骤S3中,创建HPA前,在Kubernetes集群中添加Metrics Service。
7.一种可自动伸缩实例数量的API网关实现***,其特征在于:包括镜像构建模块、Kubernetes集群部署模块和HPA创建模块;
镜像构建模块构建镜像,将需部署的应用构建为Docker镜像;
Kubernetes集群部署模块用于通过.yaml配置文件将应用部署到Kubernetes集群中;
HPA创建模块用于创建HPA,修改应用配置完成自动伸缩。
8.根据权利要求5所述的可自动伸缩实例数量的API网关实现***,其特征在于:镜像构建模块中,应用在Docker中以容器方式运行,将需部署的应用构建为Docker镜像,其中部署的应用包括data-service-service和data-service-gateway,使用Spring Boot开发,将应用打包为可执行jar包或war包,通过java-jar命令直接启动Spring Boot应用,构建镜像指定Dockerfile,包括data-service-service的Dockerfile和data-service-gateway的Dockerfile,且Dockerfile放于空的目录下。
9.根据权利要求8所述的可自动伸缩实例数量的API网关实现***,其特征在于:Kubernetes集群部署模块,由Deployment创建创建Pod,同时创建Service使外界访问到Pod,其中data-service-service配置文件为data-service-service.yaml,data-service-gateway配置文件为data-service-gateway.yaml。
10.根据权利要求9所述的可自动伸缩实例数量的API网关实现***,其特征在于:HPA创建模块在创建HPA前,在Kubernetes集群中添加Metrics Service。
CN202110300076.6A 2021-03-22 2021-03-22 一种可自动伸缩实例数量的api网关实现方法及*** Pending CN113032097A (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110300076.6A CN113032097A (zh) 2021-03-22 2021-03-22 一种可自动伸缩实例数量的api网关实现方法及***

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110300076.6A CN113032097A (zh) 2021-03-22 2021-03-22 一种可自动伸缩实例数量的api网关实现方法及***

Publications (1)

Publication Number Publication Date
CN113032097A true CN113032097A (zh) 2021-06-25

Family

ID=76472071

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110300076.6A Pending CN113032097A (zh) 2021-03-22 2021-03-22 一种可自动伸缩实例数量的api网关实现方法及***

Country Status (1)

Country Link
CN (1) CN113032097A (zh)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180225103A1 (en) * 2017-02-09 2018-08-09 International Business Machines Corporation Optimizing service deployment in a distributed computing environment
CN109067862A (zh) * 2018-07-23 2018-12-21 北京邮电大学 API Gateway自动伸缩的方法与装置
CN111371679A (zh) * 2020-03-09 2020-07-03 山东汇贸电子口岸有限公司 一种基于kubernetes与Kong实现API网关的方法
CN112422683A (zh) * 2020-11-19 2021-02-26 浪潮云信息技术股份公司 一种k8s环境下的api网关服务高可用实现方法

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180225103A1 (en) * 2017-02-09 2018-08-09 International Business Machines Corporation Optimizing service deployment in a distributed computing environment
CN109067862A (zh) * 2018-07-23 2018-12-21 北京邮电大学 API Gateway自动伸缩的方法与装置
CN111371679A (zh) * 2020-03-09 2020-07-03 山东汇贸电子口岸有限公司 一种基于kubernetes与Kong实现API网关的方法
CN112422683A (zh) * 2020-11-19 2021-02-26 浪潮云信息技术股份公司 一种k8s环境下的api网关服务高可用实现方法

Similar Documents

Publication Publication Date Title
EP3471366B1 (en) Container deployment method, communication method between services and related devices
CN113296792B (zh) 存储方法、装置、设备、存储介质和***
US9621643B1 (en) System and method for joining containers running on multiple nodes of a cluster
CN109614167B (zh) 一种管理插件的方法和***
CN111610985B (zh) 一种国产平台上的kubernetes集群快速部署方法
CN110311948B (zh) 容器/容器组间的通信方法及基于此的容器云网络***
CN112202615B (zh) 一种多cni协同工作***与方法
CN109683909A (zh) 一种基于Docker的MPI并行环境自动部署方法
CN106406933B (zh) 一种Tomcat集群一键自动部署方法
Bansal et al. Disaggregating stateful network functions
CN116028163A (zh) 一种容器组的动态链接库调度方法、装置及存储介质
CN114996750A (zh) 数据共享方法以及装置
CN111294293B (zh) 一种基于用户态协议栈的网络隔离方法和装置
CN117193936B (zh) 超融合架构下的虚拟机管理方法、装置及设备
US8442939B2 (en) File sharing method, computer system, and job scheduler
CN117729251A (zh) 边缘计算设备、嵌入式设备、控制***及其构建方法
Merzky et al. Application level interoperability between clouds and grids
US8898314B2 (en) Direct communication between applications in a cloud computing environment
CN113032097A (zh) 一种可自动伸缩实例数量的api网关实现方法及***
Sekigawa et al. Web Application-Based WebAssembly Container Platform for Extreme Edge Computing
CN116382642A (zh) 一种基于鸿蒙操作***的军用服务化框架
CN115174657B (zh) 微服务应用调用方法、装置、计算机设备及存储介质
CN117519911B (zh) 自动注入***、方法、设备、集群以及介质
Richard et al. I-Cluster: Intense computing with untapped resources
WO2023065922A1 (zh) 一种交互方法、计算机设备和计算机存储介质

Legal Events

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20210625