A data communication method, apparatus, electronic device, and storage medium

By creating a target proxy service and determining an alternative proxy service in the K8s cluster, load balancing and internal network record resolution solve the problems of high cost and difficult maintenance in communication between the K8s cluster and external devices in the VPC network, achieving high-efficiency and reliable communication.

CN116668532BActive Publication Date: 2025-11-25DAWNING CLOUD COMPUTING TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310671759.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-07
Publication Date
2025-11-25
Estimated Expiration
2043-06-07

AI Technical Summary

Technical Problem

Existing Kubernetes clusters require source code modifications to communicate with external devices in the VPC network, resulting in high labor costs and maintenance difficulties, especially when the network changes or is upgraded.

Method used

By creating a target proxy service and determining an alternative proxy service based on the proxy service type, communication between external devices and cluster containers is achieved using load balancing services and intranet DNS records, including dynamic management by listening to container events.

Benefits of technology

It reduces labor costs, improves system maintainability, and enables reliable communication between external devices and cluster containers within the same VPC network.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116668532B_ABST
    Figure CN116668532B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a data communication method and device, electronic equipment and storage medium. The data communication method can specifically include: obtaining a proxy service creation request, and creating a target proxy service according to the proxy service creation request; determining a proxy service type of the target proxy service, and determining a substitute proxy service of the target proxy service according to the proxy service type; in the case of receiving a data communication request, responding to the data communication request through the substitute proxy service; wherein the data communication request is a data request between a cluster external device and a cluster container under the same network. The technical scheme of the embodiments of the present application can realize the communication between the cluster external device and the cluster container under the same VPC network, thereby reducing the artificial cost and improving the maintainability of the system.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present application relate to the technical field of communication, and in particular to a data communication method and device, electronic equipment and storage medium. BACKGROUND

[0002] With the rapid development of Internet technology, various enterprises and institutions have begun to transform digitally. However, with the digital transformation, the business volume is getting larger and larger, and the data is getting more and more, which leads to the fact that the existing operation and deployment cannot meet the growing business volume demand. The K8s (Kubernetes, container orchestration engine) cluster can be used to manage the containerized applications on multiple hosts in the cloud platform, so the K8s cluster can provide a convenient and effective platform to enable the scheduling and running of containers in the K8s cluster on physical and virtual machine clusters.

[0003] However, if the containers in the K8s cluster need to communicate with the external devices (such as virtual machines or physical machines outside the cluster) under the same VPC (Virtual Private Cloud, Virtual Private Cloud) network, the source code of the K8s cluster needs to be modified to enable the K8s cluster to adapt to the VPC network, thereby realizing the communication between the external devices and the cluster containers under the same VPC network. However, the above method needs to modify the K8s cluster source code again when the VPC network changes or upgrades, resulting in high labor cost and difficult system maintenance. SUMMARY

[0004] Embodiments of the present application provide a data communication method and device, electronic equipment and storage medium, which can realize the communication between the external devices and the cluster containers under the same VPC network, thereby reducing the labor cost and improving the maintainability of the system.

[0005] According to an aspect of the present application, a data communication method is provided, comprising:

[0006] obtaining a proxy service creation request, and creating a target proxy service according to the proxy service creation request;

[0007] determining the proxy service type of the target proxy service, and determining the substitute proxy service of the target proxy service according to the proxy service type;

[0008] in the case of receiving a data communication request, responding to the data communication request through the substitute proxy service; wherein the data communication request is a data request between the external devices and the cluster containers under the same network.

[0009] In addition, the data communication method according to the above-mentioned embodiment of the application can further have the following additional technical features:

[0010] Optionally, the determining the substitute proxy service of the target proxy service according to the proxy service type comprises:

[0011] In a case where the proxy service type is determined as the normal proxy service type, determining a current network identifier;

[0012] According to the target proxy service and the current network identifier, creating a load balancing service;

[0013] According to the load balancing service, updating a first data structure of the target proxy service, and determining the substitute proxy service according to an updating result of the first data structure.

[0014] The above-mentioned embodiment of the application has the following advantages or beneficial effects: a specific application scenario of the proxy service type being the normal proxy service type is proposed, so as to determine the substitute proxy service of the target proxy service of the normal proxy service type, thereby improving the reliability of communication between the cluster external device and the cluster container in the same VPC network.

[0015] Optionally, the updating the first data structure of the target proxy service according to the load balancing service comprises:

[0016] Determining an IP (Internet Protocol) address corresponding to the load balancing service;

[0017] Updating an IP address corresponding to the first data structure to the IP address corresponding to the load balancing service.

[0018] The above-mentioned embodiment of the application has the following advantages or beneficial effects: a specific implementation manner of updating the first data structure of the target proxy service according to the load balancing service is proposed, so as to more accurately update the first data structure of the target proxy service.

[0019] Optionally, the determining the substitute proxy service of the target proxy service according to the proxy service type comprises:

[0020] In a case where the proxy service type is determined as the headless proxy service type, determining a second data structure of the target proxy service, and determining the substitute proxy service according to the second data structure.

[0021] An embodiment of the above application has the following advantages or beneficial effects: the specific application scenario of the proxy service type being the headless proxy service type is proposed to determine the substitute proxy service of the target proxy service of the headless proxy service type, thereby improving the reliability of communication between the cluster external device and the cluster container in the same VPC network.

