WO2020232891A1 - 负载均衡应用虚拟ip切换方法、装置、计算机设备及存储介质 - Google Patents

负载均衡应用虚拟ip切换方法、装置、计算机设备及存储介质 Download PDF

Info

Publication number
WO2020232891A1
WO2020232891A1 PCT/CN2019/103262 CN2019103262W WO2020232891A1 WO 2020232891 A1 WO2020232891 A1 WO 2020232891A1 CN 2019103262 W CN2019103262 W CN 2019103262W WO 2020232891 A1 WO2020232891 A1 WO 2020232891A1
Authority
WO
WIPO (PCT)
Prior art keywords
application
load balancing
container instance
ips
gray
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Ceased
Application number
PCT/CN2019/103262
Other languages
English (en)
French (fr)
Inventor
黄桂钦
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Publication of WO2020232891A1 publication Critical patent/WO2020232891A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/45Network directories; Name-to-address mapping
    • H04L61/4505Network directories; Name-to-address mapping using standardised directories; using standardised directory access protocols
    • H04L61/4511Network directories; Name-to-address mapping using standardised directories; using standardised directory access protocols using domain name system [DNS]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
    • H04L67/1004Server selection for load balancing
    • H04L67/1023Server selection for load balancing based on a hash applied to IP addresses or costs

