WO2024055741A1 - 一种建立网络连接的方法、装置、电子设备及存储介质 - Google Patents

一种建立网络连接的方法、装置、电子设备及存储介质 Download PDF

Info

Publication number
WO2024055741A1
WO2024055741A1 PCT/CN2023/107539 CN2023107539W WO2024055741A1 WO 2024055741 A1 WO2024055741 A1 WO 2024055741A1 CN 2023107539 W CN2023107539 W CN 2023107539W WO 2024055741 A1 WO2024055741 A1 WO 2024055741A1
Authority
WO
WIPO (PCT)
Prior art keywords
application instance
application
network
excluded
network connection
Prior art date
Application number
PCT/CN2023/107539
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/589,571 priority Critical patent/US20240205297A1/en
Publication of WO2024055741A1 publication Critical patent/WO2024055741A1/zh

Links

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/14Session management
    • H04L67/141Setup of application sessions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/143Termination or inactivation of sessions, e.g. event-controlled end of session

Definitions

  • the present application relates to the field of network technology, and in particular, to a method, device, electronic device and storage medium for establishing a network connection.
  • network connections can usually be made by calling external service interfaces.
  • external service interfaces For example, when the network environment of service network 1 is different from the network environment of service network 2, you can call Through the external service interface, the network connection between service network 1 and service network 2 is established.
  • Embodiments of the present application provide a method, device, electronic device, and storage medium for establishing a network connection, so as to reduce resource consumption in establishing a network connection and improve scalability.
  • an embodiment of the present application provides a method for establishing a network connection, including:
  • the controller selects the optional application instances corresponding to each optional tag from the preset original application instances based on each optional tag carried by the created network connection object, and based on the optional tags carried by the network connection object,
  • the indication information to be excluded is used to filter out the application instances to be excluded from the original application instances;
  • the controller deletes the corresponding optional application instance from each optional application instance based on the filtered application instances to be excluded, and obtains each candidate application instance associated with the first service network and the second service network;
  • the controller selects each target application instance that meets the preset operating conditions from each candidate application instance based on the corresponding running status of each candidate application instance;
  • the controller establishes a network connection between the first service network and the second service network based on the target application instances.
  • embodiments of the present application provide a device for establishing a network connection, including:
  • the first screening module is used to filter out the optional application instances corresponding to each optional tag from the preset original application instances based on each optional tag carried by the created network connection object, and, based on the Use the indication information to be excluded carried by the network connection object to filter out the application instances to be excluded from the original application instances;
  • a determination module configured to delete the corresponding optional application instances from the optional application instances based on the filtered application instances to be excluded, and obtain each candidate application instance associated with the first service network and the second service network;
  • the second screening module is configured to filter out each target application instance that meets the preset operating conditions from each candidate application instance based on the corresponding running status of each candidate application instance;
  • An establishment module configured to establish a network connection between the first service network and the second service network based on each of the target application instances.
  • embodiments of the present application provide an electronic device, which includes a processor and a memory, wherein the memory stores program code.
  • the processor When the program code is executed by the processor, the processor is caused to execute the above The steps for any method of establishing a network connection.
  • embodiments of the present application provide a computer storage medium that stores computer instructions.
  • the computer instructions When the computer instructions are run on a computer, they cause the computer to perform the steps of any of the above methods for establishing a network connection.
  • embodiments of the present application provide a computer program product, which includes computer instructions, and the computer instructions are stored in a computer-readable storage medium; when a processor of an electronic device reads the instructions from the computer-readable storage medium, When a computer instruction is issued, the processor executes the computer instruction, so that the electronic device performs the steps of any of the above methods for establishing a network connection.
  • the controller selects the optional application instances corresponding to each optional tag from the preset original application instances based on each optional tag carried by the created network connection object, and based on the network connection object
  • the carried indication information to be excluded is used to filter out application instances to be excluded from each original application instance, and the controller deletes the corresponding optional application instance from each optional application instance based on the filtered application instances to be excluded.
  • obtain each candidate application instance associated with the first service network and the second service network and the controller filters out the candidate application instances that meet the preset operating conditions based on the corresponding running status of each candidate application instance.
  • the controller establishes a network connection between the first service network and the second service network based on each target application instance.
  • each optional application instance can be filtered out through each optional label, each application instance to be excluded can be filtered out through the indication information to be excluded, and each application instance to be excluded can be deleted from each optional application instance, thereby obtaining
  • Each candidate application instance and based on the corresponding running status of each candidate application instance, determines each target application instance, thereby establishing a network connection based on each target application instance, without using an external service interface, the first service network and the second service network can be established
  • Network connections between service networks can use simple implementation logic to realize network connections even in very complex network environments, which not only reduces the resource consumption of network connections, but also improves scalability.
  • Figure 1 is a schematic diagram of the application scenario in the embodiment of the present application.
  • Figure 2A is a schematic flowchart of establishing a network connection in an embodiment of the present application
  • Figure 2B is an example diagram of determining candidate application instances in the embodiment of the present application.
  • Figure 2C is an example diagram of determining application instances to be excluded in the embodiment of the present application.
  • Figure 2D is an example diagram of deleting candidate application instances in the embodiment of the present application.
  • Figure 2E is an example diagram of determining a target application instance in an embodiment of the present application.
  • Figure 2F is an example diagram of providing network services in this embodiment of the present application.
  • Figure 3 is a schematic flowchart of determining a target application instance in an embodiment of the present application
  • Figure 4 is a schematic flowchart of deleting a network connection in an embodiment of the present application.
  • Figure 5 is a schematic diagram of the system in the embodiment of the present application.
  • Figure 6 is an interactive flow chart for establishing a network connection in an embodiment of the present application.
  • Figure 7 is an interactive flow chart for deleting a network connection in an embodiment of the present application.
  • Figure 8 is a schematic structural diagram of a device for establishing a network connection in an embodiment of the present application.
  • FIG. 9 is a schematic structural diagram of a hardware structure of an electronic device applying an embodiment of the present application.
  • An application instance can be a pod.
  • a pod is the smallest deployable computing unit created and managed in k8s. It is a collection of applications used to provide network services to the first service network and the second service network.
  • Service network represents an isolated network that can provide services. For example, the first service network and the second service network are isolated from each other.
  • Probe configuration status Indicates whether the candidate application instance is configured with probes.
  • the probe configuration status can be divided into configured and unconfigured.
  • the probe configuration status is configured to indicate that the candidate application instance is configured with probes.
  • the probe configuration status No probe is configured for the unconfigured characterization candidate application instance.
  • the probe is used to obtain the detection results of whether the candidate application instance is in a state that can provide network services normally.
  • Probe detection results used to characterize the detection results corresponding to the candidate application instances determined by the probe, and used to determine whether the candidate application instances are in a normal state of providing network services.
  • the probe detection results include success, failure, and unknown.
  • the probe detection results include success, failure, and unknown.
  • the detection result is successful, which means that the candidate application instance is in the normal state of providing network services, and the candidate application instance can provide normal network services.
  • the probe detection result is failure, which means that the candidate application instance is not in the normal state of providing network services, and the candidate application instance cannot provide normal network services.
  • the probe detection result is unknown, which indicates that the candidate application instance itself made an error during operation and cannot know the availability of the network service.
  • Tuning To complete the tuning of a certain type of resource, the goal is to maintain the state expected by the user.
  • Custom resource used to extend and implement custom logic. In the embodiment of this application, it is used to implement scalable network connection definition and status.
  • Finalizer An attribute of the network connection object in k8s, which can prevent the network connection object from being actually deleted and keep it stuck in the Terminating state. The network connection object will not be actually deleted until the Finalizer is removed.
  • the method of calling an external service interface can be used to realize the network connection between each network service. For example, when the network environment of service network 1 and the network of service network 2 When the environments are different, the network connection between service network 1 and service network 2 can be established by calling the external service interface.
  • the network connection method in the related technology can only support four types of network connections, namely ClusterIP, NodePort, LoadBalancer, and ExternalName.
  • ClusterIP Expose the service through the internal IP of the cluster. When this value is selected, the service can only be accessed within the cluster. This is also the default ServiceType.
  • NodePort Expose services through the IP and static port (NodePort) on each node.
  • the NodePort service will be routed to the automatically created ClusterIP service. You can access a NodePort service from outside the cluster by requesting ⁇ node IP>: ⁇ node port>.
  • LoadBalancer Use the cloud provider's load balancer to expose services to the outside.
  • the external load balancer can route traffic to the automatically created NodePort service and ClusterIP service.
  • ExternalName By returning the CNAME and the corresponding value, the service can be mapped to the content of the externalName field (for example, foo.bar.example.com). No need to create any kind of proxy.
  • embodiments of the present application provide a method, device, electronic device and storage medium for establishing a network connection.
  • each optional application instance can be filtered out, and through the indication information to be excluded, Filter out each application instance to be excluded and delete each application instance to be excluded from each optional application instance, thereby obtaining each candidate application instance, and determine each target application instance based on the corresponding running status of each candidate application instance, thereby Establishing network connections based on each target application instance can enhance scalability and reduce network resource consumption.
  • FIG. 1 is a schematic diagram of an application scenario in an embodiment of the present application.
  • the application scenario diagram includes the controller 110 and each service network 120.
  • the controller 110 and each service network 120 may communicate through a communication network.
  • the controller 110 may include one or more processors, memories, I/O interfaces that interact with the service network 120, and the like.
  • the controller 110 can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or it can provide cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, and cloud communications. , middleware services, domain name services, security services, content delivery network (Content Delivery Network, CDN), and cloud servers for basic cloud computing services such as big data and artificial intelligence platforms.
  • the controller 110 and each service network 120 may be connected directly or indirectly through wired or wireless communication methods, which are not limited in this embodiment of the present application.
  • Each service network 120 is used to provide network services.
  • the method of establishing a network connection in the embodiment of the present application can be performed on the controller 110 .
  • the controller 110 filters out each optional application instance through each optional label, filters out each application instance to be excluded through the indication information to be excluded, and removes each application instance to be excluded from each Delete from the optional application instances, thereby obtaining each candidate application instance, and determine each target application instance based on the corresponding running status of each candidate application instance, so that based on each target application instance, between the first service network and the second service network Establish a network connection.
  • the methods in the embodiments of this application can be applied to cloud native scenarios.
  • cloud native technology With the development of cloud native technology, more and more services are moving to the cloud to enjoy the advantages of cloud native.
  • One of the problems that needs to be solved is how to access the corresponding cloud native services across network environments.
  • Related technologies usually package their own network connection services, and implement them internally by calling external network services. All implementations are outside cloud native k8s. This makes it impossible to perceive the running status of the back-end application instance in real time to dynamically maintain the application instance and ensure the high reliability of network services.
  • each optional tag carried by the created network connection object from From each preset original application instance, select the optional application instances corresponding to each optional label, and based on the indication information to be excluded carried by the network connection object, select each application instance to be excluded from each original application instance, Based on the filtered application instances to be excluded, delete the corresponding optional application instances from each optional application instance, and obtain each candidate application instance associated with the first service network and the second service network, respectively based on each candidate application instance According to their corresponding running status, each target application instance that meets the preset operating conditions is selected from each candidate application instance, and based on each target application instance, a network connection is established between the first service network and the second service network, so that Perceiving the running status of back-end application instances and dynamically maintaining application instances not only ensures high reliability of network services, but also reduces resource consumption.
  • FIG. 2A is a schematic flowchart of establishing a network connection in the embodiment of the present application.
  • the process of establishing a network connection in the embodiment of the present application is described below, which specifically includes:
  • the controller Based on each optional tag carried by the created network connection object, the controller filters out the optional application instances corresponding to each optional tag from the preset original application instances, and based on the to-be-excluded tags carried by the network connection object Instruction information is used to filter out application instances to be excluded from each original application instance.
  • the network connection request is submitted to the API server through the client, and the API server performs legality verification on the created network connection request. If it is determined that the network connection request passes the legality verification, the API server based on the network connection request Create a network connection object.
  • the controller determines the created network connection object, since the network connection object carries various optional tags, based on each optional tag, the preset original application instances are filtered out with each Each original application instance corresponding to the optional tag, each original application instance filtered out is each optional application instance, and, Since the network connection object carries indication information to be excluded, each original application instance corresponding to the indication information to be excluded can be filtered out from the preset original application instances based on the indication information to be excluded.
  • the original application instance is the application instance to be excluded.
  • the filtering instruction information includes each optional tag. Therefore, Each optional tag is matched with the preset application instance tag corresponding to each original application instance. From each original application instance, an original application instance that matches each optional tag is determined, and the determined original application instance is as corresponding optional application examples.
  • Figure 2B is an example diagram for determining optional application instances in this embodiment of the present application.
  • the application instance is a pod
  • each optional label is "app:a" and "type: foo".
  • Each original pod is original pod1, original pod2, original pod3, original pod4 and original pod5.
  • the application instance labels corresponding to original pod1 are "app:a” and “type: foo”
  • the application instance labels corresponding to original pod2 are "app :a” and “type: foo”
  • the application instance labels corresponding to the original pod3 are “app:d” and “type: foo”
  • the application instance labels corresponding to the original pod4 are "app:b” and “type: bar”
  • the application instance labels corresponding to the original pod5 are “app:a” and "type: bar”. Therefore, it is determined that the original pods that match both the optional labels "app:a” and “type: foo” are the original pod1 and the original pod2. , therefore, the original pod1 and the original pod2 are respectively regarded as optional pods.
  • the optional tags may be, for example, preset attribute tags or key-value pairs, which are not limited in the embodiments of the present application.
  • the attribute tags may be version tags, environment tags, architecture tags, partition tags, etc., which are not limited in the embodiments of this application.
  • the original application instance corresponding to the optional label may be one or multiple, that is, multiple original application instances may correspond to the same optional label, and each optional application An instance may correspond to multiple optional tags, which is not limited in the embodiments of this application.
  • the embodiment of this application provides a possible implementation method for determining each application instance to be excluded, which specifically includes:
  • the controller Based on each tag to be excluded included in the indication information to be excluded, the controller filters out application instances to be excluded corresponding to each tag to be excluded from each original application instance.
  • each tag to be excluded is matched with the preset application instance tag corresponding to each original application instance, and the original application instance that matches each tag to be excluded is determined from each original application instance.
  • the determined original application instance is used as the corresponding application instance to be excluded. In this way, the application instance to be excluded can be determined, thereby ensuring the high availability of subsequent network services.
  • the controller determines the application instance to be excluded corresponding to the corresponding first application instance identifier from each original application instance based on each first application instance identifier included in the indication information to be excluded.
  • the network connection object also carries a to-be-excluded list.
  • the to-be-excluded list includes each first application instance identifier. Based on each first application instance identifier, the corresponding to-be-excluded list of each first application instance identifier is determined.
  • FIG. 2C is an example diagram for determining an application instance to be excluded in an embodiment of the present application.
  • the application instance is a pod
  • the label to be excluded is "env:1”
  • each of the third codes included in the indication information to be excluded is
  • One application instance identifier is the first application instance identifier corresponding to pod3 to be excluded and the first application instance identifier corresponding to pod4 to be excluded.
  • the default original pods are original pod1, original pod2, original pod3, original pod4 and original pod5 respectively.
  • the application instance label corresponding to the original pod1 is “env:1”
  • the application instance label corresponding to the original pod2 is “env:1”
  • the application instance label corresponding to the original pod3 is “env:3”
  • the application instance label corresponding to the original pod4 is “env:2”
  • the application instance label corresponding to the original pod5 is “env:16”. Therefore, it is determined that the original pods matching the label "env:1" to be excluded are the original pod1 and
  • the original pod2 uses the original pod1 and the original pod2 as pods to be excluded respectively, and the pods to be excluded determined based on the first application instance identifiers contained in the indication information to be excluded are pod3 and pod4 to be excluded respectively. Therefore, Directly use the original pod3 and the original pod4 as pods to be excluded.
  • the network connection request in the embodiment of this application is created directly through the API interface or the kubectl command line. Moreover, when verifying the legality of the network connection request, the legality of the formats of each optional tag and each to-be-excluded tag included in the network connection request can be verified.
  • the kubectl command line is used to communicate with the API server, organize and convert the commands entered by the user on the command line into information supported by the API server, and then manage various k8s resources based on the kubectl command line.
  • the desired network connection object is defined in a declarative manner.
  • Network connection and define some information required for extensible network connection through ServiceLinkSource, and define a selector.
  • the selector defines a series of optional tags in the form of key-value pairs to select the optional application that is expected to be connected to.
  • Instance define the excluder.
  • the excluder is used to exclude the corresponding application instances to be excluded from the set of optional application instances selected by the Selector.
  • the current running status of the network connection object is defined in the network status of the network connection object, where the network status includes a set of application instances to be excluded, a set of application instances that can provide services, and a set of application instances that cannot be provided.
  • the to-be-excluded application instance collection contains the excluded to-be-excluded application instances.
  • the service-providing application instance collection contains each target application instance.
  • the non-service-providing application instance collection contains all target application instances. Candidate application instances of the target application instance.
  • the probe-free application instance collection includes application instances that are not configured with probes.
  • a possible implementation method for screening out each candidate application instance.
  • the process of determining each candidate application instance in the embodiment of the present application is described below, which specifically includes:
  • Each candidate application instance includes: a collection of containers that provide network services to the first service network and the second service network.
  • the corresponding optional application instance is deleted from each optional application instance, and the corresponding optional application instance associated with the first service network and the second service network is obtained. Examples of each candidate application.
  • each filtered application instance to be excluded based on the application instance identifier corresponding to an application instance to be excluded, match it with the application instance identifier corresponding to each optional application instance, and determine For optional application instances that have the same application instance identifier as each application instance to be excluded, the determined optional application instance will be deleted from each optional application instance, thereby obtaining each candidate associated with the first service network and the second service network.
  • Application instances After obtaining each candidate application instance, you can obtain each candidate application instance from the API server through the informer mechanism of k8s.
  • this embodiment of the present application provides a possible implementation manner for obtaining each candidate application instance associated with the first service network and the second service network.
  • the following is the process of obtaining each candidate application instance in this embodiment of the present application.
  • the controller For each application instance to be excluded, the controller performs the following operations respectively: based on the second application instance identification corresponding to an application instance to be excluded, if it is determined that an application instance to be excluded is included in each optional application instance, then from each available application instance Among the selected application instances, delete the optional application instance corresponding to the second application instance identifier;
  • the controller uses the remaining optional application instances as candidate application instances.
  • the application instance identifier corresponding to an application instance to be excluded is matched with the application instance identifiers corresponding to each optional application instance, and it is determined whether an application instance identifier having the same application instance identifier as an application instance to be excluded can be matched.
  • Optional application instances if it is determined that one application instance to be excluded is determined from each optional application instance
  • Figure 2D is an example of deleting an optional application instance in the embodiment of the present application.
  • the application instance is a pod
  • the corresponding pod identifiers of each pod to be excluded are pod1 and pod2 respectively.
  • the corresponding pod identifiers of each optional pod are The pod identifiers are pod2, pod4, pod8, and pod11 respectively. Therefore, it is determined that the optional pod with the same pod identifier as the pod to be excluded is optional pod2. Therefore, the optional pod2 in each optional pod is deleted to obtain the same
  • the candidate pods associated with the first service network and the second service network are pod4, pod8, and pod11 respectively.
  • the embodiment of the present application also provides a possible implementation manner for obtaining each candidate application instance associated with the first service network and the second service network.
  • the following is the process of obtaining each candidate application instance in the embodiment of the present application.
  • the controller generates a set of application instances to be excluded including each application instance to be excluded, and generates an optional application instance set including each optional application instance.
  • each application instance to be excluded is added to the set of application instances to be excluded, thereby obtaining a set of application instances to be excluded including each application instance to be excluded, and each optional application instance is added to the optional In the application instance collection, an optional application instance collection containing each optional application instance is obtained.
  • S212 Based on the intersection between the application instance set to be excluded and the optional application instance set, the controller deletes the application instances to be excluded included in the intersection from the optional application instance set, and deletes the remaining available application instances. Select an application instance as a candidate application instance, and obtain a candidate application instance set including each candidate application instance.
  • the intersection between the set of application instances to be excluded and the set of optional application instances is determined, and then each application instance to be excluded can be excluded from each optional application instance, and the remaining optional application instances can be As a candidate application instance, a candidate application instance set including each candidate application instance is obtained.
  • S22 The controller selects each target application instance that meets the preset operating conditions from each candidate application instance based on the corresponding running status of each candidate application instance.
  • the controller determines whether a candidate application instance satisfies the preset operating conditions based on the running status corresponding to the candidate application instance. If it is determined that a candidate application instance satisfies the preset running conditions, If the running conditions are preset, a candidate application instance will be used as the target application instance.
  • each probe is obtained from the API server, and each candidate application instance may be configured There may or may not be probes configured. If it is determined that a candidate application instance is configured with a probe, it is determined that the probe configuration status corresponding to the candidate application instance is configured. Therefore, the probe configuration status corresponding to the candidate application instance can be configured. Based on the configuration status, determine whether the candidate application instance is the target application instance. The following details:
  • the first probe configuration status configured.
  • the probe configuration status corresponding to the candidate application instance is configured, based on the probe detection result in the running state, it is determined whether to use the candidate application instance as the target application instance.
  • the probe detection results can be divided into the following three types, namely success, failure and unknown.
  • the three types of probe detection results in the embodiments of the present application are described below, specifically including:
  • the first probe test result successful.
  • a candidate application instance is used as the target application instance.
  • Each probe is used to determine whether the corresponding candidate application instance is in a state of normally providing network services.
  • the following two conditions need to be met.
  • the first condition is that the probe configuration status corresponding to the candidate application instance is configured, that is, the candidate application instance is configured with a probe.
  • the second condition the probe detection result is successful, that is, the candidate application instance is in a state that can provide network services normally. Therefore, when the probe configuration status corresponding to the candidate application instance is configured, and the probe detection result is successful , the candidate application instance is used as the target application instance.
  • Figure 2E is an example diagram of determining a target application instance in an embodiment of the present application.
  • the application instance is a pod.
  • the controller reads candidate pod1 from the candidate pod set. If the probe configuration corresponding to candidate pod1 is determined If the status is configured, read the probe detection result in the running state. At this time, the probe detection result is successful, and it is determined that candidate pod1 is in a state that can provide network services normally. Therefore, candidate pod1 is used as the target pod, and then read Remove the next candidate pod and re-execute the steps to determine whether the probe configuration status is configured.
  • the second probe detection result failed.
  • the candidate application instance when the candidate application instance is not processed, the following two conditions need to be met.
  • the first condition is that the probe configuration status corresponding to the candidate application instance is configured, that is, the candidate application instance is configured with a probe.
  • the second condition is that the probe detection result is failure, that is, the candidate application instance is not in a state that can normally provide network services and cannot provide network services. Therefore, when the probe configuration status corresponding to the candidate application instance is configured, and the probe If the needle detection result is a failure, the candidate application instance will not be processed.
  • the candidate application instance when it is determined that the probe detection result is a failure, the candidate application instance is added to the set of application instances that cannot provide services. Therefore, the set of application instances that cannot provide services must at least include all services that cannot be provided. candidate application examples.
  • the third probe test result unknown.
  • the process returns to no probe configuration.
  • the candidate application instance is treated as a candidate application instance without a probe.
  • Corresponding processing that is, determining whether to use the candidate application instance as the target application instance based on its application instance running status.
  • the second probe configuration status not configured.
  • the probe configuration status corresponding to the candidate application instance is not configured, based on the running status of the application instance in the running status, it is determined whether to use the candidate application instance as the target application instance.
  • the running status of the application instance can be divided into the following two types, namely continuous running and not running normally.
  • the two running statuses of the application instance in the embodiment of this application are described below, specifically including:
  • the first application instance running status continuous running.
  • a candidate application instance is used as the target application instance.
  • the following two conditions need to be met.
  • the first condition is that the probe configuration status corresponding to the candidate application instance is not configured, that is, the candidate application instance is not configured with a probe.
  • the running status of the application instance is continuously running, that is, the candidate application instance is continuously running. Therefore, when the probe configuration status corresponding to the candidate application instance is not configured and the running status of the application instance is continuously running, Use the candidate application instance as the target application instance.
  • the controller reads candidate pod3 from the candidate pod set. If it is determined that the probe configuration status corresponding to candidate pod3 is not configured, it reads the pod running status in the running status. At this time, if Determine that the pod running status is continuous running, and determine that candidate pod3 is in a state that can provide network services normally. Therefore, use candidate pod3 as the target pod, then read the next candidate pod, and re-execute to determine whether the probe configuration status is configured. step.
  • the second application instance running status not running normally.
  • the candidate application instance when the candidate application instance is not processed, the following two conditions need to be met.
  • the first condition is that the probe configuration status corresponding to the candidate application instance is not configured, that is, the candidate application instance is not configured with a probe.
  • the second condition is that the running status of the application instance is not running normally, that is, the candidate application instance is not in a state that can normally provide network services and cannot provide network services. Therefore, when the probe configuration status corresponding to the candidate application instance is not configured , If the running status of the application instance is not running normally, the candidate application instance will not be processed.
  • failure to run normally indicates that the candidate application instance is in a state such as pending, initialization (init), error (error), etc., which is not limited in the embodiment of the present application.
  • each target application instance can be obtained, and each target application instance is an application instance that can provide services normally, ensuring the reliability of the network connection.
  • the controller can generate a set of probeless application instances, a set of application instances that can provide services, and a set of application instances that cannot provide services, specifically including:
  • A1 The controller adds each candidate application instance whose probe configuration status is unconfigured to the probe-free application instance set.
  • the following operations are performed for each candidate application instance: when it is determined that the probe configuration status corresponding to any candidate application instance is not configured, the candidate application instance is added to the probe-free application instance set.
  • A2 The controller adds each target application instance to the set of application instances that can provide services.
  • each target application instance is added to a set of application instances that can provide services, so that each target application instance is included in the set of application instances that can provide services.
  • A3 The controller adds each candidate application instance except each target application instance to the set of application instances that cannot provide services.
  • each candidate application instance except each target application instance is added to the application that cannot provide services. Collection of instances.
  • A4 The controller stores the probeless application instance set, the service-providing application instance set, and the service-unproviding application instance set into the network state.
  • a collection of probeless application instances, a collection of application instances that can provide services, and a collection of application instances that cannot provide services are stored in the network status, so that each application instance collection can be dynamically maintained and ensure the high availability of network services.
  • S23 The controller establishes a network connection between the first service network and the second service network based on each target application instance.
  • a network connection is established between the first service network and the second service network based on each target application instance.
  • the embodiment of the present application provides a possible implementation method for establishing a network connection.
  • the process of establishing a network connection in the embodiment of the present application is described below, which specifically includes:
  • S231 The controller establishes a network interface between the first service network and the second service network by calling the connection creation interface.
  • a network interface for providing network services is established between the first service network and the second service network by calling an external connection creation interface.
  • connection creation interface by calling the connection creation interface, a network interface between the first service network and the second service network is created. Only through the network interface, the first service network cannot obtain the information of the second service network. Corresponding network services need to be provided to the first service network through each target application instance, and the network services corresponding to the second service network need to be provided to the first service network.
  • S232 The controller provides network services of the second service network to the first service network by calling each target application instance and the network interface.
  • each target application instance is used to provide network services to the first service network
  • each target application instance is called, and the network of the second service network is provided to the first service network through the created network interface. services, thereby realizing network connections, which can avoid a lot of repetitive work of network connections in different network environments and reduce resource consumption.
  • a real network service can be created through the target application instance.
  • the network interface in the embodiment of the present application is only used to establish a network connection.
  • the implementation logic of the network interface can be the same.
  • the user can extend the network interface and inject custom implementation logic. Therefore, the network interface is scalable.
  • Figure 2F is an example diagram of providing network services in the embodiment of the present application.
  • the application instance is a pod
  • a network interface is created between the first service network and the second service network through the connection creation interface of the external service.
  • Each target pod is target pod1, target pod3, and target pod6 respectively.
  • Target pod1, target pod3, and target pod6 provide network services corresponding to the second service network to the first service network through network interfaces.
  • network services can be used declaratively, which greatly reduces the difficulty of business access to network services, while avoiding a large amount of repeated access work between different businesses, and providing a good scalable architecture. , can easily cope with different network environments and scenarios, and expand the corresponding network connection implementation. In addition, it supports high reliability of services, and combines the running status of application instances and corresponding probe detection results to ensure the high reliability of network services.
  • FIG. 3 is a schematic diagram of the process of determining the target application instance in the embodiment of the present application, which specifically includes:
  • S300 Determine whether the probe configuration status corresponding to the candidate application instance is configured. If yes, execute S301. If not, execute S304.
  • the running state corresponding to the candidate application instance includes the probe configuration state, and the probe configuration state includes configured and unconfigured.
  • the running status corresponding to the candidate application instance also includes probe detection results, and the probe detection results can be divided into success, failure, and unknown.
  • the running status corresponding to the candidate application instance also includes the application instance running status, and the application instance running status can be divided into continuous running and abnormal running.
  • the corresponding candidate application instance that can continuously provide network services can be determined from each candidate application instance, thereby ensuring that when the target application instance is used to provide network services of the second service network to the first service network , can provide network services normally and ensure normal network connection.
  • Figure 4 is a schematic flowchart of deleting a network connection in an embodiment of the present application, which specifically includes:
  • the update time is generated by updating the network connection object after the API server receives the deletion request for the network connection and sets the deletion timestamp for the network connection object to the current time.
  • the user submits a deletion request for a network connection to the API server.
  • the API server internally sets the deletion timestamp of the network connection object corresponding to the network connection to the current time, and updates the network connection object corresponding to the network connection.
  • the controller Tuning the network connection when getting the update time of the network connection object in the API server.
  • the deletion timestamp of the network connection is set to 2:10:00.
  • the network connection object corresponding to the network connection is updated, and the controller determines the network connection When the connection object is updated, the network connection is tuned.
  • the network connection is tuned to represent the deletion process of the network connection.
  • the deletion process due to the deletion process, there may be situations where the deletion process cannot be executed. Therefore, in this case, , the deletion process will be terminated.
  • the controller determines that the deletion timestamp of the network connection is the current time, and determines that the network status corresponding to the network connection is expected to be deleted.
  • the deletion timestamp is set when the deletion request is received.
  • the deletion timestamp is not empty, that is, the determined deletion timestamp of the network connection is the current time, then it is determined that the network status corresponding to the network connection is expected to be deleted.
  • the deletion timestamp of the network connection For example, assuming that the time of the deletion request submitted by the user is 2:10:00, set the deletion timestamp of the network connection to 2:10:00. During the tuning process, it is determined that the deletion timestamp corresponding to the network connection is not empty and is 2:10:00, it is determined that the network connection is expected to be deleted.
  • S42 The controller deletes the network connection.
  • the network connection when it is determined that the network status corresponding to the network connection is expected to be deleted, the network connection is deleted.
  • a possible implementation method is provided for the controller to delete the network connection.
  • the process of deleting the network connection in the embodiment of the present application is described in detail below:
  • S421 The controller deletes each network service interface corresponding to the network connection by calling the delete network interface.
  • each existing network service interface of the network connection is deleted, so that the underlying network connection is deleted.
  • S422 The controller removes the deletion interception identification corresponding to the network connection and generates a deletion instruction.
  • the deletion interception identifier corresponding to the network connection is removed and a deletion instruction is generated.
  • S423 The controller sends a deletion instruction to the API server, so that the API server deletes the network connection object created by the corresponding network connection.
  • a deletion instruction is generated, and the generated deletion instruction is sent to the API server.
  • the API server deletes the deletion instruction in response to deleting the network connection object created by the network connection.
  • the network connection can be deleted, further ensuring that the network connection can be completely deleted.
  • Figure 5 is a schematic diagram of the system in the embodiment of the present application, which specifically includes:
  • the first service network after the first service network establishes a network connection with the second service network, the first service network can use the services provided by the second service network.
  • the second service network is used to provide services to the first service network.
  • the first service network and the second service network are in different network environments, and the first service network and the second service network are isolated from each other.
  • the second service network includes pod1, pod2 and pod3, and pod1, pod2 and pod3 are all configured with probes.
  • the selector is used to filter out the optional application instances corresponding to the corresponding optional tags from the preset original application instances based on each optional tag included in the filtering instruction information.
  • the excluder is configured to filter out the application instances to be excluded corresponding to the corresponding tags to be excluded from the preset original application instances based on the tags to be excluded included in the indication information to be excluded.
  • the network resource is a module that can be implemented by personalized expansion and is used to realize reentrant creation and deletion of network connections.
  • the network resource factory is used to establish the corresponding network connection in the factory mode and delete the network connection, including creating resource 1 and creating resource 2. Both creating resource 1 and creating resource 2 are used to establish the network. connect.
  • the network resource factory in the embodiment of this application is a module that can be implemented in a personalized and extensible manner. It is only necessary to implement the Apply and Destroy methods in it to achieve reentrant creation and deletion of network connections. In this way, Subsequently, you only need to create a network connection object declaratively to easily implement network connection requests.
  • Apply is a method to create a network connection
  • Destroy is a method to delete a network connection.
  • the controller is used to interact with the API server and create or delete a network connection.
  • the API server is used to receive a network connection request and a deletion network connection request, and send the received network connection request and deletion network connection request to the controller for network connection or deletion of the network connection.
  • Figure 6 is an interactive flow chart for establishing a network connection in the embodiment of the present application, which specifically includes:
  • Step 600 The client submits a network connection request to the API server.
  • Step 601 The API server performs legality verification on the network connection request.
  • the API server performs a legality check on the network connection request. After determining that the network connection request passes the legality check, it is determined that the creation of the network connection object is allowed.
  • Step 602 After the controller determines to create the network connection object, it filters out each candidate application instance from each original application instance.
  • each optional application instance corresponding to each optional label can be determined through the selector in k8s, and each to-be-excluded application corresponding to each to-be-excluded label can be determined through the excluder in k8s. Instance, delete matching application instances to be excluded from each optional application instance, thereby obtaining each candidate application instance.
  • each optional label in the embodiment of this application can be specified in the configuration list when creating the pod, or can be added using a command after the pod is created.
  • One pod can correspond to multiple optional labels.
  • an optional label can also be attached to multiple pods.
  • the application instance in the embodiment of the present application may be a pod, which is not limited in the embodiment of the present application.
  • Step 603 Obtain each candidate application instance from the API server.
  • each candidate application instance can be obtained from the API server through the informer mechanism of k8s.
  • Informer is the code abstraction of the resource. It runs under the driver of the controller, pops the data in the Delta FIFO, and then transmits the data to the Indexer. At the same time, Informer will also distribute data to custom controllers for event processing.
  • Step 604 Obtain the probe configuration status corresponding to each candidate application instance from the API server.
  • Step 605 Based on the running status, probe configuration status, and probe detection results of each application instance, determine a set of application instances that can provide services, a set that cannot provide services, and a set of application instances without probes from each candidate application instance.
  • Step 606 Establish a network interface between the first service network and the second service network by calling the connection creation interface.
  • Step 607 Provide network services of the second service network to the first service network by calling each target application instance and network interface.
  • Step 608 Update the network status of the network connection object to the API server.
  • Body includes:
  • Step 700 The user submits a deletion request to delete the network connection to the API server.
  • Step 701 The API server internally sets the deletion timestamp of the network connection object to the current time, and updates the network connection object.
  • the network connection object after the network connection object is updated, the network connection object will be prevented from being deleted by its own deletion prevention identification.
  • the deletion prevention flag in the embodiment of this application can be the Finalizers field in k8s.
  • the Finalizers field belongs to the Kubernetes GC garbage collector and is a deletion interception mechanism that allows the controller to implement asynchronous pre-delete callbacks.
  • the Finalizers field can exist In each network connection object, during specific implementation, a deletion request for a network connection object with a Finalizer field will set its deletion timestamp to the current time, but the network connection object will not be deleted in this step. Once When the deletion timestamp is set, the value in the Finalizers field is removed.
  • each controller responsible for monitoring the network connection object will perform all the prevention deletion mechanisms to be processed by polling update requests for the network connection object.
  • all blocking deletion mechanisms have been executed, the network connection object is deleted.
  • Step 702 The controller obtains the update time corresponding to the network connection and tunes the network connection.
  • Step 703 During the tuning process, when it is determined that the deletion timestamp of the network connection is not empty, it is determined that the network status corresponding to the network connection is expected to be deleted.
  • Step 704 The controller deletes each network service interface corresponding to the network connection by calling delete network interface.
  • Step 705 Remove the deletion interception identifier corresponding to the network connection and generate a deletion instruction.
  • the controller removes the Finalizer of the network connection object and updates the network connection object to the API server.
  • Step 706 The API server deletes the network connection object created by the corresponding network connection.
  • embodiments of the present application also provide a device for establishing a network connection.
  • Figure 8 is a schematic structural diagram of a device for establishing a network connection in an embodiment of the present application, which may include:
  • the first screening module 800 is configured to filter out the optional application instances corresponding to each optional tag from the preset original application instances based on each optional tag carried by the created network connection object, and based on the network connection object
  • the carried indication information to be excluded is used to filter out the application instances to be excluded from each original application instance;
  • the determination module 801 is configured to delete the corresponding optional application instances from the optional application instances based on the filtered application instances to be excluded, and obtain each candidate application instance associated with the first service network and the second service network;
  • the second screening module 802 is used to filter out each target application instance that meets the preset operating conditions from each candidate application instance based on the corresponding running status of each candidate application instance;
  • the establishment module 803 is used to establish a network connection between the first service network and the second service network based on each target application instance.
  • the first filtering module 800 is also used to:
  • an application instance to be excluded corresponding to the corresponding first application instance identifier is determined from each original application instance.
  • the determination module 801 is also used to:
  • each application instance to be excluded For each application instance to be excluded, perform the following operations: based on the second application instance identification corresponding to an application instance to be excluded, if it is determined that an application instance to be excluded is included in each optional application instance, then select the application instance from each optional application instance , delete the optional application instance corresponding to the second application instance identifier;
  • the remaining optional application instances are regarded as candidate application instances.
  • the module 801 is also used for:
  • the application instances to be excluded included in the intersection are deleted from the set of optional application instances, and the remaining optional application instances are used as candidate applications instance to obtain a candidate application instance set including each candidate application instance.
  • the running status at least includes probe configuration status
  • the second filtering module 802 is also used to:
  • a candidate application instance is used as the target application instance, where each probe is used to determine the corresponding candidate application instance. Whether it is in a state of normal provision of network services;
  • a candidate application instance is used as the target application instance.
  • the device also includes an adding module 804, which is used for:
  • the establishment module 803 is also used to:
  • the network service of the second service network is provided to the first service network.
  • the device also includes a deletion module 805, which is used to:
  • the update time is when the API server receives the deletion request for the network connection and sets the deletion timestamp for the network connection object to the current time. Generated after object update;
  • the deletion timestamp of the network connection is the current time, it is determined that the network status corresponding to the network connection is expected to be deleted, where the deletion timestamp is set when the deletion request is received;
  • deletion module 805 when deleting a network connection, is also used to:
  • the device for establishing a network connection may at least include a processor and a memory.
  • the memory stores program code.
  • the processor is caused to perform the method of establishing a network connection according to various exemplary embodiments of the present application described in this specification. A step of.
  • the processor may perform steps as shown in Figure 2A.
  • the embodiment of the present application also provides an electronic device.
  • the electronic device may be the controller 110 as shown in Figure 1.
  • the structure of the electronic device may be as shown in Figure 9, including a memory 901, a communication module 903 and one or Multiple processors 902.
  • Memory 901 is used to store computer programs executed by the processor 902.
  • Memory 901 may mainly include stored programs Program area and storage data area, among which, the storage program area can store the operating system and programs required to run the instant messaging function; the storage data area can store various instant messaging information and operation instruction sets, etc.
  • the memory 901 can be a volatile memory (volatile memory), such as a random-access memory (random-access memory, RAM); the memory 901 can also be a non-volatile memory (non-volatile memory), such as a read-only memory, flash Memory (flash memory), hard disk (hard disk drive, HDD) or solid-state drive (SSD); or the memory 901 can be used to carry or store the desired program code in the form of instructions or data structures and can be used by Any other media accessible by a computer, but not limited to this.
  • the memory 501 may be a combination of the above memories.
  • the processor 902 may include one or more central processing units (CPUs) or a digital processing unit or the like.
  • the processor 902 is configured to implement the above method of establishing a network connection when calling the computer program stored in the memory 901.
  • the communication module 903 is used to communicate with terminal devices and other servers.
  • the embodiment of the present application does not limit the specific connection medium between the above-mentioned memory 901, communication module 903 and processor 902.
  • the memory 901 and the processor 902 are connected through a bus 904 in Figure 9.
  • the bus 904 is depicted as a thick line in Figure 9.
  • the connection between other components is only a schematic explanation and does not To be limited.
  • the bus 904 can be divided into an address bus, a data bus, a control bus, etc. For ease of description, only one thick line is used in Figure 9, but it does not describe only one bus or one type of bus.
  • a computer storage medium is stored in the memory 901, and computer executable instructions are stored in the computer storage medium.
  • the computer executable instructions are used to implement the method for establishing a network connection according to the embodiment of the present application.
  • the processor 902 is configured to execute the above method of establishing a network connection, as shown in Figure 2A.
  • various aspects of the method for establishing a network connection can also be implemented in the form of a program product, which includes program code.
  • the program product is run on a computer device, the program code is used to
  • the computer device is caused to perform the steps in the road identification method according to various exemplary embodiments of the present application described above in this specification.
  • the computer device may perform the steps as shown in FIG. 2A.
  • the Program Product may take the form of one or more readable media in any combination.
  • the readable medium may be a readable signal medium or a readable storage medium.
  • the readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination thereof. More specific examples (non-exhaustive list) of readable storage media include: electrical connection with one or more conductors, portable disk, hard disk, random access memory (RAM), read only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above.
  • the program product of the embodiment of the present application can adopt a portable compact disk read-only memory (CD-ROM) and include program code, and can be run on a computing device.
  • CD-ROM portable compact disk read-only memory
  • the program product of the present application is not limited to this.
  • a readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with a command execution system, device or device.
  • the readable signal medium may include a data signal propagated in baseband or as part of a carrier wave carrying readable program code therein. Such propagated data signals may take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above.
  • a readable signal medium may also be any readable medium other than a readable storage medium that can send, propagate, or transport a program for use by or in connection with a command execution system, apparatus, or device.
  • Program code embodied on a readable medium may be transmitted using any suitable medium, including but not limited to wireless, wireline, optical cable, RF, etc., or any suitable combination of the foregoing.
  • the program code for performing the operations of the present application can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., as well as conventional procedural programming. Language—such as "C” or a similar programming language.
  • the program code may execute entirely on the user's computing device, partly on the user's equipment, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device, or entirely on the remote computing device or server execute on. involving remote computing devices
  • the remote computing device may be connected to the user computing device through any kind of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (such as through the Internet using an Internet service provider).
  • LAN local area network
  • WAN wide area network
  • Internet service provider such as AT&T, MCI, Sprint, EarthLink, etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Stored Programmes (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)
  • Computer And Data Communications (AREA)