[0022] Optionally, the responding to the data communication request by the substitute proxy service comprises:

[0023] In a case where it is determined that the data communication request comprises the service IP address of the substitute proxy service, responding to the data communication request by the substitute proxy service according to the service IP address.

[0024] An embodiment of the above application has the following advantages or beneficial effects: the application scenario of the data communication request comprising the service IP address of the substitute proxy service is proposed to respond to the data communication request by the substitute proxy service according to the service IP address in the data communication request, thereby enabling the communication between the cluster external device and the cluster container in the same VPC network by the substitute proxy service when the data communication request comprises the service IP address of the substitute proxy service.

[0025] Optionally, after the target proxy service is created according to the proxy service creation request, the method further comprises:

[0026] According to the target proxy service, a service intranet resolution record corresponding to the target proxy service is created, and service attribute information corresponding to the target proxy service is determined according to the service intranet resolution record;

[0027] The responding to the data communication request by the substitute proxy service comprises:

[0028] In a case where it is determined that the data communication request comprises the service attribute information corresponding to the target proxy service, responding to the data communication request by the substitute proxy service according to the service attribute information;

[0029] The service intranet resolution record comprises a first type intranet resolution record and / or a second type intranet resolution record; and the service attribute information comprises service domain name information and / or service port information.

[0030] An embodiment of the above application has the following advantages or beneficial effects: by creating a service-intranet resolution record corresponding to the target proxy service, and determining service attribute information according to the service-intranet resolution record, when the service attribute information is included in the data communication request, the data communication request is responded to by the substitute proxy service according to the service attribute information, so that when the service attribute information is included in the data communication request, the communication between the cluster external device and the cluster container under the same VPC network can be realized by the substitute proxy service.

[0031] Optionally, after the substitute proxy service of the target proxy service is determined according to the proxy service type, the method further includes:

[0032] In the case of listening to a container creation event, a first substitute proxy service corresponding to the newly created container is determined, and the newly created container is added to a member list of the first substitute proxy service;

[0033] In the case of listening to a container destruction event, a second substitute proxy service corresponding to the destroyed container is determined, and the destroyed container is removed from the member list of the second substitute proxy service.

[0034] An embodiment of the above application has the following advantages or beneficial effects: the supplementary processing strategy of the listening event is increased, that is, when a container creation event is listened to, the newly created container is added to the member list of the corresponding substitute proxy service, and when a container destruction event is listened to, the destroyed container is removed from the member list of the corresponding substitute proxy service, so that the containers managed by the substitute proxy service can be added or removed in time, and the reliability of the communication is further improved.

[0035] Optionally, after the newly created container is added to the member list of the first substitute proxy service, the method further includes:

[0036] The container-intranet resolution record of the newly created container is obtained, and container domain name information of the newly created container is determined according to the container-intranet resolution record;

[0037] In the case that the container domain name information of the newly created container is included in the data communication request, the data communication request is responded to according to the container domain name information.

[0038] An embodiment of the above application has the following advantages or beneficial effects: by obtaining the container-intranet resolution record of the newly created container, and determining the container domain name information of the newly created container according to the container-intranet resolution record, when the container domain name information is included in the data communication request, the data communication request is responded to according to the container domain name information, so that when the container domain name information is included in the data communication request, the communication between the cluster external device and the cluster container under the same VPC network can be realized.

[0039] According to another aspect of the present application, there is provided a data communication apparatus comprising:

[0040] a target proxy service creation module configured to obtain a proxy service creation request and create a target proxy service according to the proxy service creation request;

[0041] a substitute proxy service determination module configured to determine a proxy service type of the target proxy service and determine a substitute proxy service of the target proxy service according to the proxy service type;

[0042] a data communication request response model configured to respond to a data communication request through the substitute proxy service in a case where the data communication request is received, wherein the data communication request is a data request between a cluster external device and a cluster container under a same network.

[0043] According to another aspect of the present application, there is provided an electronic device comprising:

[0044] at least one processor; and

[0045] a memory communicatively connected to the at least one processor; wherein

[0046] the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to perform the data communication method according to any one of the embodiments of the present application.

[0047] According to another aspect of the present application, there is provided a computer readable storage medium storing computer instructions for enabling a processor to perform the data communication method according to any one of the embodiments of the present application.

[0048] The technical solution of the embodiments of the present application obtains a proxy service creation request, creates a target proxy service according to the proxy service creation request, determines a proxy service type of the target proxy service, determines a substitute proxy service of the target proxy service according to the proxy service type, and responds to a data communication request through the substitute proxy service in a case where the data communication request is received, thereby solving the problem of high cost and difficult maintenance due to modification of source code in the prior art, enabling communication between a cluster external device and a cluster container under a same VPC network, thereby reducing labor cost and improving maintainability of the system.

[0049] It should be understood that the content described in this section is not intended to identify key or important features of the embodiments of the present application, nor is it used to limit the scope of the present application. Other features of the present application will become apparent through the following description. BRIEF DESCRIPTION OF DRAWINGS

[0050] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the accompanying drawings needed to be used in the embodiments description will be briefly introduced. Obviously, the accompanying drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained based on these drawings without any creative effort.

[0051] Figure 1 is a flow chart of a data communication method provided by the first embodiment of the present application;

[0052] Figure 2 is a flow chart of a data communication method provided by the second embodiment of the present application;

[0053] Figure 3 is an execution logic diagram of a container new creation and destruction event provided by the second embodiment of the present application;