Definitions

  • This application relates to the field of cloud computing technology, and in particular to a method, device, computer equipment and storage medium for virtual IP switching of load balancing applications.
  • grayscale release If an application adds new features or improves certain features of the original version on the basis of the original version, it will involve grayscale release.
  • the version of the application corresponding to the grayscale release is called the grayscale application.
  • the grayscale application After the grayscale application is tested, a stable new version will be formed.
  • the original application needs to be closed to switch from the original application to the new version application (grayscale application). This will cause service interruption when the version is switched and affect the user experience.
  • the embodiments of the present application provide a method, device, computer equipment, and storage medium for switching virtual IP of a load balancing application, which can not cause service interruption when the original application and grayscale application versions are switched, which improves the efficiency of version switching and improves User experience.
  • an embodiment of the present application provides a method for switching a load balancing application virtual IP, the method including:
  • the first preset number of IPs is determined from the container instance IPs of the original application according to the first preset rule, where the first preset number is less than the number of container instances of the original application, so
  • the gray scale application is an application formed after adding new or improved functions to the version of the original application; deactivating the determined first preset number of IPs and corresponding to the first preset number of IPs A container instance, wherein the first preset number of IPs that are disabled are recycled into a preset IP address pool; the second preset is determined from the disabled IPs in the preset IP address pool according to a second preset rule The number of IPs that need to be activated, wherein the second preset number is less than or equal to the number of disabled IPs; the IPs that need to be activated are allocated to the newly-added container instance of the grayscale application; Add the configuration code corresponding to the newly added container instance of the grayscale application to the configuration file of the corresponding load balancing application; combine the access domain name of the original application with the
  • an embodiment of the present application provides a load balancing application virtual IP switching device.
  • the load balancing application virtual IP switching device includes: a deactivation IP determination unit, configured to: if the grayscale application completes the test, according to the first preset The rule determines a first preset number of IPs from the container instance IPs of the original application, where the first preset number is less than the number of container instances of the original application, and the grayscale application is in the version of the original application An application formed after adding new or improved functions on the above; the deactivation unit is used to deactivate the determined first preset number of IPs and the container instance corresponding to the first preset number of IPs, where all The first preset number of IPs that are disabled are recycled to the preset IP address pool; the activation IP determining unit is configured to determine the second preset from the disabled IPs from the preset IP address pool according to the second preset rule.
  • the adding unit is used to add the configuration code corresponding to the newly added container instance of the gray-scale application to the configuration file of the load balancing application corresponding to the gray-scale application;
  • the corresponding relationship between the access domain name and the virtual IP of the load balancing application corresponding to the original application is released, and the access domain name of the original application is bound to the virtual IP of the load balancing application corresponding to the gray-scale application to The grayscale application can be accessed through the access domain name of the original application.
  • an embodiment of the present application provides a computer device, the computer device includes a memory, and a processor connected to the memory;
  • the memory is used to store a computer program
  • the processor is used to run the computer program stored in the memory to execute the method described in the first aspect above.
  • an embodiment of the present application provides a computer-readable storage medium that stores a computer program that, when executed by a processor, implements the method described in the first aspect.
  • FIG. 1 is a schematic flowchart of a method for switching a virtual IP of a load balancing application provided by an embodiment of the present application
  • FIG. 2 is a schematic diagram of a sub-flow of a method for switching a virtual IP of a load balancing application provided by an embodiment of the present application;
  • FIG. 3 is a schematic diagram of a sub-flow of a method for switching a virtual IP of a load balancing application provided by an embodiment of the present application;
  • FIG. 4 is a schematic diagram of a sub-flow of a method for switching a virtual IP of a load balancing application provided by an embodiment of the present application;
  • FIG. 5 is a schematic block diagram of a load balancing application virtual IP switching device provided by an embodiment of the present application
  • Fig. 6 is a schematic block diagram of a disabling unit provided by an embodiment of the present application.
  • FIG. 7 is a schematic block diagram of an enabling unit provided by an embodiment of the present application.
  • FIG. 8 is a schematic block diagram of a configuration adding unit provided by an embodiment of the present application.
  • Fig. 9 is a schematic block diagram of a computer device provided by an embodiment of the present application.
  • FIG. 1 is a schematic flowchart of a method for switching a virtual IP of a load balancing application provided by an embodiment of the present application. As shown in Figure 1, the method includes S101-S106.
  • the gray scale application is an application formed after adding new or improved functions to the version of the original application.
  • the grayscale application is an application formed after adding new or improved functions to the original application version.
  • the completion of the test for grayscale applications is understood to mean that grayscale applications can become a fully upgraded new version.
  • the gray scale application can also be simply understood as a new version of the application.
  • Determining the first preset number of IPs from the container instance IPs of the original application according to the first preset rule includes: obtaining the container instance IPs and the number of container instances of the original application, and from the container instance IP of the original application according to the first preset rule Determine the first preset number of IPs in the example IP.
  • the server of the PaaS platform stores the container instance IP and the number of container instances created by all applications, so the original application can be directly obtained from the database or file that saves the container instance IP and the number of container instances created by the application The container instance IP and the number of container instances.
  • the first preset number of IPs is determined from the container instance IPs of the original application according to the first preset rule.
  • the first preset number of container instance IPs can be randomly determined from the container instance IPs of the original application, or from In the container instance IP of the original application, the first preset number of container instance IPs are determined according to the order of the container instance IP allocation, and the container instance IPs of the original application can also be preferentially determined from container instance IPs that do not belong to the same network segment ( If there are many container instance IPs in a certain network segment, the first preset number of IPs will be obtained first from other network segments), and then the first preset number of IPs will be determined according to the random or container instance IP allocation order , And select the first preset number of IPs according to other rules.
  • the first preset number is less than the number of container instances of the original application.
  • the number of container instances of the original application is 8, and the first preset number may be 4, etc.
  • the purpose of the first preset number being smaller than the number of container instances of the original application is that when processing the first preset number of container instances of the original application, the original application still has container instances (except for the first preset number) Other container instances of) are running normally, and the running container instance can provide services, so that it will not cause service interruption.
  • a corresponding management panel may be developed to display the correspondence between the application and the container instance IP of the application on the management panel.
  • the original application displayed on the management panel and the container instance IP of the original application are obtained.
  • Select a first preset number of container instance IPs according to the first preset rule from the displayed container instance IPs of the original application and receive the first preset number of container instance IPs selected according to the first preset rule as the determined The first preset number of IPs.
  • the container instance IP of the original application and the container instance IP of the grayscale application are used as the preset IP address pool.
  • the container instance IP of the original application and the container instance IP of the grayscale application are preset as the preset IP address pool, and the container instance of the original application and the container instance of the grayscale application are set to share the Default IP address pool.
  • the IP is added to the shared preset IP address pool.
  • the IP cannot be occupied by other applications and can only be used The container instance of the original application and the container instance of the grayscale application are used.
  • the container instance IP of the original application and the container instance IP of the grayscale application are set to share the default IP address pool because, in general, after the container instance IP of an application is disabled, it will be recycled to the idle IP address pool, and idle
  • the IP of the IP address pool can be assigned to any container application. In this way, if the container instance IP of the original application or the container instance IP of the grayscale application is deactivated, the deactivated IP is recycled to the free IP address pool and no longer belongs to the original application or the grayscale application.
  • the default The IP in the IP address pool only belongs to the container instance of the original application and the container instance of the grayscale application, and will not be occupied by other applications.
  • the determined container instance IP and the container instance corresponding to the container instance IP are deactivated.
  • step S102 includes the following steps S1021-S1024.
  • S1021 Set the determined use state identifier of the first preset number of IPs to a disabled state.
  • setting the use state of the first preset number of IP settings to the disabled state means that the IP still belongs to the application and cannot be used by other applications.
  • S1022 Destroy the container instances corresponding to the first preset number of IPs.
  • a destruction instruction is issued to the host machine corresponding to the container instance through an orchestration tool, and the destruction instruction, such as a docker stop instruction, will destroy the corresponding container instance on the corresponding host machine.
  • the destruction instruction such as a docker stop instruction
  • destroying the container instance can also be understood as shrinking the container instance. Destroying the container instance will release all the resources occupied by the container instance, such as including environmental information corresponding to the container instance, closing file input and output streams, and closing the connection to the database. , Modify the relevant information of the container instance stored in other databases, etc.
  • orchestration tools such as marathon and so on.
  • S1023 Reclaim the IP whose use status is marked as disabled to a preset IP address pool.
  • the IP in the preset IP address pool is an IP that can be shared by the original application and the grayscale application.
  • the IP whose usage status is marked as disabled cannot be occupied by other applications.
  • S1024 Modify the number of container instances of the original application according to the first preset number.
  • the modified number of container instances is the number of original container instances of the original application minus the first preset number.
  • step S1023 and step S1024 are not strictly limited, and step S1024 may be executed first and then step S1023 may be executed.
  • S103 Determine a second preset number of IPs to be activated from the deactivated IPs from the preset IP address pool according to a second preset rule, where the second preset number is less than or equal to the number of deactivated IPs .
  • the second preset number of container instance IPs can be randomly determined from the IPs whose usage status is identified as disabled in the preset IP address pool, or the IP usage status identification can be changed from the IPs whose usage status is identified as disabled.
  • the sequence of the deactivated state determines the second preset number of container instance IPs, etc., and the second preset number of container instance IPs may also be determined according to other rules. Among them, if the second preset number is less than the number of disabled IPs, it means that a part of the disabled IPs will be allocated to the newly added container instances of the grayscale application, which means that the grayscale application needs to add the number of container instances. Less than the number of container instances destroyed by the original application.
  • the second preset number is equal to the number of disabled IPs, it means that all the disabled IPs are used to allocate the newly added container instances of the grayscale application. That means how many container instances of the original application are destroyed, and how many new container instances need to be added to the grayscale application.
  • the disabled IPs in the preset IP address pool may be greater than the first preset number of IPs disabled this time. It can be understood that, before deactivating the container instance IP of the original application this time, the container instance IP of the original application was also deactivated or the container instance IP of the grayscale application was also deactivated, which resulted in the default IP address pool The disabled IP is greater than the first preset number of IPs disabled this time.
  • the corresponding relationship between the application and the container instance IP of the application and the usage status identifier of the IP can be displayed on the management panel.
  • the container IP corresponding to the original application and the gray-scale application and the usage status identifier of the container IP are obtained and displayed on the management panel; the second preset number of IPs to be activated are selected from the IP whose usage status is identified as disabled, Receive the selected IP to be activated as the determined IP to be activated.
  • S104 Assign the IP to be activated to the newly added container instance of the grayscale application.
  • the S104 includes the following steps S1041-S1043.
  • S1041 Determine, according to the gray-scale application and the number of IPs that need to be activated, a host where the container instance to be added to the gray-scale application is located.
  • determine the area where the container instance of the grayscale application needs to be added is located according to the grayscale application, and determine the host of the same number of container instances of the grayscale application to be added from the area according to the number of IPs to be activated ( Host IP).
  • Host IP the number of hosts is the same as the number of newly added container instances, and the number of newly added container instances is the same as the number of IPs that need to be enabled.
  • S1042 Create a container instance of the grayscale application on the determined host computer.
  • the new command is sent to the orchestration tool to push the new command to the corresponding host computer through the orchestration tool, and the container instance corresponding to the grayscale application is created on the corresponding host computer through the new command.
  • the new command includes information such as application mirroring of grayscale applications.
  • the layout tools of different regions are different, and the layout tools that need to be used are determined according to the region where the grayscale is located.
  • the orchestration tool is located in the same area as the grayscale application, and is also located in the same area as the host of the newly added container instance of the grayscale application, which improves the speed of the newly added container instance.
  • the container instance of is used as a new container instance for grayscale applications.
  • S1043 Allocate the IP to be activated to the newly created container instance of the grayscale application.
  • an operation and maintenance tool such as ansible is used to connect the container instance, and the created container instance is bound to the IP to be enabled.
  • the types of load balancing applications for grayscale applications include F5, LVS, Haproxy, Nginx, and so on.
  • the load balancing application type of the gray-scale application can be obtained from the PaaS platform database.
  • step S105 includes: detecting the type of the load balancing application corresponding to the gray-scale application; obtaining according to the type of the load-balancing application corresponding to the gray-scale application in a manner matching the type And adding the configuration code corresponding to the newly added container instance of the grayscale application into the configuration file of the load balancing application.
  • F5 load balancing applications are hard load balancing applications, which are created on specific F5 devices, while LVS, Haproxy, and Nginx load balancing applications are soft load balancing applications, so F5 load balancing applications and LVS, Haproxy, Nginx load balancing
  • LVS, Haproxy, and Nginx load balancing are soft load balancing applications, so F5 load balancing applications and LVS, Haproxy, Nginx load balancing
  • the configuration file of the load balancing application is obtained by matching the type and configured in the configuration file.
  • the step of adding the configuration code corresponding to the newly added container instance of the grayscale application into the file includes the following steps S1051-S1058.
  • S1051 Determine whether the type of the load balancing application is F5.
  • S1053 Obtain the configuration file of the F5 load balancing application on the F5 device, and add the configuration code corresponding to the newly added container instance of the grayscale application in the configuration file.
  • Adding the configuration code corresponding to the newly added container instance of the grayscale application to the configuration file includes: adding pool member (container instance of the newly added grayscale application) information to the configuration file; modifying the pool information The number of members. Among them, add the information of the pool member (the newly added container instance of the grayscale application), including the IP address and port information of the newly added container instance of the grayscale application; start the container instance, and modify the monitoring status of the container instance to Running state.
  • the port is the same as the port of the previously existing container instance by default, such as port 80.
  • the number of members after modification is the number of members before modification and the number of newly added container instances of grayscale applications.
  • the type of the load balancing application is non-F5
  • Determining the container of the load balancing application according to the grayscale application can be understood as determining the virtual IP of the container of the load balancing application of the load balancing application corresponding to the grayscale application according to the grayscale application.
  • S1055 Obtain a configuration file from a container of a corresponding load balancing application, and download the obtained configuration file to a local.
  • step S1056 includes: obtaining the corresponding container instance configuration code template; adding the IP and port information of the newly-added grayscale application container instance to the corresponding container instance configuration code template (wherein, the port defaults to the previously existing container The port of the instance is the same, such as port 80) to form the configuration code of the newly added container instance; the configuration code of the newly added container instance is appended to the configuration code of the last container instance in the configuration file.
  • the container instance configuration code templates corresponding to LVS load balancing applications, Haproxy load balancing applications, and Nginx applications are different.
  • the container instance configuration code template in the LVS load balancing application includes the IP information of the container instance, the port information of the container instance (port information used to provide services), the weight information corresponding to the container instance (that is, the server of the load balancing application), Information about the health check method (including connection timeout, reconnection times, reconnection interval, etc.) corresponding to the container instance, etc., and the container instance IP parameters and container instance port parameters in the configuration code template will be grayed out.
  • the configuration code template can be a piece of code starting with the server node, such as server container instance IP: container instance port check inter 30000 rise 1 fall 2.
  • the container instance IP parameters and container in the code template will be configured
  • the port parameters of the instance are replaced with the IP and port of the newly-added grayscale application container instance to form the configuration code of the newly-added container instance.
  • the configuration code of the newly-added container instance is appended to the configuration file (the configuration here The file includes the last server code segment in Haproxy.conf), where the last server code segment can be located by locating the server node in the option forwardfor node of the Haproxy load balancing application.
  • the configuration code template is also a piece of code starting with the server node. After adding the IP of the new container instance and the port of the container instance to the configuration code template, it is added to the last container instance in the configuration file.
  • Configuration code is Among them, the configuration code of the last container instance in the configuration file can be located by locating the server content in the upstream node.
  • S1058 Restart the load balancing service of the container of the corresponding load balancing application to make the configuration file added with the configuration code take effect.
  • This embodiment further limits that different methods are determined according to the types of different load balancing applications to add the configuration code corresponding to the newly added container instance of the gray-scale application into the configuration file of the gray-scale application.
  • the process of this embodiment is automatically completed without manual intervention, which improves the speed.
  • S106 Remove the correspondence between the access domain name of the original application and the virtual IP of the load balancing application corresponding to the original application, and combine the access domain name of the original application with the load balancing application corresponding to the gray-scale application Binding to the virtual IP of the original application to access the grayscale application through the access domain name of the original application.
  • the corresponding relationship between the access domain name of the original application and the virtual IP of the load balancing application is stored in the server of the PaaS platform.
  • the corresponding relationship between the access domain name of the original application and the virtual IP of the load balancing application corresponding to the original application is removed, which can be understood as deleting the saved access domain name of the original application and the virtual IP of the load balancing application corresponding to the original application.
  • Binding the access domain name of the original application with the virtual IP of the load balancing application corresponding to the gray-scale application can be understood as adding the access domain name of the original application and the load balancing corresponding to the gray-scale application in the database Correspondence of the virtual IP of the application.
  • the user Before the corresponding relationship between the access domain name of the original application and the virtual IP of the load balancing application corresponding to the original application is removed, the user can still access the original application through the access domain name of the original application, that is, access part of the container instance of the original application (except for the first preset). Set the number of container instances), so that the service provided by the original application will not be interrupted.
  • the user can access the container instance corresponding to the grayscale application through the access domain name of the original application. In this way, the grayscale application The instance of the container starts to provide services.
  • the number of container instances of the original application is 8, and the number of container instances of the grayscale application is 1 (assuming the number of container instances of the grayscale application created by default is 1).
  • the number is 9. If the first preset number is 5, then determine 5 IP addresses from the container instance IP of the original application, destroy the container instance corresponding to the 5 IP addresses, and reclaim the 5 IP addresses to the preset IP address Pool, set the usage status of the 5 IP addresses to disabled status.
  • the second preset number is determined (less than or equal to the first preset number), and the second preset number may be 1, or 2 or 3 or 4 or 5. If the second preset number is 5, it can be understood that all recovered IP will be reused. Add 5 new container instances for grayscale applications, and assign 5 disabled IPs to the 5 new container instances for grayscale applications.
  • the first preset number of container instances of the original application and the first preset number of container instance IPs are deactivated, and the container instances of the grayscale application are added to obtain the first IP from the deactivated IP.
  • Two preset number of IPs, and assign the second preset number of IPs to the newly-added container instance of the gray-scale application add the newly-added container instance of the gray-scale application to the configuration file of the load balancing application of the gray-scale application, and Set the correspondence between the access domain name of the original application and the virtual IP of the load balancing application corresponding to the gray-scale application.
  • the virtual IP of the original application is switched to the gray-scale application, and the gray-scale application is accessed through the access domain name of the original application.
  • the above method embodiment quickly realizes the offline of the original application and the online of the grayscale application, does not cause service interruption when the original application and the grayscale application version switch, realizes the seamless switching, and improves the efficiency of version switching. Improve the user experience.
  • the above embodiment does not need to modify the access domain name, and the grayscale application can be accessed through the same access domain name (the access domain name of the original application).
  • the load balancing application virtual IP switching method includes the following steps: cloning the original application, and adding the code corresponding to the new function or the improved function on the basis of the cloned original application version, To form a gray-scale application mirror; according to the creation area of the original application container instance and the gray-scale application mirroring, create a gray-scale application container instance and the load balance corresponding to the gray-scale application in the area under the test environment application.
  • cloning the original application includes cloning the code of the original application, the configuration files, system files, allocated memory, and the number of CPUs corresponding to the original application. Clone the original version of the application to get an application that is exactly the same as the original application. On the basis of the cloned original application version, add codes corresponding to new or improved functions to form a gray-scale application mirror image.
  • the original application can provide external services, so the original application has created a corresponding container instance and a load balancing application corresponding to the original application.
  • the creation area of the original application container instance can be obtained, where the creation area refers to the location of the computer room of the created container instance, etc.
  • each different computer room corresponds to a mirror warehouse of different application environments, such as development environment (the container instance of the application is successfully created for internal development and use), production environment (meaning that the container instance of the application is created After success, it is connected to the external environment, or for external users to access), test environment (meaning that the container instance of the application is successfully created for testing).
  • development environment the container instance of the application is successfully created for internal development and use
  • production environment meaning that the container instance of the application is created After success, it is connected to the external environment, or for external users to access
  • test environment meaning that the container instance of the application is successfully created for testing.
  • the load balancing application corresponding to the grayscale application will be created at the same time as the container instance of the grayscale application is created, and the created The relationship between the gray scale application and the created load balancing application will automatically generate the created configuration file of the load balancing application and the domain name corresponding to the load balancing application. If in the process of creating a container instance of a grayscale application, no load balancing application is selected, after the container instance of the grayscale application is created, a load balancing application will be created for the grayscale application. When the load balancing application of the gray scale application is created, the configuration file of the created load balancing application and the domain name corresponding to the load balancing application are automatically generated.
  • FIG. 5 is a schematic block diagram of a load balancing application virtual IP switching device provided by an embodiment of the present application.
  • the device includes a unit corresponding to the above-mentioned load balancing application virtual IP switching method.
  • the device 100 includes a deactivation IP determination unit 101, a deactivation unit 102, an activation IP determination unit 103, an activation unit 104, an adding unit 105 and a binding unit 106.
  • the IP determining unit 101 which is configured to determine a first preset number of IPs from the container instance IPs of the original application according to the first preset rule if the grayscale application completes the test, where the first preset number is less than all Regarding the number of container instances of the original application, the gray scale application is an application formed after a new function or an improved function is added to the version of the original application.
  • the disabling unit 102 is configured to disable the determined first preset number of IPs and the container instance corresponding to the first preset number of IPs, wherein the first preset number of IPs that are disabled Reclaimed to the default IP address pool.
  • the disabling unit 102 includes: an IP status setting unit 1021, a destruction unit 1022, a recovery unit 1023, and a quantity modification unit 1024.
  • the IP status setting unit 1021 is configured to set the determined use status identifier of the first preset number of IPs as a disabled status.
  • the destroying unit 1022 is configured to destroy the container instances corresponding to the first preset number of IPs.
  • the reclaiming unit 1023 is configured to reclaim the IP whose use status is marked as inactive to a preset IP address pool.
  • the quantity modification unit 1024 is configured to modify the quantity of container instances of the original application according to the first preset quantity.
  • the activation IP determining unit 103 is configured to determine a second preset number of IPs to be activated from the disabled IPs in the preset IP address pool according to a second preset rule, wherein the second preset number is less than or equal to Number of IPs disabled.
  • the activation unit 104 is configured to allocate the IP to be activated to the newly added container instance of the grayscale application.
  • the activation unit 104 includes a host determination unit 1041, a creation unit 1042, and an allocation activation unit 1043.
  • the host determining unit 1041 is configured to determine the host where the container instance to be added to the grayscale application is located according to the grayscale application and the number of IPs to be activated.
  • the creating unit 1042 is configured to create a container instance of the gray scale application on the determined host computer.
  • the allocation enabling unit 1043 is configured to allocate the IP to be enabled to the newly created container instance of the grayscale application.
  • the adding unit 105 is configured to add the configuration code corresponding to the newly added container instance of the gray-scale application in the configuration file of the load balancing application corresponding to the gray-scale application.
  • the adding unit 105 includes a type detecting unit and a configuration adding unit.
  • the type detection unit is used to detect the type of the load balancing application corresponding to the gray scale application.
  • the configuration adding unit is configured to obtain the configuration file of the load balancing application by matching the type according to the type of the load balancing application corresponding to the gray-scale application, and add the gray-scale application to the configuration file. Apply the configuration code corresponding to the newly added container instance.
  • the configuration adding unit 1050 includes a type determining unit 1051, a device determining unit 1052, a configuration code adding unit 1053, a container determining unit 1054, a configuration downloading unit 1055, a pushing unit 1056, and a restarting unit 1057 .
  • the type judging unit 1051 is used to judge whether the type of the load balancing application is F5.
  • the device determining unit 1052 is configured to determine the F5 device where the F5 load balancing application is located according to the gray scale application if the type of the load balancing application is F5.
  • the configuration code adding unit 1053 is configured to obtain the configuration file of the F5 load balancing application on the F5 device, and add the configuration code corresponding to the newly added container instance of the grayscale application in the configuration file.
  • the container determining unit 1054 is configured to determine the container of the load balancing application according to the gray scale application if the type of the load balancing application is non-F5, where the non-F5 load balancing application includes LVS load balancing application and Haproxy load balancing application , Nginx load balancing application.
  • the configuration download unit 1055 is configured to obtain a configuration file from the container of the corresponding load balancing application, and download the obtained configuration file to the local.
  • the configuration code adding unit 1053 is further configured to add the configuration code corresponding to the newly added container instance of the grayscale application in the configuration file.
  • the pushing unit 1056 is configured to push the configuration file added with the configuration code to the container of the corresponding load balancing application.
  • the restart unit 1057 is used to restart the load balancing service of the container of the corresponding load balancing application, so that the configuration file added with the configuration code takes effect.
  • the binding unit 106 is configured to remove the correspondence between the access domain name of the original application and the virtual IP of the load balancing application corresponding to the original application, and combine the access domain name of the original application with the gray-scale application.
  • the virtual IP of the corresponding load balancing application is bound to achieve access to the grayscale application through the access domain name of the original application.
  • the load balancing application virtual IP switching device further includes: a gray-scale image forming unit and a gray-scale application creating unit.
  • the gray-scale mirror image forming unit is used to clone the original application, and on the basis of the cloned original application version, add codes corresponding to new or improved functions to form a gray-scale application mirror.
  • the gray-scale application creation unit is used to create the container instance of the gray-scale application and the load corresponding to the gray-scale application in the area under the test environment according to the creation area of the container instance of the original application and the gray-scale application mirroring Balanced application.
  • FIG. 9 is a schematic block diagram of a computer device provided by an embodiment of the application.
  • the equipment is a terminal and other equipment, such as a server in the PaaS platform.
  • the device 200 includes a processor 202, a memory, and a network interface 203 connected through a system bus 201, where the memory may include a non-volatile storage medium 204 and an internal memory 205.
  • the non-volatile storage medium 204 can store an operating system 2041 and a computer program 2042.
  • the computer program 2042 stored in the non-volatile storage medium is executed by the processor 202, the aforementioned load balancing application virtual IP switching method can be implemented.
  • the processor 202 is used to provide computing and control capabilities, and support the operation of the entire device 200.
  • the internal memory 205 provides an environment for running a computer program in a non-volatile storage medium.
  • the processor 202 can make the processor 202 execute the aforementioned load balancing application virtual IP switching method.
  • the network interface 203 is used for network communication.
  • the structure shown in the figure is only a block diagram of part of the structure related to the solution of the present application, and does not constitute a limitation on the device to which the solution of the present application is applied.
  • the specific device may include a diagram More or fewer components are shown in, or some components are combined, or have different component arrangements.
  • the processor 202 is configured to run a computer program stored in a memory to implement the load balancing application virtual IP switching method in the embodiment of the present application.
  • the embodiment of the computer device shown in FIG. 9 does not constitute a limitation on the specific configuration of the computer device.
  • the computer device may include more or less components than shown in the figure. Or combine certain components, or different component arrangements.
  • the computer device may only include a memory and a processor. In such embodiments, the structures and functions of the memory and the processor are consistent with the embodiment shown in FIG. 9 and will not be repeated here.
  • the processor 202 may be a central processing unit (Central Processing Unit, CPU), and the processor may also be other general-purpose processors or digital signal processors (DSPs). , Application specific integrated circuit (application license Specific Integrated Circuit, ASIC), ready-made programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, etc.
  • the general-purpose processor may be a microprocessor or the processor may also be any conventional processor or the like.
  • a computer-readable storage medium may be a non-volatile computer-readable storage medium.
  • the computer-readable storage medium stores a computer program, where the computer program is executed by a processor to implement the load balancing application virtual IP switching method of the embodiment of the present application.
  • the storage medium is a physical, non-transitory storage medium, such as a U disk, a mobile hard disk, a read-only memory (Read-Only Memory, ROM), a magnetic disk, or an optical disk that can store program codes. medium.
  • a physical, non-transitory storage medium such as a U disk, a mobile hard disk, a read-only memory (Read-Only Memory, ROM), a magnetic disk, or an optical disk that can store program codes. medium.