Abstract

涉及一种建立网络连接的方法、装置、电子设备及存储介质,该方法包括:基于创建的网络连接对象携带的各可选标签,筛选出各可选标签对应的可选应用实例,以及,基于网络连接对象携带的待排除指示信息,筛选出各待排除应用实例,基于筛选出的各待排除应用实例,获得与第一服务网络和第二服务网络关联的各候选应用实例,分别基于各候选应用实例各自对应的运行状态,从各候选应用实例中,筛选出满足预设运行条件的各目标应用实例;基于各目标应用实例,在第一服务网络和第二服务网络之间建立网络连接。

Description

一种建立网络连接的方法、装置、电子设备及存储介质
本申请基于申请号为:202211109508.6,申请日为2022年09月13日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此引入本申请作为参考。
技术领域
本申请涉及网络技术领域,尤其涉及一种建立网络连接的方法、装置、电子设备及存储介质。
背景技术
目前,随着网络技术的发展,服务网络所在的网络环境也越来越多变。
相关技术中,当各服务网络所在的网络环境不同时,通常可以采用调用外部服务接口的方式进行网络连接,例如,当服务网络1的网络环境与服务网络2的网络环境不同时,可以通过调用外部服务接口的方式,建立服务网络1与服务网络2之间的网络连接。
然而,相关技术中,在网络环境非常复杂的情况下,建立网络连接的外部服务接口的实现逻辑也会随之变得非常复杂,并且,不同的服务网络之间建立网络连接时所调用的外部服务接口的实现逻辑也均不相同,因此,采用相关技术中的这种方式建立网络连接时的资源消耗过高,且可扩展性不高。
发明内容
本申请实施例提供一种建立网络连接的方法、装置、电子设备及存储介质,以减少建立网络连接的资源消耗,提高可扩展性。
本申请实施例提供的具体技术方案如下:
一方面,本申请实施例中提供一种建立网络连接的方法,包括:
控制器基于创建的网络连接对象携带的各可选标签,从预设的各原始应用实例中,筛选出所述各可选标签对应的可选应用实例,以及,基于所述网络连接对象携带的待排除指示信息,从所述各原始应用实例中,筛选出各待排除应用实例;
所述控制器基于筛选出的各待排除应用实例,从各可选应用实例中删除相应的可选应用实例,获得与第一服务网络和第二服务网络关联的各候选应用实例;
所述控制器分别基于所述各候选应用实例各自对应的运行状态,从所述各候选应用实例中,筛选出满足预设运行条件的各目标应用实例;
所述控制器基于所述各目标应用实例,在所述第一服务网络和第二服务网络之间建立网络连接。
一方面,本申请实施例提供一种建立网络连接的装置,包括:
第一筛选模块,用于基于创建的网络连接对象携带的各可选标签,从预设的各原始应用实例中,筛选出所述各可选标签对应的可选应用实例,以及,基于所述网络连接对象携带的待排除指示信息,从所述各原始应用实例中,筛选出各待排除应用实例;
确定模块,用于基于筛选出的各待排除应用实例,从各可选应用实例中删除相应的可选应用实例,获得与第一服务网络和第二服务网络关联的各候选应用实例;
第二筛选模块,用于分别基于所述各候选应用实例各自对应的运行状态,从所述各候选应用实例中,筛选出满足预设运行条件的各目标应用实例;
建立模块,用于基于所述各目标应用实例,在所述第一服务网络和第二服务网络之间建立网络连接。
一方面,本申请实施例提供一种电子设备,其包括处理器和存储器,其中,所述存储器存储有程序代码,当所述程序代码被所述处理器执行时,使得所述处理器执行上述任一种建立网络连接的方法的步骤。
一方面,本申请实施例提供一种计算机存储介质,所述计算机存储介质存储有计算机指令,当所述计算机指令在计算机上运行时,使得计算机执行上述任一种建立网络连接的方法的步骤。
一方面,本申请实施例提供一种计算机程序产品,其包括计算机指令,所述计算机指令存储在计算机可读存储介质中;当电子设备的处理器从所述计算机可读存储介质读取所述计算机指令时,所述处理器执行该计算机指令,使得所述电子设备执行上述任一种建立网络连接的方法的步骤。
由于本申请实施例采用上述技术方案,至少具有如下技术效果:
本申请实施例中,控制器基于创建的网络连接对象携带的各可选标签,从预设的各原始应用实例中,筛选出各可选标签对应的可选应用实例,以及,基于网络连接对象携带的待排除指示信息,从各原始应用实例中,筛选出各待排除应用实例,所述控制器基于筛选出的各待排除应用实例,从各可选应用实例中删除相应的可选应用实例,获得与第一服务网络和第二服务网络关联的各候选应用实例,所述控制器分别基于各候选应用实例各自对应的运行状态,从各候选应用实例中,筛选出满足预设运行条件的各目标应用实例,所述控制器基于各目标应用实例,在第一服务网络和第二服务网络之间建立网络连接。这样,通过各可选标签,能够筛选出各可选应用实例,通过待排除指示信息,能够筛选出各待排除应用实例,并将各待排除应用实例从各可选应用实例中删除,从而获得各候选应用实例,并基于各候选应用实例各自对应的运行状态,确定各目标应用实例,从而基于各目标应用实例建立网络连接,无需采用外部服务接口,即可实现建立第一服务网络与第二服务网络之间的网络连接,即使在网络环境非常复杂的情况下,也能够采用简单的实现逻辑实现网络连接,不仅降低了网络连接的资源消耗,还提高了可扩展性。
附图说明
图1为本申请实施例中的应用场景示意图;
图2A为本申请实施例中建立网络连接的流程示意图;
图2B为本申请实施例中确定候选应用实例的示例图;
图2C为本申请实施例中确定待排除应用实例的示例图;
图2D为本申请实施例中删除候选应用实例示例图;
图2E为本申请实施例中确定目标应用实例的示例图;
图2F为本申请实施例中提供网络服务的示例图;
图3为本申请实施例中确定目标应用实例的流程示意图;
图4为本申请实施例中删除网络连接的流程示意图;
图5为本申请实施例中的系统示意图;
图6为本申请实施例中建立网络连接的交互流程图;
图7为本申请实施例中删除网络连接的交互流程图;
图8为本申请实施例中建立网络连接的装置的结构示意图;
图9为应用本申请实施例的一种电子设备的一个硬件组成结构示意图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,并不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
为使本申请实施例的目的、技术方案和优点更加清楚,下面将结合本申请实施例中的附图,对本申请的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请技术方案的一部分实施例,而不是全部的实施例。基于本申请文件中记载的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请技术方案保护的范围。
本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本发明的实施例能够在除了这里图示或描述的那些以外的顺序 实施。
以下对本申请实施例中的部分用语进行解释说明,以便于本领域技术人员理解。
应用实例:应用实例可以是pod,pod是在k8s中创建和管理的、最小的可部署的计算单元,是用于向第一服务网络和第二服务网络提供网络服务的应用集合。
服务网络:表征能够提供服务的隔离的网络,如,第一服务网络与第二服务网络之间相互隔离。
探针配置状态:表征候选应用实例是否配置有探针,其中,探针配置状态可以分为已配置和未配置,探针配置状态为已配置表征候选应用实例配置有探针,探针配置状态为未配置表征候选应用实例未配置有探针。
探针:探针用于获得候选应用实例是否处于能够正常提供网络服务状态的检测结果。
探针检测结果:用于表征探针确定出的候选应用实例对应的检测结果,用于确定候选应用实例是否处于正常提供网络服务状态,其中,探针检测结果包括成功、失败和未知,探针检测结果为成功,表征候选应用实例处于正常提供网络服务状态,候选应用实例能够提供正常的网络服务,探针检测结果为失败,表征候选应用实例未处于正常提供网络服务状态,候选应用实例无法提供正常的网络服务,探针检测结果为未知,表征候选应用实例自身在运行过程中出错,无法获知网络服务的可用性。
调谐:为了完成某类资源进行的调谐,目标是保持用户期望的状态。
自定义资源(Customer Resource,CR):用于扩展实现自定义逻辑,本申请实施例中,用来实现可扩展的网络连接定义与状态。
Finalizer:k8s中网络连接对象的一个属性,其可以阻止网络连接对象被真正删除,而将其卡在Terminating状态,直到Finalizer被移走,网络连接对象才会被真正删除。
Service:k8s内将逻辑上运行在一组应用实例上的应用程序公开为网络服务的抽象方法。
下面对本申请实施例的设计思想进行简要介绍:
目前,随着网络技术的发展,服务网络所在的网络环境也越来越多变。
相关技术中,当各服务网络所在的网络环境不同时,可以采用调用外部服务接口的方式,实现对各网络服务之间的网络连接,例如,当服务网络1的网络环境与服务网络2的网络环境不同时,可以通过调用外部服务接口的方式,建立服务网络1与服务网络2之间的网络连接。
并且,相关技术中的网络连接方式,仅能够支持四种类型的网络连接,分别为ClusterIP、NodePort、LoadBalancer、ExternalName。
1、ClusterIP:通过集群的内部IP暴露服务,选择该值时服务只能够在集群内部访问。这也是默认的ServiceType。
2、NodePort:通过每个节点上的IP和静态端口(NodePort)暴露服务。NodePort服务会路由到自动创建的ClusterIP服务。通过请求<节点IP>:<节点端口>,你可以从集群的外部访问一个NodePort服务。
3、LoadBalancer:使用云提供商的负载均衡器向外部暴露服务。外部负载均衡器可以将流量路由到自动创建的NodePort服务和ClusterIP服务上。
4、ExternalName:通过返回CNAME和对应值,可以将服务映射到externalName字段的内容(例如,foo.bar.example.com)。无需创建任何类型代理。
然而,由于业务场景和网络环境的不同,会使得外部服务接口的调用逻辑产生很大的差异化,一方面,创建网络请求的链路比较复杂,通常会分为多个步骤来实现,并且,不同的服务网络之间建立网络连接时所调用的外部服务接口的实现逻辑也均不相同,因此,无法保证网络连接的可重入性,建立网络连接时的资源消耗过高,且可扩展性不高,另一方面,创建好网络连接之后,无法判断后端真实提供服务的RS的可用性,也即,即使后端RS因为某些原因失效,依然会有流量分配到RS上,从而导致网络连接提供的网络服务的不稳定和可靠性降低。
为了解决上述问题,本申请实施例中提供了一种建立网络连接的方法、装置、电子设备及存储介质,通过各可选标签,能够筛选出各可选应用实例,通过待排除指示信息,能够筛选出各待排除应用实例,并将各待排除应用实例从各可选应用实例中删除,从而获得各候选应用实例,并基于各候选应用实例各自对应的运行状态,确定各目标应用实例,从而基于各目标应用实例建立网络连接,这样,能够增强可扩展性,减少网络资源消耗。
以下结合说明书附图对本申请的优选实施例进行说明,应当理解,此处所描述的优选实施例仅用于说明和解释本申请,并不用于限定本申请,并且在不冲突的情况下,本申请实施例及实施例中的特征可以相互组合。
参阅图1所示,为本申请实施例中的应用场景示意图。该应用场景示意图中包括控制器110和各服务网络120。控制器110与各服务网络120之间可以通过通信网络进行通信。
控制器110可以包括一个或多个处理器、存储器以及与服务网络120交互的I/O接口等。控制器110可以是独立的物理服务器,也可以是多个物理服务器构成的服务器集群或者分布式系统,还可以是提供云服务、云数据库、云计算、云函数、云存储、网络服务、云通信、中间件服务、域名服务、安全服务、内容分发网络(Content Delivery Network,CDN)、以及大数据和人工智能平台等基础云计算服务的云服务器。控制器110与各服务网络120可以通过有线或无线通信方式进行直接或间接地连接,本申请实施例在此不做限制。
各服务网络120用于提供网络服务。
其中,本申请实施例中的建立网络连接的方法,可以在控制器110上进行。当由控制器110建立网络连接时,控制器110通过各可选标签,筛选出各可选应用实例,通过待排除指示信息,筛选出各待排除应用实例,并将各待排除应用实例从各可选应用实例中删除,从而获得各候选应用实例,并基于各候选应用实例各自对应的运行状态,确定各目标应用实例,从而基于各目标应用实例在第一服务网络和第二服务网络之间建立网络连接。
本申请实施例中的方法能够应用于云原生的场景,随着云原生技术的发展,越来越多的服务都在上云,以享受云原生的优势。其中一个需要解决的问题为如何跨网络环境访问对应的云原生服务,相关技术中通常是包装各自的网络连接服务,内部通过调用外部网络服务来实现,所有的实现都在云原生k8s之外,这就使得无法实时感知后端应用实例的运行状况,来动态维护应用实例,保证网络服务的高可靠,为此,本申请实施例中,基于创建的网络连接对象携带的各可选标签,从预设的各原始应用实例中,筛选出各可选标签对应的可选应用实例,以及,基于网络连接对象携带的待排除指示信息,从各原始应用实例中,筛选出各待排除应用实例,基于筛选出的各待排除应用实例,从各可选应用实例中,删除相应的可选应用实例,获得与第一服务网络和第二服务网络关联的各候选应用实例,分别基于各候选应用实例各自对应的运行状态,从各候选应用实例中,筛选出满足预设运行条件的各目标应用实例,基于各目标应用实例,在第一服务网络和第二服务网络之间建立网络连接,从而能够感知后端应用实例的运行状况,动态维护应用实例,不仅保证网络服务的高可靠,还能够减少资源消耗。
本申请实施例提供的方案涉及的建立网络连接等技术,具体通过如下实施例进行说明:
基于上述实施例,参阅图2A所示,为本申请实施例中建立网络连接的流程示意图,下面对本申请实施例中建立网络连接的过程进行说明,具体包括:
S20:控制器基于创建的网络连接对象携带的各可选标签,从预设的各原始应用实例中,筛选出各可选标签对应的可选应用实例,以及,基于网络连接对象携带的待排除指示信息,从各原始应用实例中,筛选出各待排除应用实例。
本申请实施例中,将网络连接请求通过客户端提交至API服务器,API服务器对创建的网络连接请求进行合法性校验,若确定网络连接请求的合法性校验通过,API服务器基于网络连接请求创建网络连接对象,当控制器确定创建的网络连接对象时,由于网络连接对象中携带有各可选标签,因此,基于各可选标签,从预设的各原始应用实例中,筛选出与各可选标签对应的各原始应用实例,筛选出的各原始应用实例即为各可选应用实例,以及, 由于网络连接对象中携带有各待排除指示信息,因此,可基于待排除指示信息,从预设的各原始应用实例中,筛选出与待排除指示信息对应的各原始应用实例,筛选出的各原始应用实例即为各待排除应用实例。
下面对本申请实施例中,筛选出各可选应用实例的过程进行说明,具体的,接收网络连接请求,网络连接请求携带有筛选指示信息,筛选指示信息中包含有各可选标签,因此,将各可选标签,与预设的各原始应用实例各自对应的应用实例标签进行匹配,从各原始应用实例中,确定出与各可选标签均匹配的原始应用实例,将确定出的原始应用实例作为相应的可选应用实例。
例如,参阅图2B所示,为本申请实施例中确定可选应用实例的示例图,假设应用实例为pod,各可选标签分别为“app:a”和“type:foo”,预设的各原始pod分别为原始pod1、原始pod2、原始pod3、原始pod4和原始pod5,原始pod1对应的应用实例标签为“app:a”和“type:foo”,原始pod2对应的应用实例标签为“app:a”和“type:foo”,原始pod3对应的应用实例标签为“app:d”和“type:foo”,原始pod4对应的应用实例标签为“app:b”和“type:bar”,原始pod5对应的应用实例标签为“app:a”和“type:bar”,因此,确定出与可选标签“app:a”和“type:foo”均匹配的原始pod为原始pod1和原始pod2,因此,分别将原始pod1和原始pod2作为可选pod。
其中,可选标签例如可以为预设的属性标签,还可以为键值对,本申请实施例中对此并不进行限制。
属性标签可以为版本标签、环境标签、架构标签、分区标签等,本申请实施例中对此并不进行限制。
需要说明的是,本申请实施例中可选标签对应的原始应用实例可以为一个,也可以为多个,即,多个原始应用实例可能对应相同的可选标签,并且,每个可选应用实例可能对应有多个可选标签,本申请实施例中对此并不进行限制。
下面对本申请实施例中,筛选出各待排除应用实例的过程进行说明,具体的,由于网络连接请求携带有待排除指示信息,因此,可基于待排除指示信息,从各原始应用实例中,确定出各待排除应用实例。
可选的,本申请实施例中,为确定各待排除应用实例提供了一种可能的实施方式,具体包括:
N1:所述控制器基于待排除指示信息中包含的各待排除标签,从各原始应用实例中,筛选出与各待排除标签对应的待排除应用实例。
本申请实施例中,将各待排除标签,与预设的各原始应用实例各自对应的应用实例标签进行匹配,从各原始应用实例中,确定出与各待排除标签均匹配的原始应用实例,将确定出的原始应用实例作为相应的待排除应用实例,这样,能够确定出待排除应用实例,从而保证后续网络服务的高可用性。
N2:所述控制器分别基于待排除指示信息中包含的各第一应用实例标识,从各原始应用实例中,确定出与相应的第一应用实例标识对应的待排除应用实例。
本申请实施例中,网络连接对象中还携带有待排除列表,待排除列表包含有各第一应用实例标识,则基于各第一应用实例标识,确定出各第一应用实例标识各自对应的待排除应用实例。
例如,参阅图2C所示,为本申请实施例中确定待排除应用实例的示例图,假设应用实例为pod,待排除标签为“env:1”,以及,待排除指示信息中包含的各第一应用实例标识分别为待排除pod3对应的第一应用实例标识和待排除pod4对应的第一应用实例标识,预设的各原始pod分别为原始pod1、原始pod2、原始pod3、原始pod4和原始pod5,原始pod1对应的应用实例标签为“env:1”,原始pod2对应的应用实例标签为“env:1”,原始pod3对应的应用实例标签为“env:3”,原始pod4对应的应用实例标签为“env:2”,原始pod5对应的应用实例标签为“env:16”,因此,确定出与待排除标签“env:1”匹配的原始pod为原始pod1和 原始pod2,分别将原始pod1和原始pod2作为待排除pod,并且,基于待排除指示信息中包含的各第一应用实例标识确定出的各待排除pod分别为待排除pod3和待排除pod4,因此,直接将原始pod3和原始pod4作为待排除pod。
需要说明的是,本申请实施例中的网络连接请求是通过API接口或者通过kubectl命令行直接创建。并且,在对网络连接请求的合法性进行校验时,可以对网络连接请求中包含的各可选标签和各待排除标签的格式的合法性进行校验。
其中,kubectl命令行用于与API服务器进行通信,将用户在命令行输入的命令,组织并转化为API服务器支持识别的信息,进而能够基于kubectl命令行实现管理k8s各种资源。
进一步地,本申请实施例中,在创建网络连接前,需要先对网络连接对应的网络连接对象进行定义,具体地,在网络连接对象的Spec的内容中,以声明式的方式定义了期望的网络连接,并通过ServiceLinkSource定义可扩展的网络连接需要的一些信息,定义选择器,选择器通过使用键值对的形式来定义一些列的可选标签,用来选择出期望连接到的可选应用实例,定义排除器,排除器用于从Selector选择出来的可选应用实例集合中剔除相应的待排除应用实例,这些被剔除的待排除应用实例,一方面可以通过待排除标签的形式选择,另一方面以待排除应用实例标识列表的形式选择。
并且,在对网络连接对象进行定义时,在网络连接对象的网络状态中,定义网络连接对象当前的运行状态,其中,网络状态中包含有待排除应用实例集合、可提供服务应用实例集合、不可提供服务应用实例集合和无探针应用实例集合,待排除应用实例集合包含有被排除的待排除应用实例,可提供服务应用实例集合包含有各目标应用实例,不可提供服务应用实例集合包含有除各目标应用实例的候选应用实例,无探针应用实例集合包含有各未配置有探针的应用实例。
可选的,本申请实施例中,为筛选出各候选应用实例提供了一种可能的实施方式,下面对本申请实施例中确定出各候选应用实例的过程进行说明,具体包括:
其中,每个候选应用实例包括:向第一服务网络和第二服务网络提供网络服务的容器集合。
S21:所述控制器基于筛选出的各待排除应用实例,从各可选应用实例中删除相应的可选应用实例,获得与第一服务网络和第二服务网络关联的各候选应用实例。
本申请实施例中,基于筛选出的各待排除应用实例各自对应的应用实例标识,从各可选应用实例中删除相应的可选应用实例,获得与第一服务网络和第二服务网络关联的各候选应用实例。
本申请实施例中,针对筛选出的各待排除应用实例,分别执行以下操作:基于一个待排除应用实例对应的应用实例标识,与各可选应用实例各自对应的应用实例标识进行匹配,确定出与各待排除应用实例具有相同应用实例标识的可选应用实例,将确定出的可选应用实例从各可选应用实例中删除,从而获得与第一服务网络和第二服务网络关联的各候选应用实例,在获得各候选应用实例后,即可通过k8s的informer机制从API服务器获取各候选应用实例。
可选的,本申请实施例中,为获得与第一服务网络和第二服务网络关联的各候选应用实例提供了一种可能的实施方式,下面对本申请实施例中获得各候选应用实例的过程进行说明,具体包括:
针对各待排除应用实例,所述控制器分别执行以下操作:基于一个待排除应用实例对应的第二应用实例标识,若确定一个待排除应用实例包含在各可选应用实例中,则从各可选应用实例中,删除第二应用实例标识对应的可选应用实例;
控制器将剩余的各可选应用实例作为各候选应用实例。
本申请实施例中,将一个待排除应用实例对应的应用实例标识,与各可选应用实例各自对应的应用实例标识进行匹配,判断是否能够匹配到与一个待排除应用实例具有相同应用实例标识的可选应用实例,若确定从各可选应用实例中,确定出与一个待排除应用实例 具有相同应用实例标识的可选应用实例,则从各可选应用实例中,删除确定出的可选应用实例,若未从各可选应用实例中,确定出与一个待排除应用实例具有相同应用实例标识的可选应用实例,则不对各可选应用实例执行删除处理。
例如,参阅图2D所示,为本申请实施例中删除可选应用实例示例图,假设应用实例为pod,各待排除pod各自对应的pod标识分别为pod1和pod2,各可选pod各自对应的pod标识分别为pod2、pod4、pod8、pod11,因此,确定与各待排除pod具有相同pod标识的可选pod为可选pod2,因此,将各可选pod中的可选pod2删除,从而获得与第一服务网络和第二服务网络关联的各候选pod分别为pod4、pod8、pod11。
可选的,本申请实施例中为获得与第一服务网络和第二服务网络关联的各候选应用实例还提供了一种可能的实施方式,下面对本申请实施例中获得各候选应用实例的过程进行说明,具体包括:
S211:所述控制器生成包含有各待排除应用实例的待排除应用实例集合,以及,生成包含有各可选应用实例的可选应用实例集合。
本申请实施例中,分别将各待排除应用实例添加至待排除应用实例集合中,从而获得包含有各待排除应用实例的待排除应用实例集合,并分别将各可选应用实例添加至可选应用实例集合中,从而获得包含有各可选应用实例的可选应用实例集合。
S212:所述控制器基于待排除应用实例集合与可选应用实例集合之间的交集,将所述交集中包含的待排除应用实例从所述可选应用实例集合中删除,将剩余的各可选应用实例作为候选应用实例,获得包含有各候选应用实例的候选应用实例集合。
本申请实施例中,确定待排除应用实例集合与可选应用实例集合之间的交集,进而能够从各可选应用实例中,排除各待排除应用实例,并分别将剩余的各可选应用实例作为候选应用实例,获得包含有各候选应用实例的候选应用实例集合。
S22:所述控制器分别基于各候选应用实例各自对应的运行状态,从各候选应用实例中,筛选出满足预设运行条件的各目标应用实例。
本申请实施例中,针对各候选应用实例,分别执行以下操作:所述控制器基于一个候选应用实例对应的运行状态,判断一个候选应用实例是否满足预设运行条件,若确定一个候选应用实例满足预设运行条件,则将一个候选应用实例作为目标应用实例。
可选的,本申请实施例中,为从各候选应用实例中,确定出目标应用实例提供了一种可能的实施方式,具体地,从API服务器获取各探针,每个候选应用实例可能配置有探针,也可能未配置有探针,若确定某个候选应用实例配置有探针,则确定该候选应用实例对应的探针配置状态为已配置,因此,可以根据候选应用实例对应的探针配置状态,确定候选应用实例是否为目标应用实例,下面进行具体说明:
第一种探针配置状态:已配置。
具体的,当确定候选应用实例对应的探针配置状态为已配置时,基于运行状态中的探针检测结果,确定是否将候选应用实例作为目标应用实例。
其中,探针检测结果可以分为以下三种,分别为成功、失败和未知,下面分别对本申请实施例中的三种探针检测结果进行说明,具体包括:
第一种探针检测结果:成功。
具体的,当确定一个候选应用实例对应的探针配置状态为已配置,且对应的探针检测结果为成功时,将一个候选应用实例作为目标应用实例。
其中,每个探针用于确定相应的候选应用实例是否处于正常提供网络服务的状态。
本申请实施例中,将候选应用实例作为目标应用实例时,需要满足以下两个条件,第一个条件,候选应用实例对应的探针配置状态为已配置,即,候选应用实例配置有探针,第二个条件,探针检测结果为成功,即,候选应用实例处于能够正常提供网络服务的状态,因此,当候选应用实例对应的探针配置状态为已配置,且探针检测结果为成功时,将候选应用实例作为目标应用实例。
例如,参阅图2E所示,为本申请实施例中确定目标应用实例的示例图,假设应用实例为pod,控制器从候选pod集合中,读取候选pod1,若确定候选pod1对应的探针配置状态为已配置,则读取运行状态中的探针检测结果,此时,探针检测结果为成功,确定候选pod1处于能够正常提供网络服务的状态,因此,将候选pod1作为目标pod,再读取下一个候选pod,并重新执行判断探针配置状态是否为已配置的步骤。
第二种探针检测结果:失败。
具体的,当确定候选应用实例对应的探针配置状态为已配置,且运行状态中的探针检测结果为失败,则不对候选应用实例执行处理。
本申请实施例中,当不对候选应用实例执行处理时,需要满足以下两个条件,第一个条件,候选应用实例对应的探针配置状态为已配置,即,候选应用实例配置有探针,第二个条件,探针探测结果为失败,即,候选应用实例未处于能够正常提供网络服务的状态,无法提供网络服务,因此,当候选应用实例对应的探针配置状态为已配置,且探针检测结果为失败,则不对候选应用实例执行处理。
进一步地,本申请实施例中,在确定探针检测结果为失败时,将候选应用实例添加至不可提供服务应用实例集合,因此,在不可提供服务应用实例集合中,至少包含有各不可提供服务的候选应用实例。
第三种探针检测结果:未知。
具体的,当确定候选应用实例对应的探针配置状态为已配置,且运行状态中的探针检测结果为未知,则退回至没有配置探针处理。
本申请实施例中,若确定候选应用实例对应的探针配置状态为已配置,且运行状态中的探针检测结果为未知,则将该候选应用实例作为未配有探针的候选应用实例进行相应处理,即,基于其应用实例运行状态确定是否将该候选应用实例作为目标应用实例。
第二种探针配置状态:未配置。
具体的,当确定候选应用实例对应的探针配置状态为未配置时,基于运行状态中的应用实例运行状态,确定是否将候选应用实例作为目标应用实例。
其中,应用实例运行状态可以分为以下两种,分别为持续运行和未正常运行,下面分别对本申请实施例中的两种应用实例运行状态进行说明,具体包括:
第一种应用实例运行状态:持续运行。
具体的,若确定探针配置状态为未配置,且运行状态中的应用实例运行状态为持续运行,则将一个候选应用实例作为目标应用实例。
本申请实施例中,将候选应用实例作为目标应用实例时,需要满足以下两个条件,第一个条件,候选应用实例对应的探针配置状态为未配置,即,候选应用实例未配置有探针,第二个条件,应用实例运行状态为持续运行,即,候选应用实例正在持续运行,因此,当候选应用实例对应的探针配置状态为未配置,且应用实例运行状态为持续运行时,将候选应用实例作为目标应用实例。
例如,假设应用实例为pod,控制器从候选pod集合中,读取候选pod3,若确定候选pod3对应的探针配置状态为未配置,则读取运行状态中的pod运行状态,此时,若确定pod运行状态为持续运行,确定候选pod3处于能够正常提供网络服务的状态,因此,将候选pod3作为目标pod,再读取下一个候选pod,并重新执行判断探针配置状态是否为已配置的步骤。
第二种应用实例运行状态:未正常运行。
具体的,若确定探针配置状态为未配置,且运行状态中的应用实例运行状态为未正常运行,则不对候选应用实例执行处理。
本申请实施例中,当不对候选应用实例执行处理时,需要满足以下两个条件,第一个条件,候选应用实例对应的探针配置状态为未配置,即,候选应用实例未配置有探针,第二个条件,应用实例运行状态为未正常运行,即,候选应用实例未处于能够正常提供网络服务的状态,无法提供网络服务,因此,当候选应用实例对应的探针配置状态为未配置, 且应用实例运行状态为未正常运行,则不对候选应用实例执行处理。
其中,未正常运行表明候选应用实例处于待定(pending)、初始化(init)和错误(error)等状态,本申请实施例中对此并不进行限制。
这样,通过上述方式,能够获得各目标应用实例,各目标应用实例均为能够正常提供服务的应用实例,保证了网络连接的可靠性。
进一步地,本申请实施例中,所述控制器可以生成无探针应用实例集合、可提供服务应用实例集合和不可提供服务应用实例集合,具体包括:
A1:所述控制器分别将各探针配置状态为未配置的候选应用实例添加至无探针应用实例集合。
本申请实施例中,分别针对各候选应用实例,执行以下操作:确定任意一候选应用实例对应的探针配置状态为未配置时,将该候选应用实例添加至无探针应用实例集合。
A2:所述控制器分别将各目标应用实例添加至可提供服务应用实例集合。
本申请实施例中,分别将各目标应用实例添加至可提供服务应用实例集合中,从而在可提供服务应用实例集合中,包含有各目标应用实例。
A3:所述控制器分别将除各目标应用实例以外的各候选应用实例添加至不可提供服务应用实例集合。
本申请实施例中,由于除了各目标应用实例以外的候选应用实例,均为无法正常提供网络服务的候选应用实例,因此,将除各目标应用实例以外的各候选应用实例添加至不可提供服务应用实例集合。
A4:所述控制器将无探针应用实例集合、可提供服务应用实例集合和不可提供服务应用实例集合存储至网络状态中。
本申请实施例中,将无探针应用实例集合、可提供服务应用实例集合和不可提供服务应用实例集合存储至网络状态中,从而能够对各应用实例集合进行动态维护,保证网络服务的高可用性。
S23:所述控制器基于各目标应用实例,在第一服务网络和第二服务网络之间建立网络连接。
本申请实施例中,基于各目标应用实例,在第一服务网络和第二服务网络之间建立网络连接。
可选的,本申请实施例中,为建立网络连接提供了一种可能的实施方式,下面对本申请实施例中建立网络连接的过程进行说明,具体包括:
S231:所述控制器通过调用连接创建接口,在第一服务网络和第二服务网络之间建立网络接口。
本申请实施例中,通过调用外部的连接创建接口,在第一服务网络和第二服务网络之间建立用于提供网络服务的网络接口。
需要说明的是,在S231中,通过调用连接创建接口,创建的是第一服务网络与第二服务网络之间的网络接口,仅通过网络接口,第一服务网络无法获取到第二服务网络的相应网络服务,而需要通过各目标应用实例,向第一服务网络提供第二服务网络对应的网络服务。
S232:所述控制器通过调用各目标应用实例,以及网络接口,向第一服务网络提供第二服务网络的网络服务。
本申请实施例中,由于每个目标应用实例用于向第一服务网络提供网络服务,因此,调用各目标应用实例,并通过创建的网络接口,向第一服务网络提供第二服务网络的网络服务,从而实现网络连接,能够避免不同网络环境下的网络连接的大量重复性工作,减少资源消耗。
需要说明的是,本申请实施例中,通过目标应用实例,能够创建真正的网络服务,另外,需要说明的是,本申请实施例中的网络接口仅用于建立网络连接,各服务网络之间的 网络接口的实现逻辑可以相同,当然,用户可对网络接口进行扩展,注入自定义的实现逻辑,因此,网络接口具有可扩展性。
例如,参阅图2F所示,为本申请实施例中提供网络服务的示例图,假设应用实例为pod,第一服务网络与第二服务网络之间,通过外部服务的连接创建接口创建网络接口,各目标pod分别为目标pod1、目标pod3和目标pod6,目标pod1、目标pod3和目标pod6通过网络接口,向第一服务网络提供第二服务网络对应的网络服务。
本申请实施例中,能够声明式的使用网络服务,极大的减少的业务接入网络服务的难度,同时避免了不同业务之间大量重复的接入工作,并且,提供了良好的可扩展架构,能够方便的应对不同的网络环境和场景,扩展对应的网络连接实现,另外,支持服务的高可靠,结合应用实例的运行状态以及对应的探针检测结果来保证网络服务的高可靠。
基于上述实施例,下面对本申请实施例中确定目标应用实例的流程进行说明,参阅图3所示,为本申请实施例中确定目标应用实例的流程示意图,具体包括:
S300:判断候选应用实例对应的探针配置状态是否为已配置,若是,则执行S301,若否,则执行S304。
本申请实施例中,候选应用实例对应的运行状态包括探针配置状态,探针配置状态包括已配置和未配置。
S301:若探针检测结果为成功,则执行S302,若探针检测结果为失败,执行S303,若探针检测结果为未知,则执行S304。
本申请实施例中,候选应用实例对应的运行状态还包括探针检测结果,探针检测结果可以分为成功、失败和未知。
S302:将候选应用实例作为目标应用实例。
S303:不对候选应用实例执行处理。
S304:判断候选应用实例对应的应用实例运行状态是否为持续运行,若是,则执行S305,若否,则执行S306。
本申请实施例中,候选应用实例对应的运行状态还包括应用实例运行状态,应用实例运行状态可以分为持续运行和未正常运行。
S305:将候选应用实例作为目标应用实例。
S306:不对候选应用实例执行处理。
S307:读取下一个候选应用实例。
因此,通过上述方式,能够从各候选应用实例中,确定出对应的能够持续提供网络服务的候选应用实例,从而保证了在采用目标应用实例向第一服务网络提供第二服务网络的网络服务时,能够正常提供网络服务,确保网络连接正常。
基于上述实施例,参阅图4所示,为本申请实施例中删除网络连接的流程示意图,具体包括:
S40:所述控制器获得网络连接对应的更新时间时,对网络连接进行调谐。
其中,更新时间为API服务器在接收到针对网络连接的删除请求时,设置针对网络连接对象的删除时间戳为当前时间后,对网络连接对象更新后生成的。
本申请实施例中,用户提交针对网络连接的删除请求至API服务器,API服务器内部设置网络连接对应的网络连接对象的删除时间戳为当前时间,并更新网络连接对应的网络连接对象,当控制器获得API服务器中网络连接的网络连接对象的更新时间时,对网络连接进行调谐。
例如,假设用户提交的删除请求的时间为2:10:00,则设置网络连接的删除时间戳为2:10:00,此时,对网络连接对应的网络连接对象进行更新,控制器确定网络连接对象更新,则对网络连接进行调谐。
需要说明的是,当API服务器设置删除时间戳时,网络连接对象会被自身的删除拦截标识阻止删除。
另外,需要说明的是,本申请实施例中,对网络连接进行调谐,表征对网络连接执行删除流程,然而,由于删除过程中,可能会出现无法执行删除过程的情况,因此,在这种情况下,会终止执行删除过程。
S41:所述控制器在调谐过程中,确定网络连接的删除时间戳为当前时间时,确定网络连接对应的网络状态为期望删除。
其中,删除时间戳为接收到删除请求时设置的。
本申请实施例中,在调谐过程中,若确定删除时间戳不为空,也即,确定的网络连接的删除时间戳为当前时间,则确定网络连接对应的网络状态为期望删除。
例如,假设用户提交的删除请求的时间为2:10:00,则设置网络连接的删除时间戳为2:10:00,在调谐过程中,确定网络连接对应的删除时间戳不为空,为2:10:00,则确定网络连接期望被删除。
需要说明的是,本申请实施例中,当网络状态为期望删除时,表征期望删除该网络连接。
S42:所述控制器删除网络连接。
本申请实施例中,当确定网络连接对应的网络状态为期望删除时,删除该网络连接。
可选的,本申请实施例中,为所述控制器删除网络连接提供了一种可能的实施方式,下面对本申请实施例中删除网络连接的过程进行具体说明:
S421:所述控制器通过调用删除网络接口,删除网络连接对应的各网络服务接口。
本申请实施例中,通过调用外部的删除网络接口,删除该网络连接已有的各网络服务接口,从而使得底层的网络连接被删除。
需要说明的是,在删除各网络服务接口时,可以注入和实现用户自己的逻辑,提高了删除网络连接的可扩展性。
S422:所述控制器移除网络连接对应的删除拦截标识,生成删除指令。
本申请实施例中,删除底层的网络连接成功后,移除网络连接对应的删除拦截标识,生成删除指令。
S423:所述控制器将删除指令发送至API服务器,以使API服务器删除对应网络连接创建的网络连接对象。
本申请实施例中,确定移除网络连接对应的删除拦截标识后,生成删除指令,并将生成的删除指令发送至API服务器,API服务器删除响应删除指令,删除网络连接创建的网络连接对象。
这样,通过上述方式,能够删除网络连接,进一步保证网络连接可以被完全删除。
基于上述实施例,参阅图5所示,为本申请实施例中的系统示意图,具体包括:
1、第一服务网络。
本申请实施例中,当第一服务网络与第二服务网络建立网络连接后,第一服务网络可以使用第二服务网络所提供的服务。
2、第二服务网络。
本申请实施例中,第二服务网络用于向第一服务网络提供服务,第一服务网络与第二服务网络处于不同的网络环境,且第一服务网络与第二服务网络相互隔离。
其中,第二服务网络包括pod1、pod2和pod3,且pod1、pod2和pod3均配置有探针。
3、选择器。
本申请实施例中,选择器用于分别基于筛选指示信息中包含的各可选标签,从预设的各原始应用实例中,筛选出相应可选标签对应的可选应用实例。
4、排除器。
本申请实施例中,排除器用于分别基于待排除指示信息中包含的各待排除标签,从预设的各原始应用实例中,筛选出与相应待排除标签对应的待排除应用实例。
5、网络资源。
本申请实施例中,网络资源为可以个性化扩展实现的模块,用于实现可重入的创建网络连接和删除网络连接。
6、网络资源工厂。
本申请实施例中,网络资源工厂,用于以工厂模式的方式建立起对应的网络连接,以及删除网络连接,包括创建资源1和创建资源2,创建资源1和创建资源2均用于建立网络连接。
需要说明的是,本申请实施例中的网络资源工厂是可个性化扩展实现的模块,只需要在其中实现Apply和Destroy方法,实现可重入的创建网络连接和删除网络连接即可,这样,后续只需要通过声明式的创建网络连接对象,即可便捷的实现网络连接请求。
其中,Apply为创建网络连接的方法,Destroy为删除网络连接的方法。
7、控制器。
本申请实施例中,控制器用于与API服务器进行交互,创建或删除网络连接。
8、API服务器。
本申请实施例中,API服务器用于接收网络连接请求和删除网络连接请求,并将接收到的网络连接请求和删除网络连接请求发送给控制器进行网络连接或删除网络连接。
基于上述实施例,参阅图6所示,为本申请实施例中建立网络连接的交互流程图,具体包括:
步骤600:客户端提交网络连接请求至API服务器。
步骤601:API服务器对网络连接请求进行合法性校验。
本申请实施例中,API服务器对网络连接请求进行合法性校验,当确定网络连接请求的合法性校验通过后,确定允许创建网络连接对象。
步骤602:控制器确定创建网络连接对象后,从各原始应用实例中,筛选出各候选应用实例。
本申请实施例中,可以通过k8s中的选择器,确定出与各可选标签对应的各可选应用实例,并通过k8s中的排除器,确定出与各待排除标签对应的各待排除应用实例,从各可选应用实例中,删除匹配的待排除应用实例,从而获得各候选应用实例。
其中,本申请实施例中的各可选标签可以是在创建pod时,在配置清单中指定的,还可以是创建好pod之后再使用命令进行添加的,一个pod可以对应有多个可选标签,同时,一个可选标签也可以附加给多个pod。
需要说明的是,本申请实施例中的应用实例可以为pod,本申请实施例中对此并不进行限制。
步骤603:从API服务器获取各候选应用实例。
本申请实施例中,可以通过k8s的informer机制从API服务器获取各候选应用实例。
其中,Informer是资源的代码抽象,在控制器的驱动下运行,将Delta FIFO中的数据弹出,然后将数据传送给Indexer。同时Informer也会将数据分发到自定义的控制器中进行事件处理。
步骤604:从API服务器获取各候选应用实例对应的探针配置状态。
步骤605:基于各应用实例的运行状态、探针配置状态和探针检测结果,从各候选应用实例中确定出可提供服务应用实例集合、不可提供服务应用实例集合和无探针应用实例集合。
步骤606:通过调用连接创建接口,在第一服务网络和第二服务网络之间建立网络接口。
步骤607:通过调用各目标应用实例,以及网络接口,向第一服务网络提供第二服务网络的网络服务。
步骤608:向API服务器更新网络连接对象的网络状态。
基于上述实施例,参阅图7所示,为本申请实施例中删除网络连接的交互流程图,具 体包括:
步骤700:用户提交删除网络连接的删除请求至API服务器。
步骤701:API服务器内部设置网络连接对象的删除时间戳为当前时间,并更新网络连接对象。
本申请实施例中,在更新网络连接对象后,网络连接对象会被自身的阻止删除标识阻止删除。
其中,本申请实施例中的阻止删除标识可以为k8s中的Finalizers字段,Finalizers字段属于Kubernetes GC垃圾收集器,是一种删除拦截机制,能够让控制器实现异步的删除前回调,Finalizers字段可以存在于每个网路连接对象中,具体实施时,对带有Finalizer字段的网络连接对象的删除请求,会将其删除时间戳设置为当前时间,但在该步骤中不会删除网络连接对象,一旦删除时间戳被设置,Finalizers字段中的值就会被移除。
当删除时间戳对应的字段被设置时,负责监测该网络连接对象的各个控制器会通过轮询对该网络连接对象的更新请求来执行所要处理的所有阻止删除机制。当所有阻止删除机制均被执行过,网络连接对象被删除。
步骤702:控制器获得网络连接对应的更新时间,对网络连接进行调谐。
步骤703:在调谐过程中,确定网络连接的删除时间戳不为空时,确定网络连接对应的网络状态为期望被删除。
步骤704:控制器通过调用删除网络接口,删除网络连接对应的各网络服务接口。
本申请实施例中,在通过调用删除网络接口,删除网络连接对应的各网络服务接口时,可以通过默认的删除执行逻辑实现,当然,也可以注入和实现自定义逻辑实现,因此,具体有可扩展性。
步骤705:移除网络连接对应的删除拦截标识,生成删除指令。
本申请实施例中,控制器移除网络连接对象的Finalizer,并更新网络连接对象至API服务器。
步骤706:API服务器删除对应网络连接创建的网络连接对象。
基于相同的发明构思,本申请实施例还提供一种建立网络连接的装置。参阅图8所示,为本申请实施例中建立网络连接的装置的结构示意图,可以包括:
第一筛选模块800,用于基于创建的网络连接对象携带的各可选标签,从预设的各原始应用实例中,筛选出各可选标签对应的可选应用实例,以及,基于网络连接对象携带的待排除指示信息,从各原始应用实例中,筛选出各待排除应用实例;
确定模块801,用于基于筛选出的各待排除应用实例,从各可选应用实例中删除相应的可选应用实例,获得与第一服务网络和第二服务网络关联的各候选应用实例;
第二筛选模块802,用于分别基于各候选应用实例各自对应的运行状态,从各候选应用实例中,筛选出满足预设运行条件的各目标应用实例;
建立模块803,用于基于各目标应用实例,在第一服务网络和第二服务网络之间建立网络连接。
可选的,基于网络连接对象携带的待排除指示信息,从各原始应用实例中,筛选出各待排除应用实例时,第一筛选模块800还用于:
基于待排除指示信息中包含的各待排除标签,从各原始应用实例中,筛选出与各待排除标签对应的待排除应用实例;以及,
分别基于待排除指示信息中包含的各第一应用实例标识,从各原始应用实例中,确定出与相应的第一应用实例标识对应的待排除应用实例。
可选的,确定模块801还用于:
针对各待排除应用实例,分别执行以下操作:基于一个待排除应用实例对应的第二应用实例标识,若确定一个待排除应用实例包含在各可选应用实例中,则从各可选应用实例中,删除第二应用实例标识对应的可选应用实例;
将剩余的各可选应用实例作为各候选应用实例。
可选的,基于筛选出的各待排除应用实例,从各可选应用实例中删除相应的可选应用实例,获得与第一服务网络和第二服务网络关联的各候选应用实例时,确定模块801还用于:
生成包含有各待排除应用实例的待排除应用实例集合,以及,生成包含有各可选应用实例的可选应用实例集合;
基于待排除应用实例集合与可选应用实例集合之间的交集,将所述交集中包含的待排除应用实例从所述可选应用实例集合中删除,将剩余的各可选应用实例作为候选应用实例,获得包含有各候选应用实例的候选应用实例集合。
可选的,运行状态至少包括探针配置状态,第二筛选模块802还用于:
针对各候选应用实例,分别执行以下操作:
当确定一个候选应用实例对应的探针配置状态为已配置,且对应配置的探针检测成功时,将一个候选应用实例作为目标应用实例,其中,每个探针用于确定相应的候选应用实例是否处于正常提供网络服务的状态;
当确定探针配置状态为未配置,且运行状态中的应用实例运行状态为持续运行时,将一个候选应用实例作为目标应用实例。
可选的,装置还包括添加模块804,添加模块804用于:
分别将各探针配置状态为未配置的候选应用实例添加至无探针应用实例集合;
分别将各目标应用实例添加至可提供服务应用实例集合;
分别将除各目标应用实例以外的各候选应用实例添加至不可提供服务应用实例集合;
将无探针应用实例集合、可提供服务应用实例集合和不可提供服务应用实例集合存储至网络状态中。
可选的,建立模块803还用于:
通过调用连接创建接口,在第一服务网络和第二服务网络之间建立网络接口;
通过调用各目标应用实例,以及网络接口,向第一服务网络提供第二服务网络的网络服务。
可选的,装置还包括删除模块805,删除模块805用于:
获得网络连接对应的更新时间时,对网络连接进行调谐,其中,更新时间为API服务器在接收到针对网络连接的删除请求时,设置针对网络连接对象的删除时间戳为当前时间后,对网络连接对象更新后生成的;
在调谐过程中,确定网络连接的删除时间戳为当前时间时,确定网络连接对应的网络状态为期望删除,其中,删除时间戳为接收到删除请求时设置的;
删除网络连接。
可选的,删除网络连接时,删除模块805还用于:
通过调用删除网络接口,删除网络连接对应的各网络服务接口;
移除网络连接对应的删除拦截标识,生成删除指令;
将删除指令发送至API服务器,以使API服务器删除对应网络连接创建的网络连接对象。
在一些可能的实施方式中,根据本申请的建立网络连接的装置可以至少包括处理器和存储器。其中,所述存储器存储有程序代码,当所述程序代码被所述处理器执行时,使得所述处理器执行本说明书中描述的根据本申请各种示例性实施方式的建立网络连接的方法中的步骤。例如,所述处理器可以执行如图2A中所示的步骤。
与上述方法实施例基于同一发明构思,本申请实施例中还提供了一种电子设备。在一种实施例中,该电子设备可以是,如图1所示的控制器110,在该实施例中,电子设备的结构可以如图9所示,包括存储器901,通讯模块903以及一个或多个处理器902。
存储器901,用于存储处理器902执行的计算机程序。存储器901可主要包括存储程 序区和存储数据区,其中,存储程序区可存储操作系统,以及运行即时通讯功能所需的程序等;存储数据区可存储各种即时通讯信息和操作指令集等。
存储器901可以是易失性存储器(volatile memory),例如随机存取存储器(random-access memory,RAM);存储器901也可以是非易失性存储器(non-volatile memory),例如只读存储器,快闪存储器(flash memory),硬盘(hard disk drive,HDD)或固态硬盘(solid-state drive,SSD);或者存储器901是能够用于携带或存储具有指令或数据结构形式的期望的程序代码并能够由计算机存取的任何其他介质,但不限于此。存储器501可以是上述存储器的组合。
处理器902,可以包括一个或多个中央处理单元(central processing unit,CPU)或者为数字处理单元等等。处理器902,用于调用存储器901中存储的计算机程序时实现上述建立网络连接的方法。
通讯模块903用于与终端设备和其他服务器进行通信。
本申请实施例中不限定上述存储器901、通讯模块903和处理器902之间的具体连接介质。本申请实施例在图9中以存储器901和处理器902之间通过总线904连接,总线904在图9中以粗线描述,其它部件之间的连接方式,仅是进行示意性说明,并不引以为限。总线904可以分为地址总线、数据总线、控制总线等。为便于描述,图9中仅用一条粗线描述,但并不描述仅有一根总线或一种类型的总线。
存储器901中存储有计算机存储介质,计算机存储介质中存储有计算机可执行指令,计算机可执行指令用于实现本申请实施例的建立网络连接的方法。处理器902用于执行上述的建立网络连接的方法,如图2A所示。
在一些可能的实施方式中,本申请提供的建立网络连接的方法的各个方面还可以实现为一种程序产品的形式,其包括程序代码,当程序产品在计算机设备上运行时,程序代码用于使计算机设备执行本说明书上述描述的根据本申请各种示例性实施方式的道路识别方法中的步骤,例如,计算机设备可以执行如图2A中所示的步骤。
程序产品可以采用一个或多个可读介质的任意组合。可读介质可以是可读信号介质或者可读存储介质。可读存储介质例如可以是但不限于电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。可读存储介质的更具体的例子(非穷举的列表)包括:具有一个或多个导线的电连接、便携式盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。
本申请的实施方式的程序产品可以采用便携式紧凑盘只读存储器(CD-ROM)并包括程序代码,并可以在计算装置上运行。然而,本申请的程序产品不限于此,在本文件中,可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被命令执行系统、装置或者器件使用或者与其结合使用。
可读信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了可读程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。可读信号介质还可以是可读存储介质以外的任何可读介质,该可读介质可以发送、传播或者传输用于由命令执行系统、装置或者器件使用或者与其结合使用的程序。
可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于无线、有线、光缆、RF等等,或者上述的任意合适的组合。
可以以一种或多种程序设计语言的任意组合来编写用于执行本申请操作的程序代码,程序设计语言包括面向对象的程序设计语言—诸如Java、C++等,还包括常规的过程式程序设计语言—诸如“C”语言或类似的程序设计语言。程序代码可以完全地在用户计算装置上执行、部分地在用户设备上执行、作为一个独立的软件包执行、部分在用户计算装置上部分在远程计算装置上执行、或者完全在远程计算装置或服务器上执行。在涉及远程计算装置 的情形中,远程计算装置可以通过任意种类的网络包括局域网(LAN)或广域网(WAN)连接到用户计算装置,或者,可以连接到外部计算装置(例如利用因特网服务提供商来通过因特网连接)。