[0054] Figure 4 is a timing diagram of a general proxy service creation provided by the third embodiment of the present application;

[0055] Figure 5 is a timing diagram of a headless proxy service creation provided by the fourth embodiment of the present application;

[0056] Figure 6 is a schematic diagram of a data communication device provided by the fourth embodiment of the present application;

[0057] Figure 7 is a structural schematic diagram of an electronic device implementing the data communication method of the present application. DETAILED DESCRIPTION

[0058] In order to make the technical personnel in the art better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely in the following with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without any creative effort should belong to the scope of protection of the present application.

[0059] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and in the above-described drawings are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device that includes a series of steps or units does not have to be limited to only those steps or units clearly listed, but can include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0060] Embodiment one

[0061] Figure 1 is a flowchart of a data communication method provided by the first embodiment of the present application. The present embodiment can be applied to the case of realizing communication between external devices and cluster containers in the same VPC network. The method can be executed by a data communication device, which can be realized by software and / or hardware, and can be directly integrated in an electronic device that executes the method, which can be a terminal device or a server device. The present embodiment does not limit the type of electronic device that executes the data communication method. Specifically, as shown in Figure 1 the data communication method can specifically include the following steps:

[0062] S110, obtaining a proxy service creation request, and creating a target proxy service according to the proxy service creation request.

[0063] The proxy service creation request can be a request to create a proxy service. Optionally, the proxy service can be a forwarding proxy service in the K8s cluster, for example, an SVC in the K8s cluster, i.e., a Service resource object in the K8s cluster. It can be understood that the container in the K8s cluster is the carrier of the application program, and the application program can be accessed through the IP address of the container. However, the IP address of the container is not fixed, so the IP address of the container cannot be directly used to access the service. Therefore, the K8s cluster provides a Service resource. The Service can aggregate multiple containers that provide the same service and provide a unified entry address, so that the application program in the container can be accessed by accessing the entry address of the Service. The target proxy service can be a proxy service created according to the proxy service creation request.

[0064] In the embodiment of the present application, the proxy service creation request is acquired to create a target proxy service according to the proxy service creation request. It should be noted that the embodiment of the present application does not limit the specific implementation manner of creating the target proxy service according to the proxy service creation request, as long as the creation of the target proxy service can be realized. For example, after the proxy service creation request is acquired, the K8s cluster underlying kube-apiserver interface can be called to create the target proxy service according to the proxy service creation request through the kube-api server interface.

[0065] In S120, the proxy service type of the target proxy service is determined, and the substitute proxy service of the target proxy service is determined according to the proxy service type.

[0066] The proxy service type can be the type of the proxy service, for example, the proxy service type with its own IP address, or the proxy service type without its own IP address, and the like, and the embodiment of the present application does not limit this. The substitute proxy service can be a proxy service that can replace the target proxy service.

[0067] It should be noted that the embodiment of the present application does not limit the specific implementation manner of determining the proxy service type of the target proxy service, as long as the proxy service type of the target proxy service can be realized. For example, the proxy service type of the target proxy service can be determined according to the clusterIP parameter in the proxy service creation request.

[0068] In the embodiment of the present application, after the target proxy service is created according to the proxy service creation request, the proxy service type of the target proxy service can be further determined to determine the substitute proxy service of the target proxy service according to the proxy service type. It can be understood that in the same VPC network, the containers in the K8s cluster and the external devices outside the cluster cannot communicate through the SVC in the K8s cluster, so the substitute proxy service of the target proxy service can be determined to realize the communication between the containers in the cluster and the external devices outside the cluster in the same VPC network through the substitute proxy service.

[0069] In S130, the data communication request is responded through the substitute proxy service in the case that the data communication request is received, wherein the data communication request is a data request between the external devices and the cluster containers in the same network.

[0070] The data communication request can be a data request for communication, for example, an access request, and the like, and the embodiments of the present application do not limit the same. The same network can be the same VPC network. The cluster external device can be a virtual machine device outside the K8s cluster, or a physical machine device outside the K8s cluster, and the embodiments of the present application do not limit the same. The cluster container can be a container in the K8s cluster.

[0071] In the embodiments of the present application, after the alternative proxy service of the target proxy service is determined according to the proxy service type, the data communication request can be further responded through the alternative proxy service when the data communication request is received, so as to realize the data communication between the cluster external device and the cluster container in the same network.

[0072] The technical scheme of the present embodiment, by obtaining a proxy service creation request, creating a target proxy service according to the proxy service creation request, determining the proxy service type of the target proxy service, and determining the alternative proxy service of the target proxy service according to the proxy service type, so as to respond to the data communication request through the alternative proxy service when the data communication request is received, solves the problem of high cost and difficult maintenance caused by modifying the source code in the prior art, and can realize the communication between the cluster external device and the cluster container in the same VPC network, thereby reducing the labor cost and improving the maintainability of the system.

[0073] Embodiment Two

[0074] Figure 2 is a flowchart of a data communication method provided by the second embodiment of the present application, and the present embodiment is a further refinement of the above-mentioned technical solutions, and gives a plurality of specific optional implementation manners for determining the alternative proxy service of the target proxy service according to the proxy service type, and responding to the data communication request through the alternative proxy service. The technical scheme in the present embodiment can be combined with each optional scheme in one or more of the above-mentioned embodiments. As shown in the above-mentioned flowchart, the method can include the following steps: Figure 2