Landscapes

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

Abstract

本申请实施例提供一种负载均衡应用虚拟IP切换方法、装置、计算机设备及存储介质,其涉及云计算技术领域,可应用于PaaS平台中。所述方法包括:本申请实施例通过停用原应用的第一预设数量的容器实例,以及该第一预设数量的容器实例IP,再新增灰度应用的容器实例,从所停用的IP中获取第二预设数量的IP,并将第二预设数量的IP分配给灰度应用新增的容器实例,在灰度应用的负载均衡应用的配置文件中添加灰度应用新增的容器实例,并设置原应用的访问域名与灰度应用所对应的负载均衡应用的虚拟IP的对应关系。

Description

负载均衡应用虚拟IP切换方法、装置、计算机设备及存储介质
本申请要求于2019年5月17日提交中国专利局、申请号为201910410793.7、申请名称为“负载均衡应用虚拟IP切换方法、装置、计算机设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及云计算技术领域,尤其涉及一种负载均衡应用虚拟IP切换方法、装置、计算机设备及存储介质。
背景技术
若一个应用在原版本的基础上添加了新功能或者改进了原版本的某些功能,那么会涉及到灰度发布。将灰度发布所对应的版本的应用称为灰度应用。灰度应用完成测试后,会形成一个稳定的新版本。目前上线新版本应用(灰度应用)时,需要关闭原应用,以从原应用切换到新版本应用(灰度应用)上,如此在版本切换时会导致服务的中断,影响了用户的体验。
发明内容
本申请实施例提供一种负载均衡应用虚拟IP切换方法、装置、计算机设备及存储介质,可在原应用和灰度应用的版本切换时不会导致服务的中断,提高了版本切换的效率,提升了用户的体验。
第一方面,本申请实施例提供了一种负载均衡应用虚拟IP切换方法,该方法包括:
若灰度应用完成测试,根据第一预设规则从原应用的容器实例IP中确定第一预设数量的IP,其中,所述第一预设数量小于所述原应用的容器实例数量,所述灰度应用是在所述原应用的版本上添加新功能或者改进功能之后所形成的应用;停用所确定的第一预设数量的IP以及所述第一预设数量的IP所对应的容器实例,其中,所停用的所述第一预设数量的IP被回收到预设IP地址池;根据第二预设规则从预设IP地址池所停用的IP中确定第二预设数量的需启用的IP,其中,所述第二预设数量小于或者等于所停用的IP数量;将需启用的IP分配给所述灰度应用新增的容器实例;在所述灰度应用所对应的负载均衡应用的配置文件中添加所述灰度应用新增的容器实例所对应的配置代码;将所述原应用的访问域名与所述原应用所对应的负载均衡应用的虚拟IP的对应关系解除,并将所述原应用的访问域名与所述灰度应用所对应的负载均衡应用的虚拟IP进行绑定,以实现通过所述原应用的访问域名来访问所述灰度应用。
第二方面,本申请实施例提供了一种负载均衡应用虚拟IP切换装置,该负载均衡应用虚拟IP切换装置包括:停用IP确定单元,用于若灰度应用完成测 试,根据第一预设规则从原应用的容器实例IP中确定第一预设数量的IP,其中,所述第一预设数量小于所述原应用的容器实例数量,所述灰度应用是在所述原应用的版本上添加新功能或者改进功能之后所形成的应用;停用单元,用于停用所确定的第一预设数量的IP以及所述第一预设数量的IP所对应的容器实例,其中,所停用的所述第一预设数量的IP被回收到预设IP地址池;启用IP确定单元,用于根据第二预设规则从预设IP地址池所停用的IP中确定第二预设数量的需启用的IP,其中,所述第二预设数量小于或者等于所停用的IP数量;启用单元,用于将需启用的IP分配给所述灰度应用新增的容器实例;添加单元,用于在所述灰度应用所对应的负载均衡应用的配置文件中添加所述灰度应用新增的容器实例所对应的配置代码;绑定单元,用于将所述原应用的访问域名与所述原应用所对应的负载均衡应用的虚拟IP的对应关系解除,并将所述原应用的访问域名与所述灰度应用所对应的负载均衡应用的虚拟IP进行绑定,以实现通过所述原应用的访问域名来访问所述灰度应用。
第三方面,本申请实施例提供了一种计算机设备,所述计算机设备包括存储器,以及与所述存储器相连的处理器;
所述存储器用于存储计算机程序,所述处理器用于运行所述存储器中存储的计算机程序,以执行上述第一方面所述的方法。
第四方面,本申请实施例提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时,实现上述第一方面所述的方法。
附图说明
为了更清楚地说明本申请实施例技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1是本申请实施例提供的负载均衡应用虚拟IP切换方法的流程示意图;
图2是本申请实施例提供的负载均衡应用虚拟IP切换方法的子流程示意图;
图3是本申请实施例提供的负载均衡应用虚拟IP切换方法的子流程示意图;
图4是本申请实施例提供的负载均衡应用虚拟IP切换方法的子流程示意图;
图5是本申请实施例提供的负载均衡应用虚拟IP切换装置的示意性框图;
图6是本申请实施例提供的停用单元的示意性框图;
图7是本申请实施例提供的启用单元的示意性框图;
图8是本申请实施例提供的配置加入单元的示意性框图;
图9是本申请实施例提供的计算机设备的示意性框图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部 的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
图1是本申请实施例提供的负载均衡应用虚拟IP切换方法的流程示意图。如图1所示,该方法包括S101-S106。
S101,若灰度应用完成测试,根据第一预设规则从原应用的容器实例IP中确定第一预设数量的IP,其中,所述第一预设数量小于所述原应用的容器实例数量,所述灰度应用是在所述原应用的版本上添加新功能或者改进功能之后所形成的应用。
其中,灰度应用是在原应用的版本上添加新功能或者改进功能之后所形成的应用。灰度应用完成测试,理解为灰度应用可以成为一个全量升级的新版本。在本实施例中,灰度应用也可以简单理解为应用的一个新版本。
根据第一预设规则从原应用的容器实例IP中确定第一预设数量的IP,包括:获取所述原应用的容器实例IP和容器实例数量,根据第一预设规则从原应用的容器实例IP中确定第一预设数量的IP。
其中,获取原应用的容器实例IP和容器实例数量可通过多种方式。一般情况下,在该PaaS平台的服务器中保存有所有应用所创建的容器实例IP和容器实例数量,如此可从保存应用所创建的容器实例IP和容器实例数量的数据库或者文件中直接获取原应用的容器实例IP和容器实例数量。
其中,根据第一预设规则从原应用的容器实例IP中确定第一预设数量的IP,如可以从原应用的容器实例IP中随机确定第一预设数量的容器实例IP,也可以从原应用的容器实例IP中按照容器实例IP分配的先后顺序确定第一预设数量的容器实例IP,还可以从原应用的容器实例IP中优先确定不属于同一个网段中的容器实例IP(如某一个网段中的容器实例IP较多,那么优先从其他网段中获取第一预设数量的IP)、再按照随机或者容器实例IP分配的选后顺序确定第一预设数量的IP,还按照其他的规则选择第一预设数量的IP。其中,第一预设数量小于原应用的容器实例数量,如原应用的容器实例数量为8个,第一预设数量可以为4个等。其中,第一预设数量小于原应用的容器实例数量的目的是,在对原应用的第一预设数量的容器实例进行处理时,原应用仍然有容器实例(除了第一预设数量之外的其他容器实例)是正常运行的,正常运行的容器实例可以提供服务,如此,不会导致服务的中断。
在一实施例中,可开发一个对应的管理面板,以在管理面板上显示应用与应用的容器实例IP的对应关系。如此,通过调用管理面板,获取在管理面板上显示的原应用以及原应用的容器实例IP。从显示的原应用的容器实例IP中按照第一预设规则选择第一预设数量的容器实例IP,并接收按照第一预设规则选择的第一预设数量的容器实例IP作为所确定的第一预设数量的IP。
S102,停用所确定的第一预设数量的IP以及所述第一预设数量的IP所对应的容器实例,其中,所停用的所述第一预设数量的IP被回收到预设IP地址池。
其中,将所述原应用的容器实例IP和灰度应用的容器实例IP作为预设IP 地址池。在一实施例中,在步骤S102之前,预先将原应用的容器实例IP和灰度应用的容器实例IP作为预设IP地址池,并设置原应用的容器实例和灰度应用的容器实例共享该预设IP地址池。如此,一旦一个IP被分配给原应用的容器实例和原应用的灰度应用的容器实例,那么该IP加入到共享的预设IP地址池中,同时该IP不能被其他应用占用,只可供原应用的容器实例和灰度应用的容器实例使用。设置原应用的容器实例IP和灰度应用的容器实例IP共享预设IP地址池是因为,一般情况下,一个应用的容器实例IP被停用之后,会被回收到空闲IP地址池,而空闲IP地址池的IP可以分配给任意一个容器应用使用。如此,若停用原应用的容器实例IP或者灰度应用的容器实例IP之后,停用的IP被回收到空闲IP地址池,不再属于原应用或者灰度应用了。而将原应用的容器实例IP和灰度应用的容器实例IP作为预设IP地址池,并设置原应用的容器实例IP和灰度应用的容器实例IP共享该预设IP地址池,那么预设IP地址池中的IP只属于原应用的容器实例和灰度应用的容器实例,不会被其他应用占用。
在确定了第一预设数量的容器实例IP后,停用所确定的容器实例IP以及容器实例IP所对应的容器实例。
在一实施例中,如图2所示,步骤S102包括以下步骤S1021-S1024。
S1021,设置所确定的第一预设数量的IP的使用状态标识为停用状态。
需要注意的是,将第一预设数量的IP设置的使用状态设置为停用状态,理解为该IP仍然属于该应用,不可以被其他应用使用。
S1022,销毁所述第一预设数量的IP所对应的容器实例。
如通过编排工具下发销毁指令到容器实例所对应的宿主机,销毁指令如docker stop指令,在所对应的宿主机上将对应的容器实例进行销毁。其中,销毁容器实例也可理解为缩容容器实例,销毁容器实例将会释放该容器实例所占用的所有资源,如包括容器实例所对应的环境信息、关闭文件输入输出流、关闭与数据库的连接、修改其他数据库中保存的该容器实例的相关信息等。其中,编排工具如marathon等。
需要注意的是,首先停用容器实例的IP再销毁容器实例,而不是先销毁容器实例再停用容器实例的IP,是为了以防容器实例的IP有效,而容器实例无效,原应用的负载均衡应用将接收到的用户访问请求分配到该容器实例,而实际上该容器实例已经无效了,那么会导致用户访问请求的请求失败。
S1023,回收使用状态标识为停用状态的IP到预设IP地址池。
需要注意的是,该预设IP地址池中的IP是原应用与灰度应用可共享的IP。在该预设IP地址池中,使用状态标识为停用的IP不能被其他应用占用。
S1024,根据所述第一预设数量修改所述原应用的容器实例数量。
其中,修改后的容器实例数量为原应用的原容器实例数量减去第一预设数量。
需要注意的是,步骤S1023与步骤S1024的执行顺序并不严格限制,也可以先执行步骤S1024再执行步骤S1023。
S103,根据第二预设规则从预设IP地址池所停用的IP中确定第二预设数量的需启用的IP,其中,所述第二预设数量小于或者等于所停用的IP数量。
如可以从预设IP地址池中的使用状态标识为停用的IP中随机确定第二预设数量的容器实例IP,也可以从使用状态标识为停用的IP中按照IP使用状态标识改变为停用状态的先后顺序确定第二预设数量的容器实例IP等,还可以根据其他的规则确定第二预设数量的容器实例IP。其中,若第二预设数量小于所停用的IP数量,意味着将所停用的一部分IP用来分配给灰度应用新增的容器实例,意味着灰度应用需要新增容器实例的数量小于原应用销毁的容器实例的数量。若第二预设数量等于所停用的IP数量,意味着将所停用的所有IP用来分配给灰度应用新增的容器实例。那么意味着原应用有多少个容器实例销毁,那么灰度应用就需要新增多少个容器实例。
在一实施例中,预设IP地址池中所停用的IP可能大于本次所停用的第一预设数量的IP。那么可以理解为,在本次停用原应用的容器实例IP之前,还停用过原应用的容器实例IP或者还停用过灰度应用的容器实例IP,如此,导致预设IP地址池中所停用的IP大于本次所停用的第一预设数量的IP。
在一实施例中,若已开发对应的管理面板,在管理面板上可显示应用与应用的容器实例IP的对应关系、以及IP的使用状态标识。如此,获取并在管理面板上显示原应用和灰度应用所对应的容器IP以及容器IP的使用状态标识;从使用状态标识为停用的IP中选择第二预设数量的需启用的IP,接收所选择的需启用的IP作为所确定的需启用的IP。并从应用信息中选择灰度应用,如根据灰度应用所对应的应用名选择灰度应用,接收所选择的灰度应用,以进一步将需启用的IP分配给灰度应用。
S104,将需启用的IP分配给所述灰度应用新增的容器实例。
确定了需启用的IP后,将需启用的IP分配给新增的灰度应用的容器实例。
在一实施例中,如图3所示,所述S104包括以下步骤S1041-S1043。
S1041,根据所述灰度应用以及需启用的IP数量确定所述灰度应用需新增的容器实例所在的宿主机。
具体地,根据灰度应用确定灰度应用需新增的容器实例所在的区域,根据需启用的IP数量从所述区域中确定相同数量的需新增的灰度应用的容器实例的宿主机(宿主机IP)。其中,宿主机的数量与新增的容器实例的数量相同,新增的容器实例的数量与需启用的IP数量相同。
可以理解地,先确定灰度应用需启用的IP的数量,再根据需启用的IP的数量来确定灰度应用新增的容器实例数量,是因为启用IP是从预设IP地址池中的所停用的IP中获得的,所停用的IP的数量是有限的,不是无限的。因此,需要先根据第二预设数量的启用IP来确定新增的容器实例的数量。
S1042,在所确定的宿主机上创建所述灰度应用的容器实例。
具体地,发送新建命令到编排工具,以通过编排工具推送新建命令到对应的宿主机,并通过新建命令在对应的宿主机上新建灰度应用所对应的容器实例。其中,新建命令中包括有灰度应用的应用镜像等信息。
需要注意的是,不同区域的编排工具是不同的,根据灰度所在的区域确定所需要使用的编排工具。如此,编排工具与灰度应用所在的区域相同,也与新增灰度应用的容器实例的宿主机所在的区域相同,提高了新增容器实例的速度。将新建命令发送到所需要使用的编排工具上,以通过编排工具推送新建命令到对应的宿主机,并在对应的宿主机上创建灰度应用所对应的容器实例,将所创建的灰度应用的容器实例作为灰度应用新增的容器实例。
S1043,将需启用的IP分配给所述灰度应用新创建的容器实例。
具体地,通过运维工具如ansible工具去连接容器实例,将所创建的容器实例与需启用的IP进行绑定。
S105,在所述灰度应用所对应的负载均衡应用的配置文件中添加所述灰度应用新增的容器实例所对应的配置代码。
其中,灰度应用的负载均衡应用的类型包括F5、LVS、Haproxy、Nginx等。灰度应用的负载均衡应用的类型可以在PaaS平台数据库中获取。
在一实施例中,步骤S105包括:检测所述灰度应用所对应的负载均衡应用的类型;根据所述灰度应用所对应的负载均衡应用的类型,通过与所述类型相匹配的方式获取所述负载均衡应用的配置文件并在所述配置文件中加入所述灰度应用新增的容器实例所对应的配置代码。
其中,F5负载均衡应用是硬负载均衡应用,是在具体的F5设备上创建的,而LVS、Haproxy、Nginx负载均衡应用是软负载均衡应用,因此F5负载均衡应用和LVS、Haproxy、Nginx负载均衡应用获取配置文件的方式、对配置文件修改的方式、使配置文件生效的方式以及添加的配置代码等都存在不同。
在一实施例中,如图4所示,根据所述灰度应用所对应的负载均衡应用的类型,通过与所述类型相匹配的方式获取所述负载均衡应用的配置文件并在所述配置文件中加入所述灰度应用新增的容器实例所对应的配置代码的步骤,包括以下步骤S1051-S1058。
S1051,判断所述负载均衡应用的类型是否为F5。
S1052,若所述负载均衡应用的类型为F5,根据所述灰度应用确定F5负载均衡应用所在的F5设备。
S1053,在所述F5设备上获取所述F5负载均衡应用的配置文件,并在所述配置文件中加入所述灰度应用新增的容器实例所对应的配置代码。
在所述配置文件中加入所述灰度应用新增的容器实例所对应的配置代码,包括:在配置文件中添加pool member(新增的灰度应用的容器实例)的信息;修改pool信息中的member数量。其中,添加pool member(新增的灰度应用的容器实例)的信息,包括新增的灰度应用的容器实例的IP地址、端口信息;将该容器实例启动,并修改容器实例的监听状态为运行(running)状态。其中,端口默认与之前存在的容器实例的端口相同,如80端口。其中,修改后的member数量为修改前的member数量与新增的灰度应用的容器实例的数量。
S1054,若所述负载均衡应用的类型为非F5,根据所述灰度应用确定所对应的所述负载均衡应用的容器,其中非F5负载均衡应用包括LVS负载均衡应用、 Haproxy负载均衡应用、Nginx负载均衡应用。
根据所述灰度应用确定所述负载均衡应用的容器,可以理解为,根据灰度应用确定灰度应用所对应的负载均衡应用的负载均衡应用的容器的虚拟IP。
S1055,从对应的负载均衡应用的容器中获取配置文件,将所获取的配置文件下载到本地。
根据虚拟IP从对应容器中获取对应负载均衡应用的配置文件;将所获取的配置文件下载到本地的一个预设目录。需要注意的是,将所获取的配置文件下载到本地,以对配置文件进行修改,而不是直接远程在对应负载均衡应用容器上进行修改,是考虑到若在对配置文件进行修改的过程中,网络出现中断,那么改写的过程也会出现中断,即排除远程改写的过程中出现的意外情况对改写造成的影响,另一方面,在本地改写配置文件比在远程改写配置文件的速度要快。即在本地写文件的速度要比远程写文件的速度快,如至少不用通过网络进行传输。
S1056,在所述配置文件中加入所述灰度应用新增的容器实例所对应的配置代码。
具体地,步骤S1056包括:获取对应的容器实例配置代码模板;在对应的容器实例配置代码模板中添加新增的灰度应用的容器实例的IP和端口信息(其中,端口默认与之前存在的容器实例的端口相同,如80端口)以形成新增的容器实例的配置代码;将新增的容器实例的配置代码追加到配置文件中最后一个容器实例的配置代码之后。
其中,LVS负载均衡应用、Haproxy负载均衡应用、Nginx应用所对应的容器实例配置代码模板不同。如LVS负载均衡应用中容器实例配置代码模板中包括容器实例IP信息、容器实例的端口信息(用于提供服务的端口信息)、该容器实例(即负载均衡应用的服务器)所对应的权重信息、该容器实例所对应的健康检查方式信息(包括连接超时时间、重连次数、重连间隔时间等)信息等,将配置代码模板中的容器实例IP参数、容器实例的端口参数以新增的灰度应用的容器实例的IP和端口进行替换,以形成新增的容器实例的配置代码,将新增的容器实例的配置代码追加到配置文件(该处的配置文件包括keepalived.conf)中最后一个容器实例的配置代码之后。如Haproxy负载均衡应用中,配置代码模板可以是以server节点开头的一段代码,如server容器实例IP:容器实例的端口check inter 30000 rise 1 fall 2,将配置代码模板中的容器实例IP参数、容器实例的端口参数以新增的灰度应用的容器实例的IP和端口进行替换,以形成新增的容器实例的配置代码,将新增的容器实例的配置代码追加到配置文件(该处的配置文件包括Haproxy.conf)中最后一个server代码段的后面,其中,可通过定位Haproxy负载均衡应用的option forwardfor节点中的server节点来定位最后一个server代码段。如在Nginx负载均衡应用中,配置代码模板也是以server节点开头的一段代码,在配置代码模板中加入了新增的容器实例的IP和容器实例的端口后,加入到配置文件中最后一个容器实例的配置代码。其中,可以通过定位upstream节点中的server 内容来定位配置文件中最后一个容器实例的配置代码。
S1057,将加入了所述配置代码的配置文件推送至对应的负载均衡应用的容器中。
S1058,重启对应的负载均衡应用的容器的负载均衡服务,以使得加入了所述配置代码的配置文件生效。
如可以用restart命令重启所对应的负载均衡应用的负载均衡服务。
该实施例进一步限定根据不同负载均衡应用的类型来确定不同的方式来实现在灰度应用的配置文件中加入灰度应用新增的容器实例所对应的配置代码。该实施例的过程自动完成,无需人工干预,提高了速度。
S106,将所述原应用的访问域名与所述原应用所对应的负载均衡应用的虚拟IP的对应关系解除,并将所述原应用的访问域名与所述灰度应用所对应的负载均衡应用的虚拟IP进行绑定,以实现通过所述原应用的访问域名来访问所述灰度应用。
具体地,在该PaaS平台的服务器中保存有原应用的访问域名与负载均衡应用的虚拟IP的对应关系。所述原应用的访问域名与所述原应用所对应的负载均衡应用的虚拟IP的对应关系解除,可以理解为删除所保存的原应用的访问域名与原应用所对应的负载均衡应用的虚拟IP的对应关系。将所述原应用的访问域名与所述灰度应用所对应的负载均衡应用的虚拟IP进行绑定,可以理解为在数据库中添加原应用的访问域名与所述灰度应用所对应的负载均衡应用的虚拟IP的对应关系。
在原应用的访问域名与原应用所对应的负载均衡应用的虚拟IP的对应关系解除之前,用户仍可以通过原应用的访问域名来访问原应用,即访问原应用的部分容器实例(除了第一预设数量的容器实例),如此,原应用所提供的服务不会中断。
在原应用的访问域名与所述灰度应用所对应的负载均衡应用的虚拟IP进行绑定之后,用户即可以通过原应用的访问域名来访问灰度应用所对应的容器实例,如此,灰度应用的容器实例即开始提供服务。
以下举例对本实施例的方案进行简单的说明。如原应用的容器实例数量为8个,灰度应用的容器实例数量为1个(假设默认创建的灰度应用的容器实例数量为1)。将原应用的容器实例IP和灰度应用的容器实例IP作为预设IP地址池,原应用的容器实例和灰度应用的容器实例共享该预设IP地址池,预设IP地址池中的IP数量为9个。若第一预设数量为5个,那么从原应用的容器实例IP中确定5个IP地址,销毁该5个IP地址所对应的容器实例,并将该5个IP地址回收到预设IP地址池,设置该5个IP地址的使用状态为停用状态。原应用还剩3个容器实例,在没有修改用户访问域名与原应用所对应的负载均衡应用的虚拟IP的对应关系之前,用户仍可以通过剩下的3个容器实例访问原应用。确定第二预设数量(小于或者等于第一预设数量),第二预设数量可以为1、或者2或者3或者4或者5。若第二预设数量为5个,那么可理解为所有回收的IP将被重新利用。新增5个灰度应用的容器实例,将5个停用状态的 IP分配给灰度应用新增的5个容器实例。在灰度应用所对应的负载均衡应用的配置文件中添加新增的容器实例信息,如此灰度应用所对应的负载均衡应用的配置文件中就会存在6个灰度应用的容器实例(默认创建的1个容器实例和新增的5个容器实例)。将用户访问域名与原应用的负载均衡应用的VIP的对应关系解除,在解除之前,用户通过访问域名仍可以访问原应用的另外3个容器实例,如此在切换的过程中,服务不会间断,因为还有另外3个容器实例存在,这3个容器实例可以继续提供服务。在解除之后,将用户访问域名与灰度应用所对应的负载均衡应用的VIP绑定。如此,用户访问时不发生任何改变,通过原应用的访问域名即可访问灰度应用的6个容器实例。
上述方法实施例通过停用原应用的第一预设数量的容器实例,以及该第一预设数量的容器实例IP,再新增灰度应用的容器实例,从所停用的IP中获取第二预设数量的IP,并将第二预设数量的IP分配给灰度应用新增的容器实例,在灰度应用的负载均衡应用的配置文件中添加灰度应用新增的容器实例,并设置原应用的访问域名与灰度应用所对应的负载均衡应用的虚拟IP的对应关系。从而实现了将原应用的虚拟IP切换到灰度应用,通过原应用的访问域名来访问灰度应用。上述方法实施例快速地实现了原应用的下线,灰度应用的上线,在原应用和灰度应用的版本切换时不会导致服务的中断,实现了无痕切换,提高了版本切换的效率,提升了用户的体验。同时上述实施例无需修改访问域名,通过同一个访问域名(原应用的访问域名)就可以访问灰度应用。
在一实施例中,在步骤S101之前,所述负载均衡应用虚拟IP切换方法包括以下步骤:克隆原应用,并在克隆的原应用版本的基础上,添加新功能或者改进功能所对应的代码,以形成灰度应用镜像;根据所述原应用的容器实例的创建区域以及所述灰度应用镜像,在测试环境下所述区域中创建灰度应用的容器实例以及灰度应用所对应的负载均衡应用。
其中,克隆原应用,包括克隆原应用的代码,原应用所对应的配置文件、系统文件、分配的内存和CPU个数等等。克隆原版本的应用,以得到一个与原应用完全相同的应用。在该克隆的原应用版本的基础上,添加新功能或者改进功能所对应的代码,以形成灰度应用镜像。
另外,需要注意的是,原应用是可以对外提供服务的,因此原应用已经创建了对应的容器实例以及原应用所对应的负载均衡应用。如此,可获取原应用容器实例的创建区域,其中,创建区域指的是所创建的容器实例的机房位置等。在灰度应用通过简单测试(如开发人员的简单测试)后,将灰度应用推送到测试环境下与原应用容器实例创建区域相同区域下的灰度应用所对应的镜像仓库中。需要注意的是,每个不同的机房中会对应有不同应用环境的镜像仓库,如开发环境(该应用的容器实例创建成功后供内部开发使用)、生产环境(意味着该应用的容器实例创建成功后对接外部环境,或者供外部用户进行访问)、测试环境(意味着该应用的容器实例创建成功后供测试使用)。在创建灰度应用的容器实例时,可根据设置灰度应用容器实例数量(如果不进行设置,那么会使用默认的值,默认的值为1,即默认的灰度应用容器实例数量为1)并从对 应镜像仓库中选择的灰度应用镜像,在所述区域创建对应数量的容器实例,并为所创建的容器实例分配相同数量的容器实例IP。
另外,若在创建灰度应用的容器实例的过程中,选择了创建负载均衡应用,那么会在创建灰度应用的容器实例的同时创建灰度应用所对应的负载均衡应用,并设置所创建的灰度应用和所创建的负载均衡应用的关联关系,同时会自动生成所创建的负载均衡应用的配置文件以及负载均衡应用所对应的域名。若在创建灰度应用的容器实例的过程中,没有选择创建负载均衡应用,那么在灰度应用的容器实例创建完成后,会为该灰度应用创建负载均衡应用。创建该灰度应用的负载均衡应用时会自动生成所创建的负载均衡应用的配置文件以及负载均衡应用所对应的域名。
该实施例进一步限定如何创建灰度应用的容器实例。图5是本申请实施例提供的负载均衡应用虚拟IP切换装置的示意性框图。该装置包括用于执行上述负载均衡应用虚拟IP切换方法所对应的单元。具体地,如图5所示,该装置100包括停用IP确定单元101、停用单元102、启用IP确定单元103、启用单元104、添加单元105以及绑定单元106。
停用IP确定单元101,用于若灰度应用完成测试,根据第一预设规则从原应用的容器实例IP中确定第一预设数量的IP,其中,所述第一预设数量小于所述原应用的容器实例数量,所述灰度应用是在所述原应用的版本上添加新功能或者改进功能之后所形成的应用。
停用单元102,用于停用所确定的第一预设数量的IP以及所述第一预设数量的IP所对应的容器实例,其中,所停用的所述第一预设数量的IP被回收到预设IP地址池。
在一实施例中,如图6所示,停用单元102包括:IP状态设置单元1021、销毁单元1022、回收单元1023、数量修改单元1024。其中,IP状态设置单元1021,用于设置所确定的第一预设数量的IP的使用状态标识为停用状态。销毁单元1022,用于销毁所述第一预设数量的IP所对应的容器实例。回收单元1023,用于回收使用状态标识为停用状态的IP到预设IP地址池。数量修改单元1024,用于根据所述第一预设数量修改所述原应用的容器实例数量。
启用IP确定单元103,用于根据第二预设规则从预设IP地址池所停用的IP中确定第二预设数量的需启用的IP,其中,所述第二预设数量小于或者等于所停用的IP数量。
启用单元104,用于将需启用的IP分配给所述灰度应用新增的容器实例。
在一实施例中,如图7所示,启用单元104包括宿主机确定单元1041、创建单元1042、分配启用单元1043。其中,宿主机确定单元1041,用于根据所述灰度应用以及需启用的IP数量确定所述灰度应用需新增的容器实例所在的宿主机。创建单元1042,用于在所确定的宿主机上创建所述灰度应用的容器实例。分配启用单元1043,用于将需启用的IP分配给所述灰度应用新创建的容器实例。
添加单元105,用于在所述灰度应用所对应的负载均衡应用的配置文件中 添加所述灰度应用新增的容器实例所对应的配置代码。
在一实施例中,所述添加单元105包括类型检测单元、配置加入单元。其中,类型检测单元,用于检测所述灰度应用所对应的负载均衡应用的类型。配置加入单元,用于根据所述灰度应用所对应的负载均衡应用的类型,通过与所述类型相匹配的方式获取所述负载均衡应用的配置文件并在所述配置文件中加入所述灰度应用新增的容器实例所对应的配置代码。
在一实施例中,如图8所示,配置加入单元1050包括类型判断单元1051、设备确定单元1052、配置代码加入单元1053、容器确定单元1054、配置下载单元1055、推送单元1056以及重启单元1057。其中,类型判断单元1051,用于判断所述负载均衡应用的类型是否为F5。设备确定单元1052,用于若所述负载均衡应用的类型为F5,根据所述灰度应用确定F5负载均衡应用所在的F5设备。配置代码加入单元1053,用于在所述F5设备上获取所述F5负载均衡应用的配置文件,并在所述配置文件中加入所述灰度应用新增的容器实例所对应的配置代码。容器确定单元1054,用于若所述负载均衡应用的类型为非F5,根据所述灰度应用确定所述负载均衡应用的容器,其中非F5负载均衡应用包括LVS负载均衡应用、Haproxy负载均衡应用、Nginx负载均衡应用。配置下载单元1055,用于从对应的负载均衡应用的容器中获取配置文件,将所获取的配置文件下载到本地。配置代码加入单元1053,还用于在所述配置文件中加入所述灰度应用新增的容器实例所对应的配置代码。推送单元1056,用于将加入了所述配置代码的配置文件推送至对应的负载均衡应用的容器中。重启单元1057,用于重启对应的负载均衡应用的容器的负载均衡服务,以使得加入了所述配置代码的配置文件生效。绑定单元106,用于将所述原应用的访问域名与所述原应用所对应的负载均衡应用的虚拟IP的对应关系解除,并将所述原应用的访问域名与所述灰度应用所对应的负载均衡应用的虚拟IP进行绑定,以实现通过所述原应用的访问域名来访问所述灰度应用。
在一实施例中,所述负载均衡应用虚拟IP切换装置还包括:灰度镜像形成单元、灰度应用创建单元。其中,灰度镜像形成单元,用于克隆原应用,并在克隆的原应用版本的基础上,添加新功能或者改进功能所对应的代码,以形成灰度应用镜像。灰度应用创建单元,用于根据所述原应用的容器实例的创建区域以及所述灰度应用镜像,在测试环境下所述区域中创建灰度应用的容器实例以及灰度应用所对应的负载均衡应用。
需要说明的是,所属领域的技术人员可以清楚地了解到,上述装置和各单元的具体实现过程,可以参考前述方法实施例中的相应描述,为了描述的方便和简洁,在此不再赘述。
上述装置可以实现为一种计算机程序的形式,计算机程序可以在如图9所示的计算机设备上运行。图9为本申请实施例提供的一种计算机设备的示意性框图。该设备为终端等设备,如PaaS平台中的服务器等。该设备200包括通过系统总线201连接的处理器202、存储器和网络接口203,其中,存储器可以包括非易失性存储介质204和内存储器205。
该非易失性存储介质204可存储操作系统2041和计算机程序2042。该非易失性存储介质中所存储的计算机程序2042被处理器202执行时,可实现上述所述的负载均衡应用虚拟IP切换方法。该处理器202用于提供计算和控制能力,支撑整个设备200的运行。该内存储器205为非易失性存储介质中的计算机程序的运行提供环境,该计算机程序被处理器202执行时,可使得处理器202执行上述所述的负载均衡应用虚拟IP切换方法。该网络接口203用于进行网络通信。本领域技术人员可以理解,图中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的设备的限定,具体的设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。
其中,所述处理器202用于运行存储在存储器中的计算机程序,以实现本申请实施例的负载均衡应用虚拟IP切换方法。
本领域技术人员可以理解,图9中示出的计算机设备的实施例并不构成对计算机设备具体构成的限定,在其他实施例中,计算机设备可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。例如,在一些实施例中,计算机设备可以仅包括存储器及处理器,在这样的实施例中,存储器及处理器的结构及功能与图9所示实施例一致,在此不再赘述。
应当理解,在本申请实施例中,所称处理器202可以是中央处理单元(Central Processing Unit,CPU),该处理器还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(应用程序lication Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
在本申请的另一实施例中提供计算机可读存储介质。该计算机可读存储介质可以为非易失性的计算机可读存储介质。该计算机可读存储介质存储有计算机程序,其中计算机程序被处理器执行时实现本申请实施例的负载均衡应用虚拟IP切换方法。
所述存储介质为实体的、非瞬时性的存储介质,例如可以是U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、磁碟或者光盘等各种可以存储程序代码的实体存储介质。
所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,上述描述的设备、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到各种等效的修改或替换,这些修改或替换都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以权利要求的保护范围为准。

Claims (20)

  1. 一种负载均衡应用虚拟IP切换方法,所述方法包括:
    若灰度应用完成测试,根据第一预设规则从原应用的容器实例IP中确定第一预设数量的IP,其中,所述第一预设数量小于所述原应用的容器实例数量,所述灰度应用是在所述原应用的版本上添加新功能或者改进功能之后所形成的应用;
    停用所确定的第一预设数量的IP以及所述第一预设数量的IP所对应的容器实例,其中,所停用的所述第一预设数量的IP被回收到预设IP地址池;
    根据第二预设规则从预设IP地址池所停用的IP中确定第二预设数量的需启用的IP,其中,所述第二预设数量小于或者等于所停用的IP数量;
    将需启用的IP分配给所述灰度应用新增的容器实例;
    在所述灰度应用所对应的负载均衡应用的配置文件中添加所述灰度应用新增的容器实例所对应的配置代码;
    将所述原应用的访问域名与所述原应用所对应的负载均衡应用的虚拟IP的对应关系解除,并将所述原应用的访问域名与所述灰度应用所对应的负载均衡应用的虚拟IP进行绑定,以实现通过所述原应用的访问域名来访问所述灰度应用。
  2. 根据权利要求1所述的方法,其中,所述停用所确定的第一预设数量的IP以及所述第一预设数量的IP所对应的容器实例,包括:
    设置所确定的第一预设数量的IP的使用状态标识为停用状态;
    销毁所述第一预设数量的IP所对应的容器实例;
    回收使用状态标识为停用状态的IP到预设IP地址池;
    根据所述第一预设数量修改所述原应用的容器实例数量。
  3. 根据权利要求1所述的方法,其中,所述将需启用的IP分配给所述灰度应用新增的容器实例,包括:
    根据所述灰度应用以及需启用的IP数量确定所述灰度应用需新增的容器实例所在的宿主机;
    在所确定的宿主机上创建所述灰度应用的容器实例;
    将需启用的IP分配给所述灰度应用新创建的容器实例。
  4. 根据权利要求3所述的方法,其中,所述在所确定的宿主机上创建所述灰度应用的容器实例,包括:
    发送新建命令到编排工具,以通过所述编排工具推送所述新建命令到所确定的宿主机,并通过所述新建命令在对应的宿主机上创建所述灰度应用所对应的容器实例,其中,所述新建命令中包括灰度应用的镜像信息。
  5. 根据权利要求1所述的方法,其中,在所述灰度应用完成测试之前,所述方法还包括:
    克隆原应用,并在克隆的原应用版本的基础上,添加新功能或者改进功能所对应的代码,以生成灰度应用镜像;
    根据所述原应用的容器实例的创建区域以及所述灰度应用镜像,在测试环 境下所述区域中创建灰度应用的容器实例以及灰度应用所对应的负载均衡应用。
  6. 根据权利要求1所述的方法,其中,所述在所述灰度应用所对应的负载均衡应用的配置文件中添加所述灰度应用新增的容器实例的配置代码,包括:
    检测所述灰度应用所对应的负载均衡应用的类型;
    根据所述灰度应用所对应的负载均衡应用的类型,通过与所述类型相匹配的方式获取所述负载均衡应用的配置文件并在所述配置文件中加入所述灰度应用新增的容器实例所对应的配置代码。
  7. 根据权利要求6所述的方法,其中,所述根据所述灰度应用所对应的负载均衡应用的类型,通过与所述类型相匹配的方式获取所述负载均衡应用的配置文件并在所述配置文件中加入所述灰度应用新增的容器实例所对应的配置代码,包括:
    若所述负载均衡应用的类型为F5,根据所述灰度应用确定F5负载均衡应用所在的F5设备;
    在所述F5设备上获取所述F5负载均衡应用的配置文件,并在所述配置文件中加入所述灰度应用新增的容器实例所对应的配置代码;
    若所述负载均衡应用的类型为非F5,根据所述灰度应用确定所述负载均衡应用的容器,其中非F5负载均衡应用包括LVS负载均衡应用、Haproxy负载均衡应用、Nginx负载均衡应用;
    从对应的负载均衡应用的容器中获取配置文件,将所获取的配置文件下载到本地;
    在所述配置文件中加入所述灰度应用新增的容器实例所对应的配置代码;
    将加入了所述配置代码的配置文件推送至对应的负载均衡应用的容器中;
    重启对应的负载均衡应用的容器的负载均衡服务,以使得加入了所述配置代码的配置文件生效。
  8. 根据权利要求7所述的方法,其中,所述在所述配置文件中加入所述灰度应用新增的容器实例所对应的配置代码,包括:
    获取对应的容器实例配置代码模板;
    在对应的容器实例配置代码模板中添加新增的灰度应用的容器实例的IP和端口信息以形成新增的容器实例的配置代码;
    将新增的容器实例的配置代码追加到配置文件中最后一个容器实例的配置代码之后。
  9. 根据权利要求8所述的方法,其中,所述LVS负载均衡应用中容器实例配置代码模板中包括容器实例IP信息、容器实例的端口信息、所述容器实例所对应的权重信息、所述容器实例所对应的健康检查方式信息;
    所述Nginx负载均衡应用和所述Haproxy负载均衡应用中容器实例配置代码模板是以server节点开头的代码。
  10. 一种负载均衡应用虚拟IP切换装置,包括:
    停用IP确定单元,用于若灰度应用完成测试,根据第一预设规则从原应用 的容器实例IP中确定第一预设数量的IP,其中,所述第一预设数量小于所述原应用的容器实例数量,所述灰度应用是在所述原应用的版本上添加新功能或者改进功能之后所形成的应用;
    停用单元,用于停用所确定的第一预设数量的IP以及所述第一预设数量的IP所对应的容器实例,其中,所停用的所述第一预设数量的IP被回收到预设IP地址池;
    启用IP确定单元,用于根据第二预设规则从预设IP地址池所停用的IP中确定第二预设数量的需启用的IP,其中,所述第二预设数量小于或者等于所停用的IP数量;
    启用单元,用于将需启用的IP分配给所述灰度应用新增的容器实例;
    添加单元,用于在所述灰度应用所对应的负载均衡应用的配置文件中添加所述灰度应用新增的容器实例所对应的配置代码;
    绑定单元,用于将所述原应用的访问域名与所述原应用所对应的负载均衡应用的虚拟IP的对应关系解除,并将所述原应用的访问域名与所述灰度应用所对应的负载均衡应用的虚拟IP进行绑定,以实现通过所述原应用的访问域名来访问所述灰度应用。
  11. 一种计算机设备,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,其中,所述处理器执行所述计算机程序时实现以下步骤:
    若灰度应用完成测试,根据第一预设规则从原应用的容器实例IP中确定第一预设数量的IP,其中,所述第一预设数量小于所述原应用的容器实例数量,所述灰度应用是在所述原应用的版本上添加新功能或者改进功能之后所形成的应用;
    停用所确定的第一预设数量的IP以及所述第一预设数量的IP所对应的容器实例,其中,所停用的所述第一预设数量的IP被回收到预设IP地址池;
    根据第二预设规则从预设IP地址池所停用的IP中确定第二预设数量的需启用的IP,其中,所述第二预设数量小于或者等于所停用的IP数量;
    将需启用的IP分配给所述灰度应用新增的容器实例;
    在所述灰度应用所对应的负载均衡应用的配置文件中添加所述灰度应用新增的容器实例所对应的配置代码;
    将所述原应用的访问域名与所述原应用所对应的负载均衡应用的虚拟IP的对应关系解除,并将所述原应用的访问域名与所述灰度应用所对应的负载均衡应用的虚拟IP进行绑定,以实现通过所述原应用的访问域名来访问所述灰度应用。
  12. 根据权利要求11所述的计算机设备,其中,所述停用所确定的第一预设数量的IP以及所述第一预设数量的IP所对应的容器实例,包括:
    设置所确定的第一预设数量的IP的使用状态标识为停用状态;
    销毁所述第一预设数量的IP所对应的容器实例;
    回收使用状态标识为停用状态的IP到预设IP地址池;
    根据所述第一预设数量修改所述原应用的容器实例数量。
  13. 根据权利要求11所述的计算机设备,其中,所述将需启用的IP分配给所述灰度应用新增的容器实例,包括:
    根据所述灰度应用以及需启用的IP数量确定所述灰度应用需新增的容器实例所在的宿主机;
    在所确定的宿主机上创建所述灰度应用的容器实例;
    将需启用的IP分配给所述灰度应用新创建的容器实例。
  14. 根据权利要求13所述的计算机设备,其中,所述在所确定的宿主机上创建所述灰度应用的容器实例,包括:
    发送新建命令到编排工具,以通过所述编排工具推送所述新建命令到所确定的宿主机,并通过所述新建命令在对应的宿主机上创建所述灰度应用所对应的容器实例,其中,所述新建命令中包括灰度应用的镜像信息。
  15. 根据权利要求11所述的计算机设备,其中,在所述灰度应用完成测试之前,所述处理器执行所述计算机程序时还实现以下步骤:
    克隆原应用,并在克隆的原应用版本的基础上,添加新功能或者改进功能所对应的代码,以生成灰度应用镜像;
    根据所述原应用的容器实例的创建区域以及所述灰度应用镜像,在测试环境下所述区域中创建灰度应用的容器实例以及灰度应用所对应的负载均衡应用。
  16. 根据权利要求11所述的计算机设备,其中,所述在所述灰度应用所对应的负载均衡应用的配置文件中添加所述灰度应用新增的容器实例的配置代码,包括:
    检测所述灰度应用所对应的负载均衡应用的类型;
    根据所述灰度应用所对应的负载均衡应用的类型,通过与所述类型相匹配的方式获取所述负载均衡应用的配置文件并在所述配置文件中加入所述灰度应用新增的容器实例所对应的配置代码。
  17. 根据权利要求16所述的计算机设备,其中,所述根据所述灰度应用所对应的负载均衡应用的类型,通过与所述类型相匹配的方式获取所述负载均衡应用的配置文件并在所述配置文件中加入所述灰度应用新增的容器实例所对应的配置代码,包括:
    若所述负载均衡应用的类型为F5,根据所述灰度应用确定F5负载均衡应用所在的F5设备;
    在所述F5设备上获取所述F5负载均衡应用的配置文件,并在所述配置文件中加入所述灰度应用新增的容器实例所对应的配置代码;
    若所述负载均衡应用的类型为非F5,根据所述灰度应用确定所述负载均衡应用的容器,其中非F5负载均衡应用包括LVS负载均衡应用、Haproxy负载均衡应用、Nginx负载均衡应用;
    从对应的负载均衡应用的容器中获取配置文件,将所获取的配置文件下载到本地;
    在所述配置文件中加入所述灰度应用新增的容器实例所对应的配置代码;
    将加入了所述配置代码的配置文件推送至对应的负载均衡应用的容器中;
    重启对应的负载均衡应用的容器的负载均衡服务,以使得加入了所述配置代码的配置文件生效。
  18. 根据权利要求17所述的计算机设备,其中,所述在所述配置文件中加入所述灰度应用新增的容器实例所对应的配置代码,包括:
    获取对应的容器实例配置代码模板;
    在对应的容器实例配置代码模板中添加新增的灰度应用的容器实例的IP和端口信息以形成新增的容器实例的配置代码;
    将新增的容器实例的配置代码追加到配置文件中最后一个容器实例的配置代码之后。
  19. 根据权利要求18所述的计算机设备,其中,所述LVS负载均衡应用中容器实例配置代码模板中包括容器实例IP信息、容器实例的端口信息、所述容器实例所对应的权重信息、所述容器实例所对应的健康检查方式信息;
    所述Nginx负载均衡应用和所述Haproxy负载均衡应用中容器实例配置代码模板是以server节点开头的代码。
  20. 一种计算机可读存储介质,其中,所述计算机可读存储介质存储有计算机程序,所述计算机程序当被处理器执行时使所述处理器执行以下操作:
    若灰度应用完成测试,根据第一预设规则从原应用的容器实例IP中确定第一预设数量的IP,其中,所述第一预设数量小于所述原应用的容器实例数量,所述灰度应用是在所述原应用的版本上添加新功能或者改进功能之后所形成的应用;
    停用所确定的第一预设数量的IP以及所述第一预设数量的IP所对应的容器实例,其中,所停用的所述第一预设数量的IP被回收到预设IP地址池;
    根据第二预设规则从预设IP地址池所停用的IP中确定第二预设数量的需启用的IP,其中,所述第二预设数量小于或者等于所停用的IP数量;
    将需启用的IP分配给所述灰度应用新增的容器实例;
    在所述灰度应用所对应的负载均衡应用的配置文件中添加所述灰度应用新增的容器实例所对应的配置代码;
    将所述原应用的访问域名与所述原应用所对应的负载均衡应用的虚拟IP的对应关系解除,并将所述原应用的访问域名与所述灰度应用所对应的负载均衡应用的虚拟IP进行绑定,以实现通过所述原应用的访问域名来访问所述灰度应用。
PCT/CN2019/103262 2019-05-17 2019-08-29 负载均衡应用虚拟ip切换方法、装置、计算机设备及存储介质 Ceased WO2020232891A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910410793.7 2019-05-17
CN201910410793.7A CN110225094B (zh) 2019-05-17 2019-05-17 负载均衡应用虚拟ip切换方法、装置、计算机设备及存储介质

Publications (1)

Publication Number Publication Date
WO2020232891A1 true WO2020232891A1 (zh) 2020-11-26

Family

ID=67821086

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/103262 Ceased WO2020232891A1 (zh) 2019-05-17 2019-08-29 负载均衡应用虚拟ip切换方法、装置、计算机设备及存储介质

Country Status (2)

Country Link
CN (1) CN110225094B (zh)
WO (1) WO2020232891A1 (zh)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113746951A (zh) * 2021-09-10 2021-12-03 成都高新愿景数字科技有限公司 一种防止keepalive虚拟IP丢失的方法
CN114594999A (zh) * 2022-01-28 2022-06-07 阿里巴巴(中国)有限公司 发布文件的方法、装置、存储介质及系统
CN115190133A (zh) * 2022-07-08 2022-10-14 中电云数智科技有限公司 一种基于资源复用Nginx容器的七层负载均衡系统和方法
CN115865938A (zh) * 2022-11-08 2023-03-28 中国工商银行股份有限公司 一种加强负载均衡配置重载稳定性的方法及装置

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110286996B (zh) * 2019-05-17 2023-08-18 平安科技(深圳)有限公司 容器实例ip切换方法、装置、计算机设备及存储介质
CN111475289B (zh) * 2020-03-26 2024-04-12 北京世纪家天下科技发展有限公司 负载均衡方法及装置

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070118558A1 (en) * 2005-11-21 2007-05-24 Research In Motion Limited System and method for application program operation on a wireless device
CN101729947A (zh) * 2009-12-02 2010-06-09 中兴通讯股份有限公司 更新版本下载方法及系统
CN106412146A (zh) * 2016-11-01 2017-02-15 杭州迪普科技有限公司 一种dhcp客户端更新ip的方法和装置
CN107666525A (zh) * 2017-09-08 2018-02-06 北京京东尚科信息技术有限公司 集群容器ip分配的方法和装置

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107360010B (zh) * 2016-05-09 2021-04-16 阿里巴巴集团控股有限公司 一种网站灰度发布方法及装置
CN106656959B (zh) * 2016-09-28 2020-07-28 腾讯科技(深圳)有限公司 访问请求调控方法和装置
CN107493351B (zh) * 2017-10-09 2021-06-29 郑州云海信息技术有限公司 一种客户端访问存储系统的负载均衡的方法及装置
CN108156038B (zh) * 2017-12-29 2019-07-02 Oppo广东移动通信有限公司 请求分发方法、装置、接入网关及存储介质
CN108319656A (zh) * 2017-12-29 2018-07-24 中兴通讯股份有限公司 实现灰度发布的方法、装置及计算节点和系统

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070118558A1 (en) * 2005-11-21 2007-05-24 Research In Motion Limited System and method for application program operation on a wireless device
CN101729947A (zh) * 2009-12-02 2010-06-09 中兴通讯股份有限公司 更新版本下载方法及系统
CN106412146A (zh) * 2016-11-01 2017-02-15 杭州迪普科技有限公司 一种dhcp客户端更新ip的方法和装置
CN107666525A (zh) * 2017-09-08 2018-02-06 北京京东尚科信息技术有限公司 集群容器ip分配的方法和装置

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113746951A (zh) * 2021-09-10 2021-12-03 成都高新愿景数字科技有限公司 一种防止keepalive虚拟IP丢失的方法
CN113746951B (zh) * 2021-09-10 2023-07-11 成都高新愿景数字科技有限公司 一种防止keepalive虚拟IP丢失的方法
CN114594999A (zh) * 2022-01-28 2022-06-07 阿里巴巴(中国)有限公司 发布文件的方法、装置、存储介质及系统
CN114594999B (zh) * 2022-01-28 2023-09-12 阿里巴巴(中国)有限公司 发布文件的方法、装置、存储介质及系统
CN115190133A (zh) * 2022-07-08 2022-10-14 中电云数智科技有限公司 一种基于资源复用Nginx容器的七层负载均衡系统和方法
CN115865938A (zh) * 2022-11-08 2023-03-28 中国工商银行股份有限公司 一种加强负载均衡配置重载稳定性的方法及装置

Also Published As

Publication number Publication date
CN110225094B (zh) 2022-02-11
CN110225094A (zh) 2019-09-10

Similar Documents

Publication Publication Date Title
WO2020232891A1 (zh) 负载均衡应用虚拟ip切换方法、装置、计算机设备及存储介质
US11924117B2 (en) Automated local scaling of compute instances
CN108469986B (zh) 一种数据迁移方法及装置
CN110289982B (zh) 容器应用的扩容方法、装置、计算机设备及存储介质
CN109995814B (zh) 云主机资源的迁移方法及装置、通信设备、存储介质
WO2019237584A1 (zh) 容器的管理方法、装置、计算机设备及存储介质
CN104350466B (zh) 虚拟机映像写租赁
WO2020232887A1 (zh) 容器应用的配置修改方法、装置、计算机设备及存储介质
JP2017526070A (ja) ワークロードのセキュリティプロビジョニングを自動化するための方法及び装置
US11750475B1 (en) Monitoring customer application status in a provider network
WO2020233002A1 (zh) 容器实例ip切换方法、装置、计算机设备及存储介质
US10992746B2 (en) Automatic system response to external field-replaceable unit (FRU) process
CN108319492B (zh) 复位物理机的方法、装置与系统
CN114371908A (zh) 一种云应用程序运行方法和装置
CN110442307A (zh) 一种Linux系统中磁盘的绑定方法、设备以及存储介质
WO2020232888A1 (zh) 容器应用克隆方法、装置、计算机设备及存储介质
US20150127916A1 (en) Dynamic memory allocation
CN104268089B (zh) 一种信息更新的方法、装置及系统
CN111355716A (zh) 一种确定虚拟机唯一标识的方法、系统、设备以及介质
CN113127258A (zh) 一种数据备份方法、装置、设备及介质
CN116724536A (zh) 用于限制组合系统中数据可访问性的方法和系统
CN107577518B (zh) 一种虚拟机部署方法及装置
CN112994907B (zh) 虚拟机的网络配置方法、装置、存储介质及设备
JP6497157B2 (ja) 情報管理装置、情報管理方法、情報管理プログラム、データ構造、及び、ソフトウェア資産管理システム
US9239729B1 (en) Sidecar file framework for managing virtual disk plug-in data and metadata

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: 19929517

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19929517

Country of ref document: EP

Kind code of ref document: A1