WO2022033121A1 - 一种kubernetes中资源暴露方法、系统、设备以及介质 - Google Patents

一种kubernetes中资源暴露方法、系统、设备以及介质 Download PDF

Info

Publication number
WO2022033121A1
WO2022033121A1 PCT/CN2021/096544 CN2021096544W WO2022033121A1 WO 2022033121 A1 WO2022033121 A1 WO 2022033121A1 CN 2021096544 W CN2021096544 W CN 2021096544W WO 2022033121 A1 WO2022033121 A1 WO 2022033121A1
Authority
WO
WIPO (PCT)
Prior art keywords
mapping relationship
configuration file
pods
virtual
service
Prior art date
Application number
PCT/CN2021/096544
Other languages
English (en)
French (fr)
Inventor
刘鹏
Original Assignee
苏州浪潮智能科技有限公司
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 苏州浪潮智能科技有限公司 filed Critical 苏州浪潮智能科技有限公司
Priority to US18/013,108 priority Critical patent/US12010166B2/en
Publication of WO2022033121A1 publication Critical patent/WO2022033121A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
    • H04L67/1004Server selection for load balancing
    • H04L67/1008Server selection for load balancing based on parameters of servers, e.g. available memory or workload
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/45Network directories; Name-to-address mapping
    • H04L61/4505Network directories; Name-to-address mapping using standardised directories; using standardised directory access protocols
    • H04L61/4511Network directories; Name-to-address mapping using standardised directories; using standardised directory access protocols using domain name system [DNS]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/09Mapping addresses
    • H04L61/25Mapping addresses of the same type
    • H04L61/2503Translation of Internet protocol [IP] addresses
    • H04L61/255Maintenance or indexing of mapping tables
    • H04L61/2553Binding renewal aspects, e.g. using keep-alive messages
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/45Network directories; Name-to-address mapping
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/50Address allocation
    • H04L61/5053Lease time; Renewal aspects
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/104Peer-to-peer [P2P] networks
    • H04L67/1044Group management mechanisms 
    • H04L67/1048Departure or maintenance mechanisms
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/104Peer-to-peer [P2P] networks
    • H04L67/1074Peer-to-peer [P2P] networks for supporting data block transmission mechanisms
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/2866Architectures; Arrangements
    • H04L67/30Profiles
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/45Network directories; Name-to-address mapping
    • H04L61/4541Directories for service discovery