[0075] S210, obtaining a proxy service creation request, and creating a target proxy service according to the proxy service creation request.

[0076] S220, determining the proxy service type of the target proxy service.

[0077] S230, in the case where the proxy service type is determined to be a normal proxy service type, determining a current network identifier.

[0078] ​The common proxy service type can be a type of common proxy service. The common proxy service can be a proxy service with an IP address. It can be understood that the common proxy service is also a header proxy service, which has an IP address of its own, and the common proxy service can be accessed through the IP address. That is, the IP address of the target proxy service of the common proxy service type can be obtained by resolving the target proxy service of the common proxy service type. The current network identifier can be an identifier of a VPC network in which the current K8s cluster is located. It can be understood that the current network identifier can uniquely identify the current network.

[0079] In the embodiments of the present application, after determining the proxy service type of the target proxy service, the current network identifier can be further determined when the proxy service type is a common proxy service type.

[0080] S240, creating a load balancing service according to the target proxy service and the current network identifier.

[0081] The load balancing service can be a service that can balance and distribute received data communication requests to a load. It can be understood that the load can be a container in the K8s cluster.

[0082] In the embodiments of the present application, after determining the current network identifier, the load balancing service can be further created according to the target proxy service and the current network identifier. It can be understood that the IP address of the current network can be determined according to the current network identifier, so as to create the load balancing service according to the target proxy service and the IP address of the current network, so that the load balancing service can be in the same network segment as the current network. Optionally, creating the load balancing service according to the target proxy service and the current network identifier can include calling a vpc-api interface to create the load balancing service according to the target proxy service and the current network identifier through the vpc-api interface.

[0083] S250, updating a first data structure of the target proxy service according to the load balancing service, and determining the substitute proxy service according to a first data structure update result.

[0084] The first data structure can be a data structure of the target proxy service of the common proxy service type. It can be understood that the data structure of the target proxy service can be determined after the target proxy service is created according to the proxy service creation request. The first data structure update result can be a new data structure obtained after the first data structure is updated.

[0085] In the embodiment of the present application, after the load balancing service is created according to the target proxy service and the current network identifier, the first data structure of the target proxy service can be further updated according to the load balancing service to determine the substitute proxy service according to the update result of the first data structure.

[0086] The above technical solution proposes a specific application scenario of the proxy service type being the ordinary proxy service type, so as to determine the substitute proxy service of the target proxy service of the ordinary proxy service type, thereby improving the reliability of communication between the cluster external device and the cluster container in the same VPC network.

[0087] Optionally, updating the first data structure of the target proxy service according to the load balancing service can include: determining the IP address corresponding to the load balancing service; and updating the IP address corresponding to the first data structure to the IP address corresponding to the load balancing service.

[0088] Specifically, after the load balancing service is created according to the target proxy service and the current network identifier, the IP address corresponding to the load balancing service can be further determined to update the IP address corresponding to the first data structure to the IP address corresponding to the load balancing service.

[0089] The above technical solution proposes a specific implementation manner of updating the first data structure of the target proxy service according to the load balancing service, which can more accurately update the first data structure of the target proxy service.

[0090] Optionally, after the first data structure of the target proxy service is updated according to the load balancing service, the update result of the first data structure can be stored in a database for display to a user.

[0091] S260, in a case where the proxy service type is determined to be the headless proxy service type, a second data structure of the target proxy service is determined, and the substitute proxy service is determined according to the second data structure.

[0092] The headless proxy service type can be the type of headless proxy service. The headless proxy service can be a proxy service without an assigned IP address. It can be understood that the IP addresses of all containers managed by the target proxy service of the headless proxy service type can be obtained by parsing the target proxy service of the headless proxy service type. The second data structure can be the data structure of the target proxy service of the headless proxy service type.

[0093] In the embodiments of the present application, after determining the proxy service type of the target proxy service, the second data structure of the target proxy service can be further determined when the proxy service type is a headless proxy service type, so as to determine the substitute proxy service according to the second data structure. Optionally, after determining the second data structure of the target proxy service, the second data structure can be stored in the database for display to the user.

[0094] The above technical solution proposes a specific application scenario of the proxy service type being a headless proxy service type, so as to determine the substitute proxy service of the target proxy service of the headless proxy service type, thereby improving the reliability of communication between the cluster external device and the cluster container under the same VPC network.

[0095] Optionally, after determining the substitute proxy service of the target proxy service according to the proxy service type, the K8s cluster underlying kube-api server interface can be further called to delete the target proxy service through the kube-apiserver interface.

[0096] S270, in the case of receiving a data communication request, responding to the data communication request through the substitute proxy service.

[0097] Optionally, responding to the data communication request through the substitute proxy service can include: in the case of determining that the data communication request includes the service IP address of the substitute proxy service, responding to the data communication request through the substitute proxy service according to the service IP address.

[0098] The service IP address can be the IP address of the substitute proxy service. It can be understood that if the data communication request includes the service IP address of the substitute proxy service, it means that the proxy service type of the target proxy service corresponding to the substitute proxy service is a normal proxy service type.