Claims (20)

  1. 一种建立网络连接的方法,其特征在于,包括:
    控制器基于创建的网络连接对象携带的各可选标签,从预设的各原始应用实例中,筛选出所述各可选标签对应的可选应用实例,以及,基于所述网络连接对象携带的待排除指示信息,从所述各原始应用实例中,筛选出各待排除应用实例;
    所述控制器基于筛选出的各待排除应用实例,从各可选应用实例中删除相应的可选应用实例,获得与第一服务网络和第二服务网络关联的各候选应用实例;
    所述控制器分别基于所述各候选应用实例各自对应的运行状态,从所述各候选应用实例中,筛选出满足预设运行条件的各目标应用实例;
    所述控制器基于所述各目标应用实例,在所述第一服务网络和第二服务网络之间建立网络连接。
  2. 如权利要求1所述的方法,其特征在于,所述控制器基于所述网络连接对象携带的待排除指示信息,从所述各原始应用实例中,筛选出各待排除应用实例,包括:
    所述控制器基于所述待排除指示信息中包含的各待排除标签,从所述各原始应用实例中,筛选出与所述各待排除标签对应的待排除应用实例;以及,
    所述控制器分别基于所述待排除指示信息中包含的各第一应用实例标识,从所述各原始应用实例中,确定出与相应的第一应用实例标识对应的待排除应用实例。
  3. 如权利要求1所述的方法,其特征在于,所述控制器基于筛选出的各待排除应用实例,从各可选应用实例中删除相应的可选应用实例,获得与第一服务网络和第二服务网络关联的各候选应用实例,包括:
    针对所述各待排除应用实例,所述控制器分别执行以下操作:基于一个待排除应用实例对应的第二应用实例标识,若确定所述一个待排除应用实例包含在各可选应用实例中,则从所述各可选应用实例中,删除所述第二应用实例标识对应的可选应用实例;
    所述控制器将剩余的各可选应用实例作为各候选应用实例。
  4. 如权利要求1所述的方法,其特征在于,所述控制器基于筛选出的各待排除应用实例,从各可选应用实例中删除相应的可选应用实例,获得与第一服务网络和第二服务网络关联的各候选应用实例,包括:
    所述控制器生成包含有各待排除应用实例的待排除应用实例集合,以及,生成包含有各可选应用实例的可选应用实例集合;
    所述控制器基于所述待排除应用实例集合与所述可选应用实例集合之间的交集,将所述交集中包含的待排除应用实例从所述可选应用实例集合中删除,将剩余的各可选应用实例作为候选应用实例,获得包含有各候选应用实例的候选应用实例集合。
  5. 如权利要求1所述的方法,其特征在于,所述运行状态至少包括探针配置状态,所述控制器分别基于所述各候选应用实例各自对应的运行状态,从所述各候选应用实例中,筛选出满足预设运行条件的各目标应用实例,包括:
    针对所述各候选应用实例,所述控制器分别执行以下操作:
    当确定一个候选应用实例对应的探针配置状态为已配置,且对应配置的探针检测成功时,将所述一个候选应用实例作为目标应用实例,其中,每个探针用于确定相应的候选应用实例是否处于正常提供网络服务的状态;
    当确定所述探针配置状态为未配置,且所述运行状态中的应用实例运行状态为持续运行时,将所述一个候选应用实例作为目标应用实例。
  6. 如权利要求1-5任一项所述的方法,其特征在于,所述方法还包括:
    所述控制器分别将各探针配置状态为未配置的候选应用实例添加至无探针应用实例集合;
    所述控制器分别将所述各目标应用实例添加至可提供服务应用实例集合;
    所述控制器分别将除所述各目标应用实例以外的各候选应用实例添加至不可提供服务应用实例集合;
    所述控制器将所述无探针应用实例集合、所述可提供服务应用实例集合和所述不可提供服务应用实例集合存储至网络状态中。
  7. 如权利要求1所述的方法,其特征在于,所述控制器基于所述各目标应用实例,在所述第一服务网络和第二服务网络之间建立网络连接,包括:
    所述控制器通过调用连接创建接口,在所述第一服务网络和所述第二服务网络之间建立网络接口;
    所述控制器通过调用所述各目标应用实例,以及所述网络接口,向所述第一服务网络提供所述第二服务网络的网络服务。
  8. 如权利要求1-7任一项所述的方法,其特征在于,所述方法还包括:
    所述控制器获得所述网络连接对应的更新时间时,对所述网络连接进行调谐,其中,所述更新时间为API服务器在接收到针对所述网络连接的删除请求时,设置针对网络连接对象的删除时间戳为当前时间后,对所述网络连接对象更新后生成的;
    所述控制器在调谐过程中,确定所述网络连接的删除时间戳为当前时间时,确定所述网络连接对应的网络状态为期望删除,其中,所述删除时间戳为接收到删除请求时设置的;
    所述控制器删除所述网络连接。
  9. 如权利要求8所述的方法,其特征在于,所述控制器删除所述网络连接,包括:
    所述控制器通过调用删除网络接口,删除所述网络连接对应的各网络服务接口;
    所述控制器移除所述网络连接对应的删除拦截标识,生成删除指令;
    所述控制器将所述删除指令发送至API服务器,以使所述API服务器删除对应所述网络连接创建的网络连接对象。
  10. 一种建立网络连接的装置,其特征在于,应用于控制器,包括:
    第一筛选模块,用于基于创建的网络连接对象携带的各可选标签,从预设的各原始应用实例中,筛选出所述各可选标签对应的可选应用实例,以及,基于所述网络连接对象携带的待排除指示信息,从所述各原始应用实例中,筛选出各待排除应用实例;
    确定模块,用于基于筛选出的各待排除应用实例,从各可选应用实例中删除相应的可选应用实例,获得与第一服务网络和第二服务网络关联的各候选应用实例;
    第二筛选模块,用于分别基于所述各候选应用实例各自对应的运行状态,从所述各候选应用实例中,筛选出满足预设运行条件的各目标应用实例;
    建立模块,用于基于所述各目标应用实例,在所述第一服务网络和第二服务网络之间建立网络连接。
  11. 如权利要求10所述的装置,其特征在于,所述基于所述网络连接对象携带的待排除指示信息,从所述各原始应用实例中,筛选出各待排除应用实例时,所述第一筛选模块还用于:
    基于所述待排除指示信息中包含的各待排除标签,从所述各原始应用实例中,筛选出与所述各待排除标签对应的待排除应用实例;以及,
    分别基于所述待排除指示信息中包含的各第一应用实例标识,从所述各原始应用实例中,确定出与相应的第一应用实例标识对应的待排除应用实例。
  12. 如权利要求10所述的装置,其特征在于,所述基于筛选出的各待排除应用实例,从各可选应用实例中删除相应的可选应用实例,获得与第一服务网络和第二服务网络关联的各候选应用实例时,所述确定模块还用于:
    针对所述各待排除应用实例,分别执行以下操作:基于一个待排除应用实例对应的第二应用实例标识,若确定所述一个待排除应用实例包含在各可选应用实例中,则从所述各可选应用实例中,删除所述第二应用实例标识对应的可选应用实例;
    将剩余的各可选应用实例作为各候选应用实例。
  13. 如权利要求10所述的装置,其特征在于,所述基于筛选出的各待排除应用实例,从各可选应用实例中删除相应的可选应用实例,获得与第一服务网络和第二服务网络关联的各候选应用实例时,所述确定模块还用于:
    生成包含有各待排除应用实例的待排除应用实例集合,以及,生成包含有各可选应用实例的可选应用实例集合;
    基于所述待排除应用实例集合与所述可选应用实例集合之间的交集,将所述交集中包含的待排除应用实例从所述可选应用实例集合中删除,将剩余的各可选应用实例作为候选应用实例,获得包含有各候选应用实例的候选应用实例集合。
  14. 如权利要求10所述的装置,其特征在于,所述运行状态至少包括探针配置状态,所述第二筛选模块还用于:
    针对所述各候选应用实例,分别执行以下操作:
    当确定一个候选应用实例对应的探针配置状态为已配置,且对应配置的探针检测成功时,将所述一个候选应用实例作为目标应用实例,其中,每个探针用于确定相应的候选应用实例是否处于正常提供网络服务的状态;
    当确定所述探针配置状态为未配置,且所述运行状态中的应用实例运行状态为持续运行时,将所述一个候选应用实例作为目标应用实例。
  15. 如权利要求10-14任一项所述的装置,其特征在于,所述装置还包括添加模块,所述添加模块用于:
    分别将各探针配置状态为未配置的候选应用实例添加至无探针应用实例集合;
    分别将所述各目标应用实例添加至可提供服务应用实例集合;
    分别将除所述各目标应用实例以外的各候选应用实例添加至不可提供服务应用实例集合;
    将所述无探针应用实例集合、所述可提供服务应用实例集合和所述不可提供服务应用实例集合存储至网络状态中。
  16. 如权利要求10所述的装置,其特征在于,所述建立模块还用于:
    通过调用连接创建接口,在所述第一服务网络和所述第二服务网络之间建立网络接口;
    通过调用所述各目标应用实例,以及所述网络接口,向所述第一服务网络提供所述第二服务网络的网络服务。
  17. 如权利要求10-16任一项所述的装置,其特征在于,所述装置还包括删除模块,所述删除模块用于:
    获得所述网络连接对应的更新时间时,对所述网络连接进行调谐,其中,所述更新时间为API服务器在接收到针对所述网络连接的删除请求时,设置针对网络连接对象的删除时间戳为当前时间后,对所述网络连接对象更新后生成的;
    在调谐过程中,确定所述网络连接的删除时间戳为当前时间时,确定所述网络连接对应的网络状态为期望删除,其中,所述删除时间戳为接收到删除请求时设置的;
    删除所述网络连接。
  18. 一种电子设备,其特征在于,其包括处理器和存储器,其中,所述存储器存储有程序代码,当所述程序代码被所述处理器执行时,使得所述处理器执行权利要求1-9中任一所述方法的步骤。
  19. 一种计算机可读存储介质,其特征在于,其包括程序代码,当所述程序代码在电子设备上运行时,所述程序代码用于使所述电子设备执行权利要求1-9中任一所述方法的步骤。
  20. 一种计算机程序产品,其特征在于,其包括计算机指令,所述计算机指令存储在计算机可读存储介质中;当电子设备的处理器从所述计算机可读存储介质读取所述计算机指令时,所述处理器执行该计算机指令,使得所述电子设备执行权利要求1-9中任一所述方法的步骤。