Definitions

  • the invention relates to the field of kubernetes, in particular to a resource exposure method, system, device and storage medium in kubernetes.
  • kubernetes In kubernetes (K8s, an open source application for managing containerized applications on multiple hosts in a cloud platform), a variety of ways to expose services (services) to the outside world are provided, such as nodeport, L7ingress, L4LoadBalancer ( Kubernetes' three external access methods), but because these methods are based on DNS (Domain Name System, domain name system), they do not provide true High Availability (HA, high availability) of multiple copies of pods (the smallest management element in kubernetes). ).
  • DNS Domain Name System, domain name system
  • HA High Availability
  • the main reason for the problem is that in a multi-copy pod, when a copy is down, DNS does not perceive the occurrence of an abnormal pod, and some traffic will still be imported into the abnormal pod until DNS finds that the pod is abnormal. And correct the traffic direction to stop importing abnormal traffic into abnormal pods.
  • an embodiment of the present invention proposes a method for exposing resources in kubernetes, including the following steps:
  • mapping relationship In response to the absence of the mapping relationship, acquiring a new virtual IP and establishing a mapping relationship between the new virtual IP and the label in the first configuration file;
  • the virtual IP corresponding to the label in the first configuration file is bound to multiple pods corresponding to the service resource, so as to use the virtual IP to expose the multiple pods to the outside of the kubernetes cluster.
  • binding the virtual IP corresponding to the label in the first configuration file to multiple pods corresponding to the service resource includes:
  • a load balancing strategy is executed based on the number of pods corresponding to the service resources in the load configuration file.
  • the method further includes:
  • the keepalived service monitors that the IPs of several pods on the pod list are deleted, deletes the IPs of the corresponding several pods in the load configuration file, and based on the remaining service resources in the load configuration file. The number of pods to enforce the load balancing strategy.
  • the method further includes:
  • mapping relationship In response to the existence of the mapping relationship, determining whether a request to disconnect the mapping relationship is received;
  • mapping relationship In response to receiving the request to disconnect the mapping relationship, delete the mapping relationship from the first configuration file, and unbind the multiple pods corresponding to the service resource with the corresponding virtual IPs, Expose the plurality of pods to the outside of the kubernetes cluster in a method native to the kubernetes cluster.
  • mapping relationship in response to the absence of the mapping relationship, acquiring a new virtual IP and establishing a mapping relationship between the new virtual IP and the label in the first configuration file, further comprising:
  • a new virtual IP is acquired and a mapping relationship between the new virtual IP and the label is established in the first configuration file.
  • the method further includes:
  • the multiple pods are exposed to the outside of the kubernetes cluster by using a method native to the kubernetes cluster.
  • the method further includes:
  • an embodiment of the present invention also provides a system for resource exposure in kubernetes, including:
  • a judging module configured to, in response to receiving a request for applying for a service resource, judge whether there is a mapping relationship between the label corresponding to the type of the service resource and the virtual IP in the first configuration file of the keepalived service;
  • the acquisition module is configured to acquire a new virtual IP and establish a mapping relationship between the new virtual IP and the label in the first configuration file in response to the absence of the mapping relationship;
  • binding module configured to bind the virtual IP corresponding to the label in the first configuration file to multiple pods corresponding to the service resource, so as to use the virtual IP to bind all
  • the above-mentioned multiple pods are exposed to the outside of the kubernetes cluster.
  • an embodiment of the present invention further provides a computer device, including:
  • a memory where the memory stores a computer program that can be executed on the processor, wherein when the processor executes the program, the processor executes the steps of any one of the methods for exposing resources in kubernetes as described above.
  • an embodiment of the present invention further provides a computer-readable storage medium, where the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor Perform the steps of any of the resource exposure methods in kubernetes as described above.
  • the present invention has one of the following beneficial technical effects: the solution proposed by the present invention implements the keepalived and corresponding virtual IP (VIP (Virtual IP)) to each pod of the service resource, and exposes the VIP to the outside of the kubernetes cluster, thereby realizing Expose each pod of service resources to the outside of the kubernetes cluster, while avoiding business interruption caused by DNS.
  • VIP Virtual IP
  • FIG. 1 is a schematic flowchart of a method for exposing resources in kubernetes according to an embodiment of the present invention
  • FIG. 2 is a schematic structural diagram of a system for resource exposure in kubernetes provided by an embodiment of the present invention
  • FIG. 3 is a schematic structural diagram of a computer device provided by an embodiment of the present invention.
  • FIG. 4 is a schematic structural diagram of a computer-readable storage medium provided by an embodiment of the present invention.
  • an embodiment of the present invention proposes a method for exposing resources in kubernetes, as shown in FIG. 1 , which may include steps:
  • S1 in response to receiving a request for applying for a service resource, determine whether there is a mapping relationship between the label corresponding to the type of the service resource and the virtual IP in the first configuration file of the keepalived service;
  • S3 Bind the virtual IP corresponding to the label in the first configuration file to multiple pods corresponding to the service resource, so as to use the virtual IP to expose the multiple pods to the outside of the kubernetes cluster .
  • the solution proposed by the present invention exposes each pod of the service resource to the outside of the kubernetes cluster through keepalived and corresponding virtual IP (VIP) to each pod of the service resource, and exposes the VIP to the outside of the kubernetes cluster, At the same time, the problem of business interruption caused by DNS is avoided.
  • VIP virtual IP
  • binding the virtual IP corresponding to the label in the first configuration file to multiple pods corresponding to the service resource includes:
  • a load balancing strategy is executed based on the number of pods corresponding to the service resources in the load configuration file.
  • the kubernetes cluster can add the IPs of the multiple pods created to the pod list, and the kubernetes cluster will provide an interface for other services to obtain the pods on the pod list Therefore, the keepalived service can obtain the pod information on the pod list through this interface, so that when it monitors that the pod information on the pod list changes, it can determine whether the service resource corresponding to the changed pod information is the specified service resource. , if it is a specified service resource, add the IPs of the corresponding multiple pods to the load configuration file to execute a load balancing strategy based on the number of pods corresponding to the service resource in the load configuration file.
  • the method further includes:
  • the keepalived service monitors that the IPs of several pods on the pod list are deleted, deletes the IPs of the corresponding several pods in the load configuration file, and based on the remaining service resources in the load configuration file. The number of pods to enforce the load balancing strategy.
  • the keepalived service monitors the deletion of the IPs of several pods on the pod list
  • the IPs of the corresponding pods exist in the load configuration file
  • the IPs of the corresponding several pods in the load configuration file are also deleted.
  • a load balancing strategy based on the number of pods remaining in the service resource in the load configuration file.
  • the IPs of several pods on the pod list are monitored to increase, and the IDs of the added pods belong to the specified service resources, the IPs of the added pods are added to the load configuration file, and the load configuration is based on the added pods.
  • the number of pods remaining in the service resource described in the file implements the load balancing strategy.
  • the load configuration file of the keepalived service will be modified synchronously; if the user deletes the service resource, The pods in the keepalived load configuration file will be deleted synchronously.
  • step S1 in response to receiving a request for applying for a service resource, determines whether there is a mapping relationship between the label corresponding to the type of the service resource and the virtual IP in the first configuration file of the keepalived service, the specific , when a user applies for a service resource in the kubernetes cluster, the first configuration file of the keepalived service can be used to determine whether the service resource has established a mapping relationship with the virtual IP (VIP), and if there is no mapping relationship, step S2 is performed.
  • VIP virtual IP
  • step S2 in response to the absence of the mapping relationship, acquiring a new virtual IP and establishing a mapping relationship between the new virtual IP and the label in the first configuration file, and further include:
  • a new virtual IP is acquired and a mapping relationship between the new virtual IP and the label is established in the first configuration file.
  • the method further includes:
  • the multiple pods are exposed to the outside of the kubernetes cluster by using a method native to the kubernetes cluster.
  • an application can be made to establish a corresponding mapping relationship, that is, a new virtual IP can be acquired, and then a mapping relationship between the virtual IP and the service resource can be established. It is also possible to expose the multiple pods to the outside of the kubernetes cluster by using the native method of the kubernetes cluster without applying for establishing a corresponding mapping relationship.
  • the method further includes:
  • mapping relationship In response to the existence of the mapping relationship, determining whether a request to disconnect the mapping relationship is received;
  • mapping relationship In response to receiving the request to disconnect the mapping relationship, delete the mapping relationship from the first configuration file, and unbind the multiple pods corresponding to the service resource with the corresponding virtual IPs, Expose the plurality of pods to the outside of the kubernetes cluster in a method native to the kubernetes cluster.
  • mapping relationship you can also apply to disconnect the mapping relationship, and use the native pod exposure method of the kubernetes cluster to expose multiple pods to the outside of the kubernetes cluster.
  • the method further includes:
  • the user can modify the load balancing configuration policy of the service in the first configuration file, and execute the load balancing policy according to the number of pods of the corresponding service resources in the load configuration file.
  • the solution proposed by the present invention exposes each pod of the service resource to the outside of the kubernetes cluster through keepalived and corresponding virtual IP (VIP) to each pod of the service resource, and exposes the VIP to the outside of the kubernetes cluster, At the same time, the problem of business interruption caused by DNS is avoided.
  • VIP virtual IP
  • an embodiment of the present invention further provides a system 400 for resource exposure in kubernetes, as shown in FIG. 2 , including:
  • Judging module 401 the judging module 401 is configured to, in response to receiving a request for applying for a service resource, judge whether there is a mapping relationship between the label corresponding to the type of the service resource and the virtual IP in the first configuration file of the keepalived service;
  • the obtaining module 402 is configured to, in response to the absence of the mapping relationship, obtain a new virtual IP and establish a mapping relationship between the new virtual IP and the label in the first configuration file ;
  • a binding module 403, the binding module 403 is configured to bind the virtual IP corresponding to the label in the first configuration file to multiple pods corresponding to the service resource, so as to utilize the virtual IP Expose the multiple pods outside the kubernetes cluster.
  • an embodiment of the present invention further provides a computer device 501, including:
  • the memory 510 stores a computer program 511 that can be executed on the processor.
  • the processor 520 executes the program, the processor 520 executes the steps of any one of the above methods for exposing resources in kubernetes.
  • an embodiment of the present invention further provides a computer-readable storage medium 601, where the computer-readable storage medium 601 stores computer program instructions 610, and the computer When the program instructions 610 are executed by the processor, the steps of any one of the above resource exposure methods in kubernetes are performed.
  • computer-readable storage media e.g. memory
  • volatile memory e.g., memory
  • non-volatile memory e.g., RAM

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Hardware Design (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Theoretical Computer Science (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本发明公开了一种kubernetes中资源暴露方法,包括:响应于接收到申请服务资源的请求,判断keepalived服务的第一配置文件中是否存在所述服务资源的类型对应的标签与虚拟IP之间的映射关系;响应于不存在所述映射关系,获取新的虚拟IP并在所述第一配置文件中建立所述新的虚拟IP与所述标签之间的映射关系;将所述第一配置文件中的与所述标签对应的虚拟IP绑定到所述服务资源对应的多个pod上,以利用所述虚拟IP将所述多个pod暴露到kubernetes集群外。本发明还公开了一种系统、计算机设备以及可读存储介质。本发明提出的方案通过keepalived和将虚拟IP(VIP)对应到服务资源的每个pod上,并将VIP暴露到kubernetes集群之外,从而实现将服务资源的每一个pod暴露到kubernetes集群之外,同时避免因DNS带来的业务中断问题。

Description

一种kubernetes中资源暴露方法、系统、设备以及介质
本申请要求于2020年8月14日提交中国国家知识产权局,申请号为202010818535.5,发明名称为“一种kubernetes中资源暴露方法、系统、设备以及介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明涉及kubernetes领域,具体涉及一种kubernetes中资源暴露方法、系统、设备以及存储介质。
背景技术
在kubernetes(K8s,是一种开源的、用于管理云平台中多个主机上的容器化的应用)中,提供了多种对外暴漏service(服务)的方式,例如nodeport、L7ingress、L4LoadBalancer(Kubernetes的三种外部访问方式)方式,但是由于这些方式基于DNS(Domain Name System,域名系统),并没有提供pod(kubernetes中的最小管理元素)的多副本的真正的High Availability(HA,高可用性)。主要带来问题的原因是,多副本pod中,当某一副本宕机,这时DNS并未感知到有异常pod发生,仍然会有一部分流量导入到异常的pod中,直到DNS发现pod异常,并修正流量导向,才会停止将异常流量导入到异常pod中。
发明内容
有鉴于此,为了克服上述问题的至少一个方面,本发明实施例提出一种kubernetes中资源暴露方法,包括以下步骤:
响应于接收到申请服务资源的请求,判断keepalived(一种能够实现高可用解决方案的软件)服务的第一配置文件中是否存在所述服务资源的类型对应的标签与虚拟IP(Internet Protocol,网络协议)之间的映射关系;
响应于不存在所述映射关系,获取新的虚拟IP并在所述第一配置文件中建立所述新的虚拟IP与所述标签之间的映射关系;
将所述第一配置文件中的与所述标签对应的虚拟IP绑定到所述服务资源对应的多个pod上,以利用所述虚拟IP将所述多个pod暴露到kubernetes集群外。
在一些实施例中,将第一配置文件中的与标签对应的虚拟IP绑定到服务资源对应的多个pod上包括:
创建所述服务资源对应的多个pod;
将创建的所述多个pod的IP更新到pod列表中;
利用所述keepalived服务监听所述pod列表,以将所述创建的多个pod的IP更新到负载配置文件中;
基于所述负载配置文件中所述服务资源对应的pod的数量执行负载均衡策略。
在一些实施例中,方法还包括:
响应于所述服务资源对应的多个pod中若干个pod异常,将异常的所述若干个pod的IP从所述pod列表中删除;
所述keepalived服务监听到所述pod列表上的若干个pod的IP被删除,将所述负载配置文件中对应的若干个pod的IP删除,并基于所述负载配置文件中所述服务资源剩余的pod的数量执行负载均衡策略。
在一些实施例中,方法还包括:
响应于存在所述映射关系,判断是否接收到断开所述映射关系的请求;
响应于接收到所述断开所述映射关系的请求,将所述映射关系从所述第一配置文件中删除,并将所述服务资源对应的多个pod与对应的虚拟IP进行解绑,以利用所述kubernetes集群原生的方法将所述多个pod暴露到所述kubernetes集群外。
在一些实施例中,响应于不存在所述映射关系,获取新的虚拟IP并在所述第一配置文件中建立所述新的虚拟IP与所述标签之间的映射关系,进一步包括:
响应于不存在所述映射关系,判断是否接收到建立所述映射关系的请求;
响应于接收到建立所述映射关系的请求,获取新的虚拟IP并在所述第一配置文件中建立所述新的虚拟IP与所述标签之间的映射关系。
在一些实施例中,方法还包括:
响应于没有接收到建立所述映射关系的请求,利用所述kubernetes集群原生的方法将所述多个pod暴露到所述kubernetes集群外。
在一些实施例中,方法还包括:
通过所述第一配置文件修改负载均衡策略。
基于同一发明构思,根据本发明的另一个方面,本发明的实施例还提供了一种用于kubernetes中资源暴露的系统,包括:
判断模块,所述判断模块配置为响应于接收到申请服务资源的请求,判断keepalived服务的第一配置文件中是否存在所述服务资源的类型对应的标签与虚拟IP之间的映射关系;
获取模块,所述获取模块配置为响应于不存在所述映射关系,获取新的虚拟IP并在所述第一配置文件中建立所述新的虚拟IP与所述标签之间的映射关系;
绑定模块,所述绑定模块配置为将所述第一配置文件中的与所述标签对应的虚拟IP绑定到所述服务资源对应的多个pod上,以利用所述虚拟IP将所述多个pod暴露到kubernetes集群外。
基于同一发明构思,根据本发明的另一个方面,本发明的实施例还提供了一种计算机设备,包括:
至少一个处理器;以及
存储器,所述存储器存储有可在所述处理器上运行的计算机程序,其特征在于,所述处理器执行所述程序时执行如上所述的任一种kubernetes中资源暴露方法的步骤。
基于同一发明构思,根据本发明的另一个方面,本发明的实施例还提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时执行如上所述的任一种kubernetes中资源暴露方法的步骤。
本发明具有以下有益技术效果之一:本发明提出的方案通过keepalived和将虚拟IP(VIP(Virtual IP))对应到服务资源的每个pod上,并将VIP暴露到kubernetes集群之外,从而实现将服务资源的每一个pod暴露到kubernetes集群之外,同时避免因DNS带来的业务中断问题。
附图说明
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员 来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的实施例。
图1为本发明的实施例提供的kubernetes中资源暴露方法的流程示意图;
图2为本发明的实施例提供的用于kubernetes中资源暴露的系统的结构示意图;
图3为本发明的实施例提供的计算机设备的结构示意图;
图4为本发明的实施例提供的计算机可读存储介质的结构示意图。
具体实施方式
为使本发明的目的、技术方案和优点更加清楚明白,以下结合具体实施例,并参照附图,对本发明实施例进一步详细说明。
需要说明的是,本发明实施例中所有使用“第一”和“第二”的表述均是为了区分两个相同名称非相同的实体或者非相同的参量,可见“第一”“第二”仅为了表述的方便,不应理解为对本发明实施例的限定,后续实施例对此不再一一说明。
根据本发明的一个方面,本发明的实施例提出一种kubernetes中资源暴露方法,如图1所示,其可以包括步骤:
S1,响应于接收到申请服务资源的请求,判断keepalived服务的第一配置文件中是否存在所述服务资源的类型对应的标签与虚拟IP之间的映射关系;
S2,响应于不存在所述映射关系,获取新的虚拟IP并在所述第一配置文件中建立所述新的虚拟IP与所述标签之间的映射关系;
S3,将所述第一配置文件中的与所述标签对应的虚拟IP绑定到所述服务资源对应的多个pod上,以利用所述虚拟IP将所述多个pod暴露到 kubernetes集群外。
本发明提出的方案通过keepalived和将虚拟IP(VIP)对应到服务资源的每个pod上,并将VIP暴露到kubernetes集群之外,从而实现将服务资源的每一个pod暴露到kubernetes集群之外,同时避免因DNS带来的业务中断问题。
在一些实施例中,将第一配置文件中的与标签对应的虚拟IP绑定到服务资源对应的多个pod上包括:
创建所述服务资源对应的多个pod;
将创建的所述多个pod的IP更新到pod列表中;
利用所述keepalived服务监听所述pod列表,以将所述创建的多个pod的IP更新到负载配置文件中;
基于所述负载配置文件中所述服务资源对应的pod的数量执行负载均衡策略。
具体的,当在kubernetes集群中利用多个pod创建服务资源时,kubernetes集群可以将创建的多个pod的IP添加到pod列表中,kubernetes集群会提供接口以使其他服务获取到pod列表上的pod信息,因此keepalived服务可以通过该接口获取到pod列表上的pod信息,这样当其监听到pod列表上的pod信息发生改变时,可以判断发生改变的pod信息对应的服务资源是否是指定的服务资源,如果是指定的服务资源则将对应的多个pod的IP加入负载配置文件中,以基于所述负载配置文件中所述服务资源对应的pod的数量执行负载均衡策略。
在一些实施例中,方法还包括:
响应于所述服务资源对应的多个pod中若干个pod异常,将异常的所述若干个pod的IP从所述pod列表中删除;
所述keepalived服务监听到所述pod列表上的若干个pod的IP被删除,将所述负载配置文件中对应的若干个pod的IP删除,并基于所述负载配置文件中所述服务资源剩余的pod的数量执行负载均衡策略。
具体的,当keepalived服务监听到pod列表上的若干个pod的IP删除,如果负载配置文件中存在对应的若干个pod的IP,则同样将所述负载配置文件中对应的若干个pod的IP删除,并基于所述负载配置文件中所述服务资源剩余的pod的数量执行负载均衡策略。同样的,若监听到pod列表上的若干个pod的IP增加,且增加的pod的ID属于指定的服务资源,则将增加的若干个pod的IP添加负载配置文件中,并基于所述负载配置文件中所述服务资源剩余的pod的数量执行负载均衡策略。
需要说明的是,只要keepalived服务对指定的服务资源的pod进行监听,无论用户对该服务资源进行横向扩展、缩容,都会同步修改keepalived服务的负载配置文件;如果用户对该服务资源进行删除,会同步删除keepalived的负载配置文件中的pod。
在一些实施例中,步骤S1响应于接收到申请服务资源的请求,判断keepalived服务的第一配置文件中是否存在所述服务资源的类型对应的标签与虚拟IP之间的映射关系中,具体的,当用户在kubernetes集群中申请服务资源时,可以通过keepalived服务的第一配置文件判断该服务资源是否与虚拟IP(VIP)建立了映射关系,如果不存在映射关系,则执行步骤S2。
在一些实施例中,步骤S2,响应于不存在所述映射关系,获取新的虚拟IP并在所述第一配置文件中建立所述新的虚拟IP与所述标签之间的映射关系,进一步包括:
响应于不存在所述映射关系,判断是否接收到建立所述映射关系的请求;
响应于接收到建立所述映射关系的请求,获取新的虚拟IP并在所述第一配置文件中建立所述新的虚拟IP与所述标签之间的映射关系。
在一些实施例中,方法还包括:
响应于没有接收到所述建立映射关系的请求,利用所述kubernetes集群原生的方法将所述多个pod暴露到所述kubernetes集群外。
具体的,如果第一配置文件中没有映射关系,则可以申请建立相应的映射关系,即可以获取一个新的虚拟IP,然后建立该虚拟IP与服务资源的映射关系。也可以不申请建立相应的映射关系,利用kubernetes集群原生的方法将所述多个pod暴露到所述kubernetes集群外。
需要说明的是,如果申请建立相应的映射关系,利用VIP的方法将多个pod暴露到所述kubernetes集群外,可以与kubernetes集群原生的将所述多个pod暴露到所述kubernetes集群外的方法共存,即用户即可以通过VIP访问相应的服务资源,也可以通过原生的方法访问相应的服务资源。
在一些实施例中,方法还包括:
响应于存在所述映射关系,判断是否接收到断开所述映射关系的请求;
响应于接收到所述断开所述映射关系的请求,将所述映射关系从所述第一配置文件中删除,并将所述服务资源对应的多个pod与对应的虚拟IP进行解绑,以利用所述kubernetes集群原生的方法将所述多个pod暴露到所述kubernetes集群外。
具体的,如果存在映射关系,也可以申请断开映射关系,利用kubernetes集群原生的暴露pod的方法将多个pod暴露到所述kubernetes集群外。
在一些实施例中,方法还包括:
通过所述第一配置文件修改负载均衡策略。
具体的,用户可以在第一配置文件中对业务的负载均衡配置策略进行 修改,并根据负载配置文件中相应服务资源的pod的数量执行负载均衡策略。
本发明提出的方案通过keepalived和将虚拟IP(VIP)对应到服务资源的每个pod上,并将VIP暴露到kubernetes集群之外,从而实现将服务资源的每一个pod暴露到kubernetes集群之外,同时避免因DNS带来的业务中断问题。
基于同一发明构思,根据本发明的另一个方面,本发明的实施例还提供了一种用于kubernetes中资源暴露的系统400,如图2所示,包括:
判断模块401,所述判断模块401配置为响应于接收到申请服务资源的请求,判断keepalived服务的第一配置文件中是否存在所述服务资源的类型对应的标签与虚拟IP之间的映射关系;
获取模块402,所述获取模块402配置为响应于不存在所述映射关系,获取新的虚拟IP并在所述第一配置文件中建立所述新的虚拟IP与所述标签之间的映射关系;
绑定模块403,所述绑定模块403配置为将所述第一配置文件中的与所述标签对应的虚拟IP绑定到所述服务资源对应的多个pod上,以利用所述虚拟IP将所述多个pod暴露到kubernetes集群外。
基于同一发明构思,根据本发明的另一个方面,如图3所示,本发明的实施例还提供了一种计算机设备501,包括:
至少一个处理器520;以及
存储器510,存储器510存储有可在处理器上运行的计算机程序511,处理器520执行程序时执行如上的任一种kubernetes中资源暴露方法的步骤。
基于同一发明构思,根据本发明的另一个方面,如图4所示,本发明的实施例还提供了一种计算机可读存储介质601,计算机可读存储介质601 存储有计算机程序指令610,计算机程序指令610被处理器执行时执行如上的任一种kubernetes中资源暴露方法的步骤。
最后需要说明的是,本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,可以通过计算机程序来指示相关硬件来完成,程序可存储于一计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。
此外,应该明白的是,本文的计算机可读存储介质(例如,存储器)可以是易失性存储器或非易失性存储器,或者可以包括易失性存储器和非易失性存储器两者。
本领域技术人员还将明白的是,结合这里的公开所描述的各种示例性逻辑块、模块、电路和算法步骤可以被实现为电子硬件、计算机软件或两者的组合。为了清楚地说明硬件和软件的这种可互换性,已经就各种示意性组件、方块、模块、电路和步骤的功能对其进行了一般性的描述。这种功能是被实现为软件还是被实现为硬件取决于具体应用以及施加给整个系统的设计约束。本领域技术人员可以针对每种具体应用以各种方式来实现的功能,但是这种实现决定不应被解释为导致脱离本发明实施例公开的范围。
以上是本发明公开的示例性实施例,但是应当注意,在不背离权利要求限定的本发明实施例公开的范围的前提下,可以进行多种改变和修改。根据这里描述的公开实施例的方法权利要求的功能、步骤和/或动作不需以任何特定顺序执行。此外,尽管本发明实施例公开的元素可以以个体形式描述或要求,但除非明确限制为单数,也可以理解为多个。
应当理解的是,在本文中使用的,除非上下文清楚地支持例外情况,单数形式“一个”旨在也包括复数形式。还应当理解的是,在本文中使用的“和/或”是指包括一个或者一个以上相关联地列出的项目的任意和所有 可能组合。
上述本发明实施例公开实施例序号仅仅为了描述,不代表实施例的优劣。
本领域普通技术人员可以理解实现上述实施例的全部或部分步骤可以通过硬件来完成,也可以通过程序来指令相关的硬件完成,的程序可以存储于一种计算机可读存储介质中,上述提到的存储介质可以是只读存储器,磁盘或光盘等。
所属领域的普通技术人员应当理解:以上任何实施例的讨论仅为示例性的,并非旨在暗示本发明实施例公开的范围(包括权利要求)被限于这些例子;在本发明实施例的思路下,以上实施例或者不同实施例中的技术特征之间也可以进行组合,并存在如上的本发明实施例的不同方面的许多其它变化,为了简明它们没有在细节中提供。因此,凡在本发明实施例的精神和原则之内,所做的任何省略、修改、等同替换、改进等,均应包含在本发明实施例的保护范围之内。

Claims (10)

  1. 一种kubernetes中资源暴露方法,其特征在于,包括以下步骤:
    响应于接收到申请服务资源的请求,判断keepalived服务的第一配置文件中是否存在所述服务资源的类型对应的标签与虚拟IP之间的映射关系;
    响应于不存在所述映射关系,获取新的虚拟IP并在所述第一配置文件中建立所述新的虚拟IP与所述标签之间的映射关系;
    将所述第一配置文件中的与所述标签对应的虚拟IP绑定到所述服务资源对应的多个pod上,以利用所述虚拟IP将所述多个pod暴露到kubernetes集群外。
  2. 如权利要求1所述的方法,其特征在于,将所述第一配置文件中的与所述标签对应的虚拟IP绑定到所述服务资源对应的多个pod上包括:
    创建所述服务资源对应的多个pod;
    将创建的所述多个pod的IP更新到pod列表中;
    利用所述keepalived服务监听所述pod列表,以将所述创建的多个pod的IP更新到负载配置文件中;
    基于所述负载配置文件中所述服务资源对应的pod的数量执行负载均衡策略。
  3. 如权利要求2所述的方法,其特征在于,还包括:
    响应于所述服务资源对应的多个pod中若干个pod异常,将异常的所述若干个pod的IP从所述pod列表中删除;
    所述keepalived服务监听到所述pod列表上的若干个pod的IP被删除,将所述负载配置文件中对应的若干个pod的IP删除,并基于所述负载配置文件中所述服务资源剩余的pod的数量执行负载均衡策略。
  4. 如权利要求1所述的方法,其特征在于,还包括:
    响应于存在所述映射关系,判断是否接收到断开所述映射关系的请求;
    响应于接收到所述断开所述映射关系的请求,将所述映射关系从所述第一配置文件中删除,并将所述服务资源对应的多个pod与对应的虚拟IP进行解绑,以利用所述kubernetes集群原生的方法将所述多个pod暴露到所述kubernetes集群外。
  5. 如权利要求1所述的方法,其特征在于,响应于不存在所述映射关系,获取新的虚拟IP并在所述第一配置文件中建立所述新的虚拟IP与所述标签之间的映射关系,进一步包括:
    响应于不存在所述映射关系,判断是否接收到建立所述映射关系的请求;
    响应于接收到建立所述映射关系的请求,获取新的虚拟IP并在所述第一配置文件中建立所述新的虚拟IP与所述标签之间的映射关系。
  6. 如权利要求5所述的方法,其特征在于,还包括:
    响应于没有接收到建立所述映射关系的请求,利用所述kubernetes集群原生的方法将所述多个pod暴露到所述kubernetes集群外。
  7. 如权利要求2或3所述的方法,其特征在于,还包括:
    通过所述第一配置文件修改负载均衡策略。
  8. 一种用于kubernetes中资源暴露的系统,其特征在于,包括:
    判断模块,所述判断模块配置为响应于接收到申请服务资源的请求,判断keepalived服务的第一配置文件中是否存在所述服务资源的类型对应的标签与虚拟IP之间的映射关系;
    获取模块,所述获取模块配置为响应于不存在所述映射关系,获取新的虚拟IP并在所述第一配置文件中建立所述新的虚拟IP与所述标签之间的映射关系;
    绑定模块,所述绑定模块配置为将所述第一配置文件中的与所述标签对应的虚拟IP绑定到所述服务资源对应的多个pod上,以利用所述虚拟IP将所述多个pod暴露到kubernetes集群外。
  9. 一种计算机设备,包括:
    至少一个处理器;以及
    存储器,所述存储器存储有可在所述处理器上运行的计算机程序,其特征在于,所述处理器执行所述程序时执行如权利要求1-7任意一项所述的方法的步骤。
  10. 一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,其特征在于,所述计算机程序被处理器执行时执行如权利要求1-7任意一项所述的方法的步骤。
PCT/CN2021/096544 2020-08-14 2021-05-27 一种kubernetes中资源暴露方法、系统、设备以及介质 WO2022033121A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US18/013,108 US12010166B2 (en) 2020-08-14 2021-05-27 Method and system for resource exposure in kubernetes, and device and medium

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010818535.5A CN112003961B (zh) 2020-08-14 2020-08-14 一种kubernetes中资源暴露方法、系统、设备以及介质
CN202010818535.5 2020-08-14

Publications (1)

Publication Number Publication Date
WO2022033121A1 true WO2022033121A1 (zh) 2022-02-17

Family

ID=73472396

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/096544 WO2022033121A1 (zh) 2020-08-14 2021-05-27 一种kubernetes中资源暴露方法、系统、设备以及介质

Country Status (3)

Country Link
US (1) US12010166B2 (zh)
CN (1) CN112003961B (zh)
WO (1) WO2022033121A1 (zh)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114553686A (zh) * 2022-02-26 2022-05-27 苏州浪潮智能科技有限公司 一种主备流量切换的方法、系统、设备和存储介质
CN114745358A (zh) * 2022-03-23 2022-07-12 网宿科技股份有限公司 负载均衡服务中的ip地址管理方法、系统及控制器
CN114979286A (zh) * 2022-05-11 2022-08-30 咪咕文化科技有限公司 容器服务的访问控制方法、装置、设备及计算机存储介质
CN115250197A (zh) * 2022-06-02 2022-10-28 苏州思萃工业互联网技术研究所有限公司 一种自动化创建容器发现服务的装置
CN115314432A (zh) * 2022-07-30 2022-11-08 济南浪潮数据技术有限公司 一种跨集群应用路由访问方法、系统、设备及介质

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112003961B (zh) 2020-08-14 2022-05-17 苏州浪潮智能科技有限公司 一种kubernetes中资源暴露方法、系统、设备以及介质
CN112799775B (zh) * 2020-12-29 2024-05-14 杭州涂鸦信息技术有限公司 一种节点属性传递方法以及相关装置
CN113835846B (zh) * 2021-11-26 2022-04-08 深圳市明源云科技有限公司 k8s集群的创建方法、装置及计算机可读存储介质
CN114374696A (zh) * 2021-12-15 2022-04-19 深圳前海微众银行股份有限公司 一种容器负载均衡方法、装置、设备及存储介质
CN115277652B (zh) * 2022-06-29 2024-03-22 北京百度网讯科技有限公司 基于推理服务的流媒体处理方法、装置、电子设备
CN115150410B (zh) * 2022-07-19 2024-06-18 京东科技信息技术有限公司 多集群访问方法和系统

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110086726A (zh) * 2019-04-22 2019-08-02 航天云网科技发展有限责任公司 一种自动切换Kubernetes主节点的方法
US20190379590A1 (en) * 2018-06-06 2019-12-12 Servicenow, Inc. Discovery and Mapping of Containerized Software Applications
CN111343007A (zh) * 2020-02-13 2020-06-26 卓望数码技术(深圳)有限公司 一种集群部署方法、装置和计算机可读介质
CN112003961A (zh) * 2020-08-14 2020-11-27 苏州浪潮智能科技有限公司 一种kubernetes中资源暴露方法、系统、设备以及介质

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7269603B1 (en) * 2003-12-17 2007-09-11 Sprint Communications Company L.P. Enterprise naming service system and method
US8077619B2 (en) * 2005-02-14 2011-12-13 Telefonaktiebolaget L M Ericsson (Publ) Method for aggregating data traffic over an access domain and nodes therefor
CN107864131A (zh) * 2017-11-03 2018-03-30 郑州云海信息技术有限公司 一种实现Kubernetes集群多租户网络隔离的方法及系统
US11153279B2 (en) * 2020-01-30 2021-10-19 Hewlett Packard Enterprise Development Lp Locally representing a remote application programming interface (API) endpoint within an application platform

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190379590A1 (en) * 2018-06-06 2019-12-12 Servicenow, Inc. Discovery and Mapping of Containerized Software Applications
CN110086726A (zh) * 2019-04-22 2019-08-02 航天云网科技发展有限责任公司 一种自动切换Kubernetes主节点的方法
CN111343007A (zh) * 2020-02-13 2020-06-26 卓望数码技术(深圳)有限公司 一种集群部署方法、装置和计算机可读介质
CN112003961A (zh) * 2020-08-14 2020-11-27 苏州浪潮智能科技有限公司 一种kubernetes中资源暴露方法、系统、设备以及介质

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114553686A (zh) * 2022-02-26 2022-05-27 苏州浪潮智能科技有限公司 一种主备流量切换的方法、系统、设备和存储介质
CN114553686B (zh) * 2022-02-26 2023-09-08 苏州浪潮智能科技有限公司 一种主备流量切换的方法、系统、设备和存储介质
CN114745358A (zh) * 2022-03-23 2022-07-12 网宿科技股份有限公司 负载均衡服务中的ip地址管理方法、系统及控制器
CN114979286A (zh) * 2022-05-11 2022-08-30 咪咕文化科技有限公司 容器服务的访问控制方法、装置、设备及计算机存储介质
CN114979286B (zh) * 2022-05-11 2023-09-19 咪咕文化科技有限公司 容器服务的访问控制方法、装置、设备及计算机存储介质
CN115250197A (zh) * 2022-06-02 2022-10-28 苏州思萃工业互联网技术研究所有限公司 一种自动化创建容器发现服务的装置
CN115250197B (zh) * 2022-06-02 2024-04-12 苏州思萃工业互联网技术研究所有限公司 一种自动化创建容器发现服务的装置
CN115314432A (zh) * 2022-07-30 2022-11-08 济南浪潮数据技术有限公司 一种跨集群应用路由访问方法、系统、设备及介质

Also Published As

Publication number Publication date
US12010166B2 (en) 2024-06-11
US20230319132A1 (en) 2023-10-05
CN112003961B (zh) 2022-05-17
CN112003961A (zh) 2020-11-27

Similar Documents

Publication Publication Date Title
WO2022033121A1 (zh) 一种kubernetes中资源暴露方法、系统、设备以及介质
US20210336997A1 (en) Method and system for virtual machine aware policy management
US20230079670A1 (en) Global-scale connectivity using scalable virtual traffic hubs
US11856065B2 (en) Data transmission for service integration between a virtual private cloud and an intranet
US9307017B2 (en) Member-oriented hybrid cloud operating system architecture and communication method thereof
WO2017036288A1 (zh) 一种网元升级方法及设备
WO2019029327A1 (zh) 网络功能服务的发现方法及设备
WO2017166136A1 (zh) 一种vnf的资源分配方法及装置
US9432321B2 (en) Method and apparatus for messaging in the cloud
US11218358B2 (en) Network connection and termination system
US11601365B2 (en) Wide area networking service using provider network backbone network
WO2017114363A1 (zh) 报文处理方法、bng及bng集群系统
WO2020057445A1 (zh) 一种通信系统、方法及装置
WO2023124309A1 (zh) 一种云原生upf信令面负载均衡选择方法及系统
WO2017012383A1 (zh) 一种服务注册方法、使用方法及相关装置
WO2024016624A1 (zh) 多集群访问方法和系统
US20240089328A1 (en) Systems and methods for dynamic federated api generation
WO2021129754A1 (zh) 一种报文处理的方法、设备及存储介质
WO2017211161A1 (zh) 基于软件定义网络的资源管理方法及装置
WO2020108443A1 (zh) 一种虚拟化管理方法及装置
US11638134B2 (en) Methods, systems, and computer readable media for resource cleanup in communications networks
US20220321471A1 (en) Multi-tenant offloaded protocol processing for virtual routers
CN110809033B (zh) 报文转发方法、装置及交换服务器
TWI607337B (zh) Firewall command rule optimization system and method
WO2018126483A1 (zh) 一种网络服务的控制方法及装置

Legal Events

Date Code Title Description
NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21855177

Country of ref document: EP

Kind code of ref document: A1