[0099] Specifically, after receiving the data communication request, the service IP address of the proxy service can be further included in the data communication request, and the data communication request can be responded to by the proxy service according to the service IP address. It can be understood that there can be multiple proxy services before receiving the data communication request, and each proxy service can manage containers in multiple K8s clusters. After receiving the data communication request, if the service IP address is included in the data communication request, the service IP address in the data communication request can be compared with the IP address corresponding to each proxy service for consistency to determine the proxy service whose IP address is consistent with the service IP address, so that the data communication request is forwarded to the container managed by the proxy service. That is, if the service IP address in the data communication request is the IP address of the proxy service, it means that the service IP address is consistent with the IP address of the proxy service, and the data communication request can be responded to by the proxy service.

[0100] The above technical solution proposes an application scenario in which the data communication request includes the service IP address of the proxy service, so that the data communication request can be responded to by the proxy service according to the service IP address in the data communication request, thereby enabling the communication between the external device and the container in the cluster in the same VPC network to be realized by the proxy service when the data communication request includes the service IP address of the proxy service.

[0101] Optionally, after creating the target proxy service according to the proxy service creation request, the target proxy service corresponding service internal network resolution record can be created according to the target proxy service, and the target proxy service corresponding service attribute information can be determined according to the service internal network resolution record. Correspondingly, responding to the data communication request by the proxy service can include: in the case where the data communication request includes the target proxy service corresponding service attribute information, responding to the data communication request by the proxy service according to the service attribute information; wherein the service internal network resolution record can include a first type internal network resolution record and / or a second type internal network resolution record; the service attribute information includes service domain name information and / or service port information.

[0102] The service internal network resolution record can be an internal network resolution record corresponding to the target proxy service. The first type of internal network resolution record can be a type of internal network resolution record, for example, can be an internal network resolution record of type A, and the like. The present embodiment does not limit the second type of internal network resolution record. The second type of internal network resolution record can be another type of internal network resolution record, for example, can be an internal network resolution record of type SRV, and the like. The present embodiment does not limit the service attribute information. The service attribute information can be attribute information corresponding to the target proxy service, for example, can be domain name information of the target proxy service, or can be port information of the target proxy service, and the like. The present embodiment does not limit the service domain name information. The service domain name information can be domain name information of the target proxy service. The service port information can be port information of the target proxy service.

[0103] Specifically, after creating the target proxy service according to the proxy service creation request, the service internal network resolution record corresponding to the target proxy service can be further created according to the target proxy service, and the service attribute information corresponding to the target proxy service is determined according to the service internal network resolution record, so that when the service attribute information corresponding to the target proxy service is included in the data communication request, the surrogate proxy service responds to the data communication request according to the service attribute information. Optionally, creating the service internal network resolution record corresponding to the target proxy service according to the target proxy service can include calling a vpc-api interface to create the service internal network resolution record corresponding to the target proxy service according to the target proxy service through the vpc-api interface.

[0104] It can be understood that there can be multiple surrogate proxy services before receiving the data communication request. After receiving the data communication request, if the service attribute information is included in the data communication request, the service attribute information in the data communication request can be compared with the attribute information of each surrogate proxy service for consistency, to determine the surrogate proxy service whose attribute information is consistent with the service attribute information, so that the data communication request is forwarded to the container managed by the surrogate proxy service through the surrogate proxy service. That is, if the service attribute information in the data communication request is the attribute information of the target proxy service, it means that the service attribute information is consistent with the attribute information of the surrogate proxy service corresponding to the target proxy service, and the data communication request can be responded through the surrogate proxy service.

[0105] Optionally, when the proxy service type of the target proxy service is a normal proxy service type, the service internal network resolution record corresponding to the target proxy service can be a first type of internal network resolution record. When the proxy service type of the target proxy service is a headless proxy service type, the service internal network resolution record corresponding to the target proxy service can be a first type of internal network resolution record, a second type of internal network resolution record, or a first type of internal network resolution record and a second type of internal network resolution record. The present embodiment does not limit the service attribute information.

[0106] The technical solution described above creates a service-intranet resolution record corresponding to the target proxy service, and determines service attribute information according to the service-intranet resolution record, so that when the service attribute information is included in the data communication request, the data communication request is responded to by the substitute proxy service according to the service attribute information, thereby enabling the communication between the cluster external device and the cluster container in the same VPC network to be realized by the substitute proxy service when the service attribute information is included in the data communication request.

[0107] Optionally, after determining the substitute proxy service of the target proxy service according to the proxy service type, the method can further include: in the case of listening to a container new event, determining a first substitute proxy service corresponding to the new container, and adding the new container to a member list of the first substitute proxy service; in the case of listening to a container destruction event, determining a second substitute proxy service corresponding to the destroyed container, and removing the destroyed container from the member list of the second substitute proxy service.

[0108] The container new event can be an event of a new container. The new container can be a newly created container. The first substitute proxy service can be a substitute proxy service for managing the new container. The member list of the first substitute proxy service can be a list of all containers managed by the substitute proxy service for managing the new container. The container destruction event can be an event of a destroyed container. The destroyed container can be a destroyed container. The second substitute proxy service can be a substitute proxy service for managing the destroyed container. The member list of the second substitute proxy service can be a list of all containers managed by the substitute proxy service for managing the destroyed container.