PCT/CN2023/107539 2022-09-13 2023-07-14 一种建立网络连接的方法、装置、电子设备及存储介质 WO2024055741A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US18/589,571 US20240205297A1 (en) 2022-09-13 2024-02-28 Method and apparatus for establishing network connection, electronic device, and storage medium

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211109508.6 2022-09-13
CN202211109508.6A CN117749854A (zh) 2022-09-13 2022-09-13 一种建立网络连接的方法、装置、电子设备及存储介质

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US18/589,571 Continuation US20240205297A1 (en) 2022-09-13 2024-02-28 Method and apparatus for establishing network connection, electronic device, and storage medium

Publications (1)

Publication Number Publication Date
WO2024055741A1 true WO2024055741A1 (zh) 2024-03-21

Family

ID=90249446

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/107539 WO2024055741A1 (zh) 2022-09-13 2023-07-14 一种建立网络连接的方法、装置、电子设备及存储介质

Country Status (3)

Country Link
US (1) US20240205297A1 (zh)
CN (1) CN117749854A (zh)
WO (1) WO2024055741A1 (zh)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140146731A1 (en) * 2011-05-09 2014-05-29 Cumbari Ab System and method for establishing communication for network connected devices
CN108667777A (zh) * 2017-03-31 2018-10-16 华为技术有限公司 一种服务链生成方法及网络功能编排器nfvo
CN111913875A (zh) * 2014-10-24 2020-11-10 谷歌有限责任公司 用于基于软件执行跟踪自动加标签的方法和系统
CN114666306A (zh) * 2022-02-18 2022-06-24 阿里巴巴(中国)有限公司 WebRTC网络连接建立方法和服务器、电子设备及计算机可读存储介质

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140146731A1 (en) * 2011-05-09 2014-05-29 Cumbari Ab System and method for establishing communication for network connected devices
CN111913875A (zh) * 2014-10-24 2020-11-10 谷歌有限责任公司 用于基于软件执行跟踪自动加标签的方法和系统
CN108667777A (zh) * 2017-03-31 2018-10-16 华为技术有限公司 一种服务链生成方法及网络功能编排器nfvo
CN114666306A (zh) * 2022-02-18 2022-06-24 阿里巴巴(中国)有限公司 WebRTC网络连接建立方法和服务器、电子设备及计算机可读存储介质