[0109] Specifically, after determining the substitute proxy service of the target proxy service according to the proxy service type, the container new event and the container destruction event can be further listened to. When the container new event is listened to, the first substitute proxy service corresponding to the new container is determined to add the new container to the member list of the first substitute proxy service. When the container destruction event is listened to, the second substitute proxy service corresponding to the destroyed container is determined to remove the destroyed container from the member list of the second substitute proxy service. Optionally, the container new event and the container destruction event can be listened to by the watch mode of the K8s client (client). Another optional way is to determine the first substitute proxy service corresponding to the new container by the label (label) method, and to determine the second substitute proxy service corresponding to the destroyed container by the label method.

[0110] The technical solution increases the supplementary processing strategy of the monitoring event, that is, when the container creation event is monitored, the newly created container is added to the member list of the corresponding surrogate service, and when the container destruction event is monitored, the destroyed container is deleted from the member list of the corresponding surrogate service, so that the container managed by the surrogate service can be added or deleted in time, and the reliability of communication is further improved.

[0111] Optionally, after adding the newly created container to the member list of the first surrogate service, the container internal network resolution record of the newly created container can be obtained, and the container domain name information of the newly created container can be determined according to the container internal network resolution record; in the case that the container domain name information of the newly created container is included in the data communication request, the data communication request is responded according to the container domain name information.

[0112] Optionally, after adding the newly created container to the member list of the first surrogate service, the container internal network resolution record of the newly created container can be obtained, and the container domain name information of the newly created container can be determined according to the container internal network resolution record; in the case that the container domain name information of the newly created container is included in the data communication request, the data communication request is responded according to the container domain name information.

[0113] Optionally, after adding the newly created container to the member list of the first surrogate service, the container internal network resolution record of the newly created container can be obtained, and the container domain name information of the newly created container can be determined according to the container internal network resolution record; in the case that the container domain name information of the newly created container is included in the data communication request, the data communication request is responded according to the container domain name information.

[0114] It can be understood that each surrogate service can manage multiple containers, and each container can have its corresponding internal network resolution record. If the container domain name information is included in the data communication request, the container domain name information in the data communication request can be compared with the internal network resolution record of each container for consistency, to determine the container consistent with the container domain name information, so as to respond to the data communication request through the container. That is, if the container domain name information in the data communication request is the domain name information of the newly created container, the newly created container can be determined through the container domain name information, so as to respond to the data communication request through the newly created container.

[0115] The technical solution obtains the container internal network resolution record of the newly created container, and determines the container domain name information of the newly created container according to the container internal network resolution record, so as to respond to the data communication request according to the container domain name information when the container domain name information is included in the data communication request, thereby enabling the communication between the cluster external device and the cluster container under the same VPC network when the container domain name information is included in the data communication request.

[0116] Optionally, after removing the destroyed container from the member list of the second surrogate service, the internal network resolution record corresponding to the destroyed container can be further deleted.

[0117] Optionally, after removing the destroyed container from the member list of the second surrogate service, the internal network resolution record corresponding to the destroyed container can be further deleted.Figure 3 is a container new creation and destruction event execution logic schematic diagram provided by the second embodiment of the present application, as shown in Figure 3 As shown, the new creation and destruction events of the pod (container) are listened to through the watch mode of the k8s client, and the newly created pod is found through the label mode to correspond to the load balancing service, added to the member of the corresponding listener, and then written into the internal network resolution record of type A. The destroyed pod is found through the label mode to correspond to the load balancing service, deleted from the member in the corresponding listener, and the corresponding internal network resolution record is deleted.

[0118] The technical scheme of the embodiment, by obtaining a proxy service creation request, creating a target proxy service according to the proxy service creation request, and determining the proxy service type of the target proxy service, determines the current network identifier when the proxy service type is a normal proxy service type, and creates a load balancing service according to the target proxy service and the current network identifier, updates the first data structure of the target proxy service according to the load balancing service, and determines the replacement proxy service according to the first data structure update result; or when the proxy service type is a headless proxy service type, determine the second data structure of the target proxy service, and determine the replacement proxy service according to the second data structure, so as to respond to the data communication request through the replacement proxy service when receiving the data communication request, solve the problem of high cost and difficult maintenance caused by modifying the source code in the prior art, and realize the communication between the cluster external equipment and the cluster container in the same VPC network, thereby reducing the artificial cost and improving the maintainability of the system.

[0119] Embodiment three

[0120] In order for those skilled in the art to better understand the data communication method of the embodiment, a specific example is used to illustrate, Figure 4 is a timing diagram of a normal proxy service creation provided by the third embodiment of the present application, Figure 5 is a timing diagram of a headless proxy service creation provided by the fourth embodiment of the present application, as shown in Figure 4 , 5 The method can specifically include:

[0121] (1) Through the Service related operation interface of kube-external proxy kube-apiserver. Since the native SVC resource object of the K8s cluster has many properties, when kube-external receives a Service creation request, the underlying kube-apiserver real interface is called to create a native SVC.

[0122] (2) If the native SVC is a common SVC, a vpc-api interface is directly called to create an LB (load balancing service) and an internal network resolution record of type A, and the IP in the json content returned by creating the native SVC is replaced, finally the native SVC created by the K8s underlying is deleted, and the modified json content is stored in the database.

[0123] (3) If the native SVC is a headless SVC, a vpc-api interface is called to create an internal network resolution record of type A and type SRV, the json content returned by creating the native SVC is stored in the database, and the native SVC created by the K8s underlying is deleted.

[0124] (4) When receiving an access request, the native SVC in the K8s cluster is replaced by the LB or the internal network resolution record to respond to the access request.

[0125] The above technical solution uses the LB and the internal network resolution to replace the K8s native Service by the way of intercepting the kube-apiserver interface through the kube-external as a proxy, so that the network of the container deployment application and the virtual machine and the physical machine deployment application is communicated, thereby achieving the effect that the containers, the virtual machines and the physical machines intercommunicate under the same VPC.

[0126] Embodiment Four

[0127] Figure 6 is a schematic diagram of a data communication device provided by an embodiment of the application, as shown in Figure 6 The device includes a target proxy service creation module 610, a substitute proxy service determination module 620, and a data communication request response model 630, wherein:

[0128] The target proxy service creation module 610 is configured to obtain a proxy service creation request and create a target proxy service according to the proxy service creation request.

[0129] The substitute proxy service determination module 620 is configured to determine a proxy service type of the target proxy service and determine a substitute proxy service of the target proxy service according to the proxy service type.

[0130] The data communication request response model 630 is configured to respond to a data communication request through the substitute proxy service when the data communication request is received, wherein the data communication request is a data request between a cluster external device and a cluster container under the same network.

[0131] The technical scheme of the embodiment is that a target proxy service is created according to a proxy service creation request, a proxy service type of the target proxy service is determined, a substitute proxy service of the target proxy service is determined according to the proxy service type, and the substitute proxy service is used to respond to a data communication request when the data communication request is received, so that the problem of high cost and difficult maintenance caused by modifying source code in the prior art is solved, the communication between a cluster external device and a cluster container in the same VPC network is implemented, the manual cost is reduced, and the maintainability of the system is improved.

[0132] Optionally, the substitute proxy service determination module 620 can be specifically configured to: in a case where the proxy service type is determined as the normal proxy service type, determine a current network identifier; create a load balancing service according to the target proxy service and the current network identifier; and update the first data structure of the target proxy service according to the load balancing service, and determine the substitute proxy service according to an update result of the first data structure.

[0133] Optionally, the substitute proxy service determination module 620 can be further configured to: determine an IP address corresponding to the load balancing service; and update the IP address corresponding to the first data structure to the IP address corresponding to the load balancing service.

[0134] Optionally, the substitute proxy service determination module 620 can be further configured to: in a case where the proxy service type is determined as the headless proxy service type, determine a second data structure of the target proxy service, and determine the substitute proxy service according to the second data structure.

[0135] Optionally, the data communication request response model 630 can be specifically configured to: in a case where the data communication request includes a service IP address of the substitute proxy service, respond to the data communication request according to the service IP address through the substitute proxy service.

[0136] Optionally, the target proxy service creation module 610 can be further configured to: after the target proxy service is created according to the proxy service creation request, create a service intranet resolution record corresponding to the target proxy service according to the target proxy service, and determine service attribute information corresponding to the target proxy service according to the service intranet resolution record; and correspondingly, the data communication request response model 630 can be specifically configured to: in a case where the data communication request includes the service attribute information corresponding to the target proxy service, respond to the data communication request according to the service attribute information through the substitute proxy service; wherein the service intranet resolution record includes a first type intranet resolution record and / or a second type intranet resolution record; and the service attribute information includes service domain name information and / or service port information.

[0137] Optionally, the alternative proxy service determining module 620 can also be specifically configured to: in the case of listening to a container creation event, determine a first alternative proxy service corresponding to the created container, and add the created container to a member list of the first alternative proxy service; in the case of listening to a container destruction event, determine a second alternative proxy service corresponding to the destroyed container, and remove the destroyed container from the member list of the second alternative proxy service.

[0138] Optionally, the data communication request response model 630 can also be specifically configured to: obtain a container intranet resolution record of the created container, and determine container domain name information of the created container according to the container intranet resolution record; in the case of including the container domain name information of the created container in the data communication request, respond to the data communication request according to the container domain name information.

[0139] The data communication device provided by the embodiment of the application can execute the data communication method provided by any embodiment of the application, and has the corresponding function modules and beneficial effects of the execution method.

[0140] Embodiment five

[0141] Figure 7 A structural schematic diagram of an electronic device 10 that can be used to implement embodiments of the application is shown. The electronic device is intended to represent various forms of digital computers, such as laptops, desktops, tablets, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular telephones, smart phones, wearable devices (e.g., headsets, glasses, watches, etc.), and other similar computing devices. The components shown here, their connections and relationships, and their functions, are meant to be examples only, and are not intended to limit the implementations of the applications described and / or claimed in this document.

[0142] As shown in Figure 7 The electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., which are communicatively connected to the at least one processor 11, wherein the memory stores a computer program executable by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or loaded from the storage unit 18 into the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0143] A plurality of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network, such as the Internet, and / or various telecommunication networks.

[0144] The processor 11 can be various general and / or special purpose processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 performs various methods and processes described above, such as the data communication method.

[0145] In some embodiments, the data communication method can be implemented as a computer program tangibly embodied in a computer readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded onto the RAM 13 and executed by the processor 11, one or more steps of the data communication method described above can be performed. Alternatively, in other embodiments, the processor 11 can be configured to perform the data communication method by any other appropriate means, such as by means of firmware.

[0146] Various implementations of the systems and techniques described above can be realized in digital electronic circuitry, integrated circuitry, a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on a chip (SOC), a programmable logic device (PLD), a computer hardware, firmware, software, and / or combinations thereof. These various implementations can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.