Also Published As

Publication number Publication date
US20240205297A1 (en) 2024-06-20
CN117749854A (zh) 2024-03-22

Similar Documents

Publication Publication Date Title
US11030020B2 (en) Asynchronous handling of service requests
US9971823B2 (en) Dynamic replica failure detection and healing
US11044230B2 (en) Dynamically opening ports for trusted application processes hosted in containers
US10521116B2 (en) System and method for managing object store
US20140173594A1 (en) Scalable Services Deployment
CN107729176B (zh) 一种配置文件管理系统的容灾方法及容灾系统
CN111258627A (zh) 一种接口文档生成方法和装置
WO2019100266A1 (zh) 移动边缘主机服务通知方法和装置
KR102486236B1 (ko) 무선 통신 시스템에서 네트워크 기능 가상화를 위한 장치 및 방법
US11627169B2 (en) Network-based Media Processing (NBMP) workflow management through 5G Framework for Live Uplink Streaming (FLUS) control
US11546307B2 (en) Method to implement multi-tenant/shared Redis cluster using envoy
US20100332532A1 (en) Distributed directory environment using clustered ldap servers
CN113709810A (zh) 一种网络服务质量的配置方法、设备和介质
CN114371914A (zh) 容器ip地址配置方法、装置、存储介质及电子设备
US20240048448A1 (en) Parallel execution of network services with overlapping device configuration
US11381665B2 (en) Tracking client sessions in publish and subscribe systems using a shared repository
WO2024055741A1 (zh) 一种建立网络连接的方法、装置、电子设备及存储介质
CN114070889B (zh) 配置方法、流量转发方法、设备、存储介质及程序产品
US11323355B1 (en) Partition abstraction in distributed computing systems
KR102651239B1 (ko) 가상화 기술을 이용한 통신 방법 및 이를 수행하는 전자 장치
US11403093B1 (en) Application modification with proxy service process
US11853560B2 (en) Conditional role decision based on source environments
US11196668B2 (en) End user premises device controller
US11757733B2 (en) Parallel service invocation in a network
US20220334884A1 (en) Method to implement multi-tenant/shared redis cluster using envoy

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23864477

Country of ref document: EP

Kind code of ref document: A1