[0147] Computer programs for implementing the methods of the present application can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer program, when executed, can cause instructions defined in the flow charts and / or block diagrams to be implemented. The computer program can be executed entirely on a machine, partially on a machine, partially on a machine as a stand-alone software package and partially on a remote machine or entirely on a remote machine or server.

[0148] In the context of the present application, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. A computer-readable storage medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium can be a machine-readable signal medium. More specific examples of a machine-readable storage medium will include one or more lines of a program of instructions in a transitory signal, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0149] To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.

[0150] The systems and techniques described herein can be implemented in a computing system that includes a back end component, e.g., as a data server, or that includes a middleware component, e.g., an application server, or that includes a front end component, e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described herein, or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication, e.g., a communication network. Examples of communication networks include a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0151] The computing system can include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. A server can be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system, to solve the defects of large management difficulty and weak business scalability in traditional physical host and VPS service.

[0152] It should be understood that the various forms of flow shown above can be re-ordered, added to, or deleted from without departing from the scope of the present disclosure. For example, the steps recited in the present disclosure can be performed in parallel, in series, or in a different order, and the present disclosure is not limited in this regard.

[0153] The specific embodiments described above are not intended to limit the scope of the present disclosure. Those skilled in the art will understand that various modifications, combinations, sub-combinations, and alternatives can be made to the specific embodiments without departing from the spirit and principles of the present disclosure. Any further modifications, equivalents, and / or alternatives come within the scope of the present disclosure as recited by the claims.

Claims

1. A method of data communication, characterized by, The method comprises the following steps: obtaining an agent service creation request and creating a target agent service according to the agent service creation request; determining the agent service type of the target agent service and determining the substitute agent service of the target agent service according to the agent service type; in the case of receiving a data communication request, responding to the data communication request through the substitute agent service; wherein the data communication request is a data request between a cluster external device and a cluster container under the same network; the same network refers to the same VPC network; wherein, according to the agent service type, the substitute agent service of the target agent service comprises: in the case of determining that the agent service type is a normal agent service type, determining the current network identifier; creating a load balancing service according to the target agent service and the current network identifier; updating the first data structure of the target agent service according to the load balancing service, and determining the substitute agent service according to the first data structure update result.

2. The method of claim 1, wherein, The first data structure of the target agent service is updated according to the load balancing service, comprising: determining the IP address corresponding to the load balancing service; updating the IP address corresponding to the first data structure to the IP address corresponding to the load balancing service.

3. The method of claim 1, wherein, The substitute agent service of the target agent service is determined according to the agent service type, comprising: in the case of determining that the agent service type is a headless agent service type, determining the second data structure of the target agent service, and determining the substitute agent service according to the second data structure.

4. The method of claim 1, wherein, The data communication request is responded to through the substitute agent service, comprising: in the case of determining that the data communication request includes the service IP address of the substitute agent service, responding to the data communication request through the substitute agent service according to the service IP address.

5. The method of claim 1, wherein, After the target agent service is created according to the agent service creation request, the method further comprises: creating a service intranet resolution record corresponding to the target agent service according to the target agent service, and determining service attribute information corresponding to the target agent service according to the service intranet resolution record; The data communication request is responded to through the substitute agent service, comprising: in the case of determining that the data communication request includes the service attribute information corresponding to the target agent service, responding to the data communication request through the substitute agent service according to the service attribute information; wherein, the service intranet resolution record comprises a first type intranet resolution record and / or a second type intranet resolution record; the service attribute information comprises service domain name information and / or service port information.

6. The method of claim 1, wherein, After the substitute agent service of the target agent service is determined according to the agent service type, the method further comprises: in the case of listening to the container new event, determining the first substitute agent service corresponding to the new container, and adding the new container to the member list of the first substitute agent service; In the case of listening to the container destruction event, a second substitute proxy service corresponding to the destroyed container is determined, and the destroyed container is removed from the member list of the second substitute proxy service.

7. The method of claim 6, wherein, After adding the newly created container to the member list of the first substitute proxy service, further comprising: Obtaining the container intranet resolution record of the newly created container, and determining the container domain name information of the newly created container according to the container intranet resolution record; In the case of including the container domain name information of the newly created container in the data communication request, responding to the data communication request according to the container domain name information.

8. A data communication device, characterized by Comprise: The target proxy service creation module is used for obtaining a proxy service creation request, and creating a target proxy service according to the proxy service creation request; The substitute proxy service determination module is used for determining the proxy service type of the target proxy service, and determining the substitute proxy service of the target proxy service according to the proxy service type; The data communication request response model is used for responding to the data communication request through the substitute proxy service in the case of receiving the data communication request; wherein the data communication request is a data request between a cluster external device and a cluster container under the same network; the same network refers to the same VPC network; The substitute proxy service determination module is specifically used for: In the case of determining that the proxy service type is a normal proxy service type, determining a current network identifier; According to the target proxy service and the current network identifier, a load balancing service is created; According to the first data structure of the target proxy service, the first data structure is updated, and the substitute proxy service is determined according to the first data structure update result.

9. An electronic device, comprising: The electronic device comprises: At least one processor; and The memory is connected in communication with the at least one processor; wherein The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the data communication method in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer instructions, and the computer instructions are used to enable the processor to execute the data communication method in any one of claims 1-7 when executed.

Citation Information

Patent Citations

  • Container communication method and device, network equipment and storage medium

    CN111885075A