WO2020232890A1 - 负载均衡应用创建方法、装置、计算机设备及存储介质 - Google Patents

负载均衡应用创建方法、装置、计算机设备及存储介质 Download PDF

Info

Publication number
WO2020232890A1
WO2020232890A1 PCT/CN2019/103260 CN2019103260W WO2020232890A1 WO 2020232890 A1 WO2020232890 A1 WO 2020232890A1 CN 2019103260 W CN2019103260 W CN 2019103260W WO 2020232890 A1 WO2020232890 A1 WO 2020232890A1
Authority
WO
WIPO (PCT)
Prior art keywords
container
application
lvs
instance
load balancing
Prior art date
Application number
PCT/CN2019/103260
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 平安科技(深圳)有限公司
Publication of WO2020232890A1 publication Critical patent/WO2020232890A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/08Configuration management of networks or network elements
    • H04L41/0889Techniques to speed-up the configuration process
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/50Address allocation
    • H04L61/5007Internet protocol [IP] addresses
    • 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

Definitions

  • This application relates to the field of cloud computing technology, and in particular to a method, device, computer equipment, and storage medium for creating a load balancing application.
  • PaaS platforms (Platform-as-a-Service) need to create load balancing applications for container applications when creating container applications.
  • F5 load balancing applications are used in the industry, and F5 load balancing applications need to rent hardware resources, which increases costs.
  • creating container applications and creating other non-F5 load balancing applications are created separately, that is, creating container applications separately, creating other non-F5 load balancing applications, and then manually configuring The relationship between the created container application and other non-F5 load balancing applications. In this way, the process of creating and configuring the association relationship is more complicated, inconvenient and not fast, and errors are prone to occur.
  • the embodiments of the present application provide a load balancing application creation method, device, computer equipment, and storage medium, which can accelerate the speed and efficiency of creating container applications and creating associated load balancing applications.
  • an embodiment of the present application provides a method for creating a load balancing application.
  • the method includes: if a setting instruction is received, calling a preset setting interface according to the setting instruction, so as to set through the preset setting interface
  • the information of the load balancing application includes the type of the load balancing application and the port information of the load balancing application.
  • the type of the load balancing application is Linux Virtual Server (Linux Virtual Server).
  • LVS LVS
  • the container instance of the container application is created according to the information of the set container application
  • the host machine for creating the LVS load balancing application is determined according to the information of the set container application, and in the Create an LVS container on the host; assign a virtual IP and a service IP to the created LVS container; reconstruct the configuration file of the LVS load balancing application according to the virtual IP, the container instance of the created container application, and the port information; enable The LVS load balancing service of the LVS container; configure the subnet card of the LVS container to bind the virtual IP with the subnet card of the LVS container; add a route to the configured subnet card to complete When creating a container application, create an LVS load balancing application.
  • an embodiment of the present application provides an apparatus for creating a load balancing application.
  • the apparatus for creating a load balancing application includes a unit corresponding to the method described in the first aspect.
  • an embodiment of the present application provides a computer device, the computer device including 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 creating a load balancing application provided by an embodiment of the present application
  • Figure 2 is a schematic diagram of a setting interface provided by an embodiment of the present application.
  • FIG. 3 is a schematic diagram of a sub-flow of a method for creating a load balancing application provided by an embodiment of the present application
  • FIG. 4 is a schematic diagram of the sub-process of FIG. 4 provided by an embodiment of the present application.
  • FIG. 6 is a schematic diagram of a sub-flow of a method for creating a load balancing application provided by an embodiment of the present application
  • FIG. 7 is a schematic block diagram of a load balancing application creation device provided by an embodiment of the present application.
  • FIG. 8 is a schematic block diagram of an application creation unit provided by an embodiment of the present application.
  • FIG. 9 is a schematic block diagram of an instance creation unit provided by an embodiment of the present application.
  • FIG. 10 is a schematic block diagram of an LVS creation unit provided by an embodiment of the present application.
  • FIG. 11 is a schematic block diagram of a reconstruction unit provided by an embodiment of the present application.
  • FIG. 12 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 creating a load balancing application provided by an embodiment of the present application. As shown in Figure 1, the method includes S101-S108.
  • a preset setting interface is invoked according to the setting instruction to set the information of the container application to be created and the information of the load balancing application through the preset setting interface, where the load balancing application
  • the information includes the type of the load balancing application and the port information of the load balancing application, where the type of the load balancing application is a Linx virtual server (Linux Virtual Server, LVS).
  • a preset setting interface is invoked according to the setting instruction to set the information of the container application to be created and the information of the load balancing application through the preset setting interface, where the information of the load balancing application includes The type of load balancing application, the port information of the load balancing application, where the type of load balancing application is LVS; the information of the container application includes the application environment of the container application, the area of the container application, the number of container instances of the container application, and the image information of the container application .
  • the preset setting interface is a setting interface written by a developer, which can be presented in the form of a setting page, as shown in Figure 2.
  • the information of the container application to be created and the information of the load balancing application are set through the preset setting interface. Specifically, the information of the container application to be created and the information of the load balancing application input/selected by the user is received. Since the information of the container application and the information of the load balancing application can be set in the preset creation interface, the information of the container application and the information of the load balancing application can be obtained at the same time.
  • the information of the container application includes the application environment of the container application, the area of the container application, the number of container instances of the container application, and the image information of the container application.
  • the information of the container application also includes whether monitoring is enabled, the application administrator (the person who creates the container application can manage the created container application), the resource group of the container application, and so on.
  • the application environment of the container application includes a production environment, a test environment, and a development environment.
  • the production environment means that the container application is successfully created to connect to the external environment, or for external users to access
  • the test environment means that the container application is successfully created for testing
  • the development environment means that the container application is created for development and use .
  • the container application area refers to the location of the computer room where the container application is created. It consists of two parts: “area” + “safe area”. Among them, "safe area” is a sub-area under "area”. It can be understood that the container application is created in the computer room of the "xxx security zone” under the "xx zone”. However, to determine which specific computer room the container application is created in, it needs to be determined jointly according to the application environment of the container application and the area of the container application. It can be understood as creating the container application in the computer room corresponding to the area of the container application in a certain application environment. . It can be understood that the computer rooms corresponding to different application environments in the same area are different.
  • the number of container instances of a container application refers to the number of containers of the container application, and there is no upper limit on the number of containers of a container application. Among them, the number of container instances can be determined according to the access volume of the container application.
  • the container instance image information includes the image version, image type, and image name. Among them, the image version includes the official version, the official version 1.1, the official version 4.5, etc.; the image type refers to which image the container instance uses, such as nginx, tomcat, weblogic, springboot, etc.; the image name refers to the specific image name, Such as tomcat1.1 and so on.
  • the mirror image information can be obtained from the corresponding mirror warehouse for users to choose, where the corresponding mirror warehouse refers to the mirror warehouse under the computer room that is jointly determined by the application environment of the container application and the region of the container application.
  • the resource group of the container application includes a resource account for the cost of creating the container application.
  • Whether to enable monitoring refers to whether you choose to monitor the container instance of the container application, such as the CPU/memory/IO usage of the container instance.
  • the container application information also includes a beneficiary resource pool.
  • the beneficiary resource pool refers to the subsidiary/department that created the container application, which determines the IP network segment allocated by the created container and the host resources of the container.
  • Different resource pools use different IP network segments and host resources. If the information of the container application also includes the beneficiary resource pool, the beneficiary resource pool, the application environment of the container application, and the region of the container application together determine the IP network segment allocated by the created container instance and the host resources of the container instance.
  • the information of the load balancing application includes the type of the load balancing application and the port information of the load balancing application, where the type of the load balancing application is LVS.
  • the port information of the load balancing application can be one or more.
  • the port of the load balancing application refers to the access port supported by the LVS load balancing application, that is, the port accessed in http mode, such as ports 80 and 443.
  • S301 Determine the container instance IP of the container application according to the application environment of the container application, the area of the container application, and the number of container instances of the container application in the set information of the container application.
  • S302 Create a container instance according to the container application image information in the set container application information, the application environment of the container application, the area of the container application, and the number of container instances of the container application, and the determined container instance IP is set to the IP of the created container instance.
  • the container instance After assigning the IP of the container instance of the container application, create the container instance. Specifically, as shown in FIG. 4, the container instance is created according to the container application image information in the set container application information, the application environment of the container application, the area of the container application, and the number of container instances of the container application ,
  • S402 Determine the resources required to create the container instance according to the container image type, image version, and image name, and determine the host for creating the container instance according to the application environment of the container application, the region of the container application, and the resources required to create the container instance.
  • S403 Create a container instance of the container application on the determined host machine according to the determined specific image, and bind the created container instance with the determined container instance IP to set the determined container instance IP to the determined container instance IP.
  • the execution order of determining the specific image and determining the host machine for creating the container instance is not strictly limited. In other embodiments, the host machine for creating the container instance may be determined first, and then the specific image is determined.
  • the location where the container application is created can be determined according to the application environment of the container application and the region of the container application, that is, in which computer room the container application is created. It should be noted that each area in each application environment corresponds to a mirror warehouse that stores mirror resources. All the mirror resources needed to be used in the area under the application environment are stored in the mirror warehouse.
  • Creating a container instance requires a certain amount of resources to be occupied on the host. Therefore, it is necessary to determine the resources required to create the container instance first to determine whether the host has enough resources to create the container instance.
  • the resources required to create a container instance include CPU (number of CPU cores, etc.), memory, monitoring resources, etc.
  • step S403 is to create a container instance of the container application on the determined host machine according to the determined specific image, and bind the created container instance with the determined container instance IP to bind the determined container instance
  • the IP is set to the IP of the created container instance, including: sending the determined specific image to the host of the determined container instance through the container orchestration tool to create the container instance; if the creation is completed, through the operation and maintenance tool For example, the ansible tool connects to the container instance, binds the created container instance with the determined container instance IP to set the determined container instance IP to the IP of the created container instance. After the container instance is successfully created, it will return a successful creation message; if the container instance fails to be created, it will return the reason for the creation failure.
  • the above container application creation process also involves enabling monitoring for the container instance of the created container application, and the corresponding steps Also includes:
  • the monitoring process is installed on all hosts by default, and the monitoring process is enabled. Push the enable monitoring identifier to the determined host, and monitor the container instance through the monitoring process installed on the host. In this way, it is convenient to obtain the relevant information of all container instances of the container application, and it is convenient to locate the abnormality in the container application.
  • the step of creating a container instance of the container application according to the set information of the container application further includes:
  • S301a Generate an application name of the container application according to a preset name generation rule.
  • step S301b Determine whether the generated application name already exists in the area corresponding to the container application, wherein the area corresponding to the container application is determined according to the application environment of the container application and the area of the container application. If the generated application name does not exist in the area corresponding to the container application, step S301 is executed. If the generated application name already exists in the area corresponding to the container application, step S301d is executed.
  • step S301d the step of creating a container instance of the container application according to the set information of the container application further includes:
  • step S301c Determine whether there is enough money in the resource group of the container application to create a container instance of the container application according to the usage time of the container instance, the resource group of the container application, and the number of container instances. If there is enough money to create a container instance of the container application, step S301 is executed. If there is not enough money to create a container instance of the container application, step S301d is executed.
  • the amount to be paid to create the current container application is calculated according to the number of container instances of the container application, the usage time of the container instance, and the cost of each container instance; to determine whether the remaining amount in the resource group of the container application is greater than or equal to the creation of the current container application The amount to be paid; if it is, it is determined that the resource group of the container application has enough money to create the corresponding container application; if not, it is determined that the resource group of the container application does not have enough money to create the corresponding container application.
  • S103 Determine a host for creating the LVS load balancing application according to the set information of the container application, and create an LVS container on the host.
  • the location where the container application is created can be determined, that is, the host computer in which computer room the container application is created. It should be noted that, generally speaking, the host where the container instance of the container application is located is not the same as the host where the load balancing application is located, so as to avoid failure of the host and the load balancing application cannot be used. Application services cannot be used either. In addition, the host where the container instance of the container application is located and the host where the load balancing application is located are usually in the same network segment to improve the speed of network access.
  • the host cluster for creating the load balancing application and the host cluster for creating the container application can be the same host cluster, or they can be separate and independent host clusters. After determining the host to create the load balancing application, then create the LVS container for the LVS load balancing application.
  • step S103 includes the following steps S501-S503.
  • S501 Determine LVS image information according to the application environment of the container application and the region of the container application in the information of the container application.
  • S503 Create a container instance of the LVS load balancing application on the host machine according to the LVS image information, and call the created container instance of the LVS load balancing application as an LVS container.
  • a mirror repository for storing LVS mirror information is determined and the LVS mirror information is obtained from the mirror repository.
  • the resources required to create the container instance of the LVS load balancing application are determined.
  • the resources required to create the container instance of the LVS load balancing application determine the host machine for creating the LVS load balancing application.
  • the method of creating the container instance of the LVS load balancing application is the same as the method of creating the container instance of the container application, and will not be repeated here.
  • a default configuration file is generated based on the LVS mirroring information, and the configuration file is saved in a preset directory.
  • S104 Allocate a virtual IP and a management IP to the created LVS container.
  • the virtual IP Virtual IP, VIP
  • the service IP is the IP required to provide load balancing services. It can also be understood as the IP for external use, that is, the IP corresponding to the incoming request from external users.
  • the management IP is the IP used for internal management of the LVS container, such as the IP required to log in to the LVS container. It should be noted that because LVS load balancing is a four-layer load balancing.
  • the four-layer load balancer receives the request through the virtual IP+port, forwards the request according to the destination address and source address in the request, and cannot modify or judge the specific type of the requested resource, and then forwards the request to the real request to be processed through the load balancing algorithm Server.
  • the real server is the container instance corresponding to the container application. Because it is a four-layer load balancing, you can perform load balancing for all applications without considering the specific applications to be processed. Therefore, two IPs are allocated to the LVS container to facilitate LVS to provide services to the outside world and to manage the LVS container inside the PaaS platform.
  • step S104 includes the following steps: obtain two free IPs from a pre-allocated IP address pool according to the application environment of the container application and the area of the container application in the information of the container application; Two free IPs are used as virtual IP and management IP, and the virtual IP and management IP are allocated to the created LVS container.
  • the pre-allocated IP address pool can be determined according to the application environment of the container application and the area of the container application in the information of the container application.
  • the virtual IP (VIP) and management IP address can be obtained from the free IP of two different pre-allocated address pools, such as the VIP address pool and the management IP address pool; it can also be a pre-allocated address pool. Obtained from an IP address pool, that is, two idle IPs are obtained from an IP address pool, one of which is a VIP and the other is a management IP.
  • step S105 Reconstruct the configuration file of the LVS load balancing application according to the virtual IP, the container instance of the created container application, and the port information. Because when creating the LVS container, a default configuration file will be generated based on the LVS image information, and the configuration file cannot really be used for load balancing. Therefore, the configuration file needs to be reconstructed. In an embodiment, as shown in FIG. 6, step S105 includes the following steps S601-S603.
  • S601 Use the virtual IP, the container instance of the created container application, and the port information as variables and pass them into a preset configuration file generation interface.
  • S602 Generate a new configuration file according to the configuration file template integrated in the preset configuration file generation interface.
  • S603 Upload a new configuration file to the preset directory where the configuration file of the LVS container is located, to replace the configuration file generated when the LVS container of the LVS load balancing application is created.
  • step S602 before step S602, it further includes generating a configuration file template.
  • the step of generating a configuration file template includes: obtaining preset LVS load balancing parameter information and preset container instance parameter information; setting virtual IP parameters, container instance IP parameters, and load balancing port parameters; according to preset settings LVS load balancing parameter information, preset parameter information of the container instance, set virtual IP parameters, IP parameters of the container instance, and load balancing port parameters to generate configuration file templates.
  • the generated configuration file template can be understood as follows: the generated configuration file template includes load balancing information and a container instance information, and the load balancing information includes the set virtual IP parameters, load Balanced port parameters, preset LVS load balancing parameter information, and this piece of container instance information includes IP parameters of the container instance, load balancing port parameters, and preset parameter information of the container instance.
  • the configuration file template can be understood as related configuration information corresponding to a port.
  • the preset LVS load balancing parameter information includes the LVS load balancing parameter and the value corresponding to the LVS load balancing parameter.
  • LVS load balancing parameters include LVS load balancing algorithm parameters (the default is the polling algorithm (the polling algorithm can be abbreviated as rr)), LVS load balancing forwarding mode parameters (the default is DR mode, in this mode pass is the received request message Re-encapsulate the new MAC address to forward to the corresponding server (ie container instance), LVS load balancing forwarding protocol parameters (the default is TCP protocol, the protocol uses LVS four-layer load balancing by default), etc.
  • the preset parameter information of the container instance includes the container instance parameter and the corresponding value of the container instance parameter.
  • Container instance parameters include the weight parameters of the server corresponding to the container instance (according to the weight to determine which container instance (server) the access request should be forwarded to, if it is a polling algorithm, the weight corresponding to each container instance is the same), container instance
  • the corresponding TCP health check parameters (LVS load balancing needs to periodically check the container instance (server) to check whether the container instance is available), etc.
  • the TCP health check parameters corresponding to the container instance include the connection timeout parameter (the default is 3s), the number of reconnection parameters (the default is 3), the reconnection interval parameter (the default is 3s), and the connected port parameter ( Can be consistent with the port of the load balancing application).
  • the connection is made up within 3s, the connection is considered to be timed out, and the default reconnection is 3 times, and the interval between each reconnection is 3s. If there are 3 reconnections and the connection timeout is 3s after each reconnection interval, then the container instance is considered unavailable.
  • all parameters in the configuration file template are default values. It can also be understood that the parameter values in the configuration file template are based on the optimal values in the current application scenario of the current environment.
  • the generated configuration file template may include the following content:
  • xxx.yyy.zzz.mmm represents VIP
  • LVS_port represents the port of the load balancing application
  • LVS_algorithm represents LVS load balancing algorithm parameters
  • LVS_kind represents LVS load balancing forwarding mode parameters
  • protocol represents LVS load balancing forwarding protocol parameters.
  • xxx.yyy.zzz.nnn represents the IP of the container instance
  • weight represents the weight parameter of the server corresponding to the container instance
  • TCP_CHECK represents the TCP health check parameter of the server corresponding to the container instance.
  • This parameter includes the following parameters: connect_timeout represents the connection timeout time Parameter, nb_get_retry indicates the number of reconnection parameters, delay_before_retry indicates the reconnection interval time parameter, and connect_port indicates the connected port parameter.
  • the VIP, the created container instance, and port information are used as variables and passed to the configuration file generation interface.
  • the configuration file generation interface can be understood as an interface function. Generate a new configuration file through the configuration file template integrated in the interface function.
  • the step of generating a new configuration file according to the configuration file template integrated in the preset configuration file generation interface includes: for each load balancing application port, generating a corresponding configuration file template according to the number of container instances created Number of container instance information, replace the IP of the created container instance with the IP parameter of the container instance in each container instance information, and replace the port of the load balancing application with the load balancing port parameter in each container instance information; change VIP ,
  • the port information of the load balancing application replaces the virtual IP parameters and load balancing port parameters set in the load balancing information respectively, so that the relevant configuration information of the ports of multiple load balancing applications can be generated, and all ports of the load balancing application
  • the file composed of related configuration information is used as a new configuration file.
  • the port information includes the second number, such as two ports 80,443. Then in the new configuration file generated, there are 4 container instance information corresponding to port 80, and there are 4 container instances corresponding to port 443. Finally, the new configuration file generated includes port 80 configuration information and port 443 configuration information.
  • the load balancing port parameters are default, for example, the default port includes ports 80 and 443.
  • the configuration file template includes relevant configuration information corresponding to at least two different ports.
  • step S106 Start the LVS load balancing service of the LVS container.
  • step S106 includes: associating the new configuration file with a preset startup script; and executing the associated preset startup script. After starting, the status of LVS load balancing service is changed to started. In an embodiment, it can be implemented using commands. For example, xxx/xxxxx/xx/xx/keepalived.conf restart. Among them, keepalived.conf is the new configuration file, restart means restart.
  • the subnet card is not an actual network interface device, but it can also appear in the system as a network interface, such as eth0:1, eth1:2. They must depend on the physical network card. Although they can exist in the system at the same time as the network interface of the physical network card and use different IP addresses, these subnetwork cards will not work together when the dependent physical network card is not enabled (Down state).
  • One LVS container can correspond to multiple subnet cards. When the LVS load balancing service of the LVS container is turned on, the subnet card corresponding to the LVS container will be turned on.
  • the VIP is assigned to a subnet card of the LVS container, so that the subnet card can be accessed through the VIP. For example, you can use the command ifconfig to configure the subnet card.
  • a VIP corresponds to a subnet card, so no matter how many ports are used for LVS load balancing, it corresponds to a subnet card.
  • the configuration of the subnet card of the LVS container can be implemented using commands. For example: ifconfig eth0:1 192.168.1.54 netmask 255.255.255.255 broadcast 192.168.1.54up. Among them, eth0:1 represents the network interface 1 of the subnet card eth0, 192.168.1.54 is the VIP, 255.255.255.255 is the mask address, and 192.168.1.54 is the broadcast address.
  • S108 Add a route to the configured subnet card to complete the creation of the LVS load balancing application when creating the container application. Because LVS load balancing is a four-layer load balancing, it is necessary to add a route to the configured subnet card so that when accessing the load balancing application, the access request can reach the subnet card, and then reach the sink corresponding to the LVS container through the subnet card Host.
  • the route add command can be used to add a route. For example, route add-host 192.168.1.54 dev eth0:1.
  • the above method embodiment automatically completes the creation of the container application and the creation of the LVS load balancing application, automatically realizes the basic settings of the created load balancing application, and speeds up the creation speed and efficiency.
  • the load balancing application creation method further includes the following steps:
  • Verify the validity of the LVS container according to the virtual IP. Verifying the validity of the LVS container includes verifying whether the VIP of the LVS is truly released, that is, whether the VIP can be accessed as an independent IP. If you can use the arping command. That is, ICMP packets are sent to the VIP of the LVS container to detect the IP address. If the ICMP response of the VIP can be received within the set time, it is considered that it can be pinged. If it can be pinged, it is valid. If the ping fails, it means that the VIP cannot be used yet and further verification is required.
  • the load balancing application creation method further includes the following steps:
  • S108b Set the association relationship between the container instance of the container application and the virtual IP, so as to realize the binding of the container instance of the container application with the virtual IP.
  • the created container instance of the container application is the real server corresponding to the application, that is, the server that actually provides services for user access requests.
  • Set the association relationship between the container instance and the LVS load balancing application specifically, set the association relationship between the container instance of the container application and the VIP, so as to bind the container instance and the VIP.
  • the LVS load balancing container assigns the access request to a container instance (one of the server) according to the port information of the access request and through a certain load balancing algorithm. ) To return the information required by the access request through the container instance.
  • the above method embodiment creates a container application while creating an LVS load balancing application, and automatically associates the created container application with the created LVS load balancing application, so there is no need to create container applications and creating LVS load balancing applications separately, and There is no need to manually associate the two, which speeds up the creation.
  • the above container application is created while the LVS load balancing application is created, and the created container application is automatically associated with the created LVS load balancing application. This entire process is automatically completed, which further accelerates the creation speed and efficiency, and saves time and cost. Labor costs.
  • Fig. 7 is a schematic block diagram of an apparatus for creating a load balancing application according to an embodiment of the present application.
  • the device includes a unit corresponding to the above load balancing application creation method.
  • the device 70 includes a setting unit 701, an application creation unit 702, an LVS creation unit 703, an IP distribution unit 704, a reconstruction unit 705, an opening unit 706, a network card configuration unit 707, and a route adding unit 708 .
  • the setting unit 701 is configured to, if a setting instruction is received, call a preset setting interface according to the setting instruction to set information of the container application to be created and information of the load balancing application through the preset setting interface, wherein:
  • the information of the load balancing application includes the type of the load balancing application and the port information of the load balancing application, where the type of the load balancing application is LVS.
  • the application creation unit 702 is configured to, if a setting completion instruction is received, create a container instance of the container application according to the set information of the container application.
  • the application creation unit 702 includes an instance IP determination unit 801 and an instance creation unit 802.
  • the instance IP determining unit 801 is configured to determine the container instance IP of the container application according to the application environment of the container application, the area of the container application, and the number of container instances of the container application in the set information of the container application.
  • the instance creation unit 802 is configured to create a container instance according to the container application image information in the set container application information, the application environment of the container application, the area of the container application, and the number of container instances of the container application, and The determined container instance IP is set to the created container instance IP.
  • the application creation unit 702 further includes a name generation unit 801a, a name judgment unit 801b, and a prompt unit 801d.
  • the name generating unit 801a is configured to generate the application name of the container application according to a preset name generation rule.
  • the name determining unit 801b is used to determine whether the generated application name already exists in the area corresponding to the container application. If the generated application name does not exist in the area corresponding to the container application, the instance IP determining unit 801 is triggered.
  • the prompt unit 801d is configured to prompt if the generated application name already exists in the area corresponding to the container application.
  • the application creation unit 702 further includes an amount judgment unit 801c.
  • the amount judgment unit 801c is configured to judge whether there is enough money in the resource group of the container application to create the container application according to the usage time of the container instance, the resource group of the container application, and the number of container instances. The container instance of the container application. If there is enough money to create a container instance of the container application, the instance IP determining unit 801 is triggered. If there is not enough money to create a container instance of the container application, the prompt unit 801d is triggered.
  • the instance creation unit 802 includes a mirror image determination unit 901, a host computer determination unit 902, and an application instance creation unit 903.
  • the image determining unit 901 is used to determine the image warehouse for storing the image information of the container application according to the application environment of the container application and the area of the container application, and according to the image type, image version, and image name of the container application image information.
  • the specific image needed to create the container instance is extracted from the determined image warehouse.
  • the host determining unit 902 is configured to determine the resources required to create a container instance according to the image type, image version, and image name, and determine the creation according to the application environment of the container application, the region of the container application, and the resources required to create the container instance The host of the container instance.
  • the application instance creation unit 903 is configured to create a container instance of the container application on the determined host machine according to the determined specific image, and bind the created container instance with the determined container instance IP to bind the determined
  • the container instance IP is set to the IP of the created container instance.
  • the LVS creating unit 703 is configured to determine a host for creating the LVS load balancing application according to the set information of the container application, and create the LVS container on the host.
  • the LVS creation unit 703 includes an LVS image determination unit 101, an LVS host determination unit 102, and an LVS container creation unit 103.
  • the LVS image determining unit 101 is configured to determine the LVS image information according to the application environment of the container application and the region of the container application in the information of the container application.
  • the LVS host determining unit 102 is configured to determine the host for creating the LVS load balancing application according to the application environment of the container application, the region of the container application, and the LVS mirroring information.
  • the LVS container creation unit 103 is configured to create a container instance of the LVS load balancing application on the host machine according to the LVS image information, and call the created container instance of the LVS load balancing application as an LVS container.
  • the IP allocation unit 704 is configured to allocate virtual IP and management IP to the created LVS container.
  • the reconstruction unit 705 is configured to reconstruct the configuration file of the LVS load balancing application according to the virtual IP, the container instance of the created container application, and the port information.
  • the reconstruction unit 705 includes a parameter input unit 111, a configuration file generation unit 112, and a replacement unit 113.
  • the parameter input unit 111 is used to input the virtual IP, the container instance of the created container application, and the port information as variables to the preset configuration file generation interface.
  • the configuration file generating unit 112 is configured to generate a new configuration file according to the configuration file template integrated in the preset configuration file generation interface.
  • the replacing unit 113 is configured to upload a new configuration file to the preset directory where the configuration file of the LVS container is located, so as to replace the configuration file generated when the LVS container of the LVS load balancing application is created.
  • the reconstruction unit 705 further includes a template generation unit.
  • the template generating unit is used to generate a configuration file template.
  • the template generation unit includes a parameter acquisition unit, a parameter setting unit, and a configuration template generation unit.
  • the parameter obtaining unit is used to obtain preset LVS load balancing parameter information and preset container instance parameter information.
  • the parameter setting unit is used to set virtual IP parameters, IP parameters of the container instance, and port parameters.
  • the configuration template generating unit is configured to generate a configuration file template according to preset LVS load balancing parameter information, preset parameter information of the container instance, set virtual IP parameters, IP parameters of the container instance, and port parameters.
  • the enabling unit 706 is configured to start the LVS load balancing service of the LVS container.
  • the network card configuration unit 707 is configured to configure the sub-network card of the LVS container to bind the virtual IP to the sub-network card of the LVS container.
  • the route adding unit 708 is configured to add routes to the configured subnet card to complete the creation of the LVS load balancing application when creating the container application.
  • the load balancing application creation apparatus further includes a verification unit 708a.
  • the verification unit 708a is configured to verify the validity of the LVS container according to the virtual IP.
  • the load balancing application creation apparatus further includes an association setting unit 708b.
  • the association setting unit 708b is configured to set the association relationship between the container instance of the container application and the virtual IP if the LVS container is valid, so as to realize the binding of the container instance of the container application with the virtual IP.
  • FIG. 12 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 120 includes a processor 122, a memory, and a network interface 123 connected through a system bus 121, where the memory may include a non-volatile storage medium 124 and an internal memory 125.
  • the non-volatile storage medium 124 can store an operating system 1241 and a computer program 1242.
  • the load balancing application creation method described in the server can be implemented.
  • the processor 122 is used to provide calculation and control capabilities, and support the operation of the entire device 120.
  • the internal memory 125 provides an environment for running a computer program in a non-volatile storage medium.
  • the processor 122 can make the processor 122 execute the load balancing application creation method described in the server.
  • the network interface 123 is used for network communication.
  • FIG. 12 is only a block diagram of a 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 More or fewer components are shown in the figure, or some components are combined, or have different component arrangements.
  • the processor 122 is configured to run a computer program stored in a memory to implement the method for creating a load balancing application in the embodiment of the present application.
  • the embodiment of the computer device shown in FIG. 12 does not constitute a limitation on the specific configuration of the computer device.
  • the computer device may include more or less components than those 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 an embodiment, the structures and functions of the memory and the processor are consistent with the embodiment shown in FIG. 12, and will not be repeated here.
  • the processor 122 may be a central processing unit (Central Processing Unit, CPU), and the processor may also be other general-purpose processors or digital signal processors (DSP). , 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, discrete hardware components, 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 creation 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.

Abstract

本申请实施例提供一种负载均衡应用创建方法、装置、计算机设备及存储介质,其涉及云计算技术领域,可应用于PaaS平台中。所述方法包括:若接收到设置指令,根据设置指令调用预设的设置接口,以通过预设的设置接口设置需创建的容器应用的信息以及LVS负载均衡应用的信息;根据所设置的容器应用的信息创建容器应用的容器实例;根据所设置的容器应用的信息和负载均衡应用的信息创建所述LVS负载均衡应用;开启LVS负载均衡服务;配置LVS容器的子网卡;为配置后的所述子网卡添加路由。

Description

负载均衡应用创建方法、装置、计算机设备及存储介质
本申请要求于2019年5月17日提交中国专利局、申请号201910414034.8、申请名称为“负载均衡应用创建方法、装置、计算机设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及云计算技术领域,尤其涉及一种负载均衡应用创建方法、装置、计算机设备及存储介质。
背景技术
目前,很多PaaS平台(Platform-as-a-Service,平台即服务)在创建容器应用时,需要为容器应用创建负载均衡应用。业内有使用F5负载均衡应用,而F5负载均衡应用需要租用硬件资源,增加了成本。目前的很多PaaS平台中在创建其他非F5负载均衡应用时,创建容器应用和创建其他非F5负载均衡应用是单独进行创建,即分别创建容器应用,在创建其他非F5负载均衡应用,再手动配置创建的容器应用与其他非F5负载均衡应用的关联关系。如此,创建的过程以及配置关联关系时较为复杂,不方便不快捷,很容易出现差错。
发明内容
本申请实施例提供一种负载均衡应用创建方法、装置、计算机设备及存储介质,可加快创建容器应用和创建相关联的负载均衡应用的速度和效率。
第一方面,本申请实施例提供了一种负载均衡应用创建方法,该方法包括:若接收到设置指令,根据所述设置指令调用预设的设置接口,以通过所述预设的设置接口设置需创建的容器应用的信息以及负载均衡应用的信息,其中,负载均衡应用的信息包括负载均衡应用的类型、负载均衡应用的端口信息,其中,负载均衡应用的类型为Liunx虚拟服务器(Linux Virtual Server,LVS);若接收到设置完成指令,根据所设置的容器应用的信息创建所述容器应用的容器实例;根据所设置的容器应用的信息确定创建LVS负载均衡应用的宿主机,并在所述宿主机上创建LVS容器;为所创建的LVS容器分配虚拟IP和服务IP;根据所述虚拟IP、所创建的容器应用的容器实例、所述端口信息重构LVS负载均衡应用的配置文件;开启所述LVS容器的LVS负载均衡服务;配置所述LVS容器的子网卡,以将所述虚拟IP与所述LVS容器的子网卡进行绑定;为配置后的所述子网卡添加路由,以完成在创建容器应用时,创建LVS负载均衡应用。
第二方面,本申请实施例提供了一种负载均衡应用创建装置,该负载均衡应用创建装置包括用于执行上述第一方面所述的方法对应的单元。
第三方面,本申请实施例提供了一种计算机设备,所述计算机设备包括存 储器,以及与所述存储器相连的处理器;
所述存储器用于存储计算机程序,所述处理器用于运行所述存储器中存储的计算机程序,以执行上述第一方面所述的方法。
第四方面,本申请实施例提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时,实现上述第一方面所述的方法。
附图说明
为了更清楚地说明本申请实施例技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1是本申请实施例提供的负载均衡应用创建方法的流程示意图;
图2是是本申请实施例提供的设置界面的示意图;
图3是本申请实施例提供的负载均衡应用创建方法的子流程示意图;
图4是本申请实施例提供的图4的子流程示意图;
图5是本申请实施例提供的负载均衡应用创建方法的子流程示意图;
图6是本申请实施例提供的负载均衡应用创建方法的子流程示意图;
图7是本申请实施例提供的负载均衡应用创建装置的示意性框图;
图8是本申请实施例提供的应用创建单元的示意性框图;
图9是本申请实施例提供的实例创建单元的示意性框图;
图10是本申请实施例提供的LVS创建单元的示意性框图;
图11是本申请实施例提供的重构单元的示意性框图;
图12是本申请实施例提供的计算机设备的示意性框图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
图1是本申请实施例提供的负载均衡应用创建方法的流程示意图。如图1所示,该方法包括S101-S108。
S101,若接收到设置指令,根据所述设置指令调用预设的设置接口,以通过所述预设的设置接口设置需创建的容器应用的信息以及负载均衡应用的信息,其中,负载均衡应用的信息包括负载均衡应用的类型、负载均衡应用的端口信息,其中,负载均衡应用的类型为Liunx虚拟服务器(Linux Virtual Server,LVS)。
若接收到设置指令,根据所述设置指令调用预设的设置接口,以通过所述预设的设置接口设置需创建的容器应用的信息以及负载均衡应用的信息,其中, 负载均衡应用的信息包括负载均衡应用的类型、负载均衡应用的端口信息,其中,负载均衡应用的类型为LVS;容器应用的信息包括容器应用的应用环境、容器应用的区域、容器应用的容器实例数量、容器应用镜像信息。其中,预设的设置接口为开发人员编写的设置接口,可以以一个设置页面的形式呈现,如图2所示。通过该预设的设置接口设置需创建的容器应用的信息以及负载均衡应用的信息。具体地,接收用户输入的/选择的需创建的容器应用的信息以及负载均衡应用的信息。由于该预设的创建接口中可以设置容器应用的信息和负载均衡应用的信息,因此可同时获取容器应用的信息和负载均衡应用的信息。
其中,容器应用的信息包括容器应用的应用环境、容器应用的区域,容器应用的容器实例数量、容器应用镜像信息等。容器应用的信息还包括是否启用监控、应用管理员(创建容器应用的人,可以对创建的容器应用进行管理)、容器应用的资源组等。其中,容器应用的应用环境包括生产环境、测试环境、开发环境等。其中,生产环境意味着该容器应用创建成功后对接外部环境,或者供外部用户进行访问;测试环境意味着该容器应用创建成功后供测试使用;开发环境意味着该容器应用创建成功后供开发使用。容器应用的区域指的是创建容器应用的机房位置,由两部分组成:“区域”+“安全区域”。其中,“安全区域”是“区域”下的一个子区域。可以理解为,将容器应用创建在“xx区域”下的“xxx安全区域”的机房中。然而,确定容器应用创建在哪个具体地机房中,需要根据容器应用的应用环境和容器应用的区域共同决定,可以理解为将容器应用创建在某个应用环境下容器应用的区域所对应的机房中。可以理解为,同一个区域不同应用环境所对应的机房是不同的。容器应用的容器实例数量指的是该容器应用的容器数量,一个容器应用的容器数量是没有上限的。其中,容器实例数量可根据该容器应用的访问量确定。容器实例镜像信息包括镜像版本、镜像类型和镜像名称。其中,镜像版本包括官方版本、官方版本1.1、官方版本4.5等;镜像类型指的是该容器实例使用哪种镜像,如nginx、tomcat、weblogic、springboot等;镜像名称指的是具体的镜像名称,如tomcat1.1等。其中,镜像信息可以从对应的镜像仓库中获取以供用户选择,其中,对应的镜像仓库指的是该容器应用的应用环境和容器应用的区域共同确定的机房下的镜像仓库。创建容器应用是需要收费的,容器应用的资源组下包括有资源账户,用于容器应用创建所使用的费用。是否启用监控指的是是否选择对容器应用的容器实例进行监控,比如容器实例的CPU/内存/IO等资源的使用情况。在一些实施例中,容器应用的信息还包括受益人资源池,受益人资源池指的是创建容器应用的子公司/部门,决定所创建的容器分配的IP网段以及容器的宿主机资源,不同资源池,使用的是不同的IP网段以及宿主机资源。若容器应用的信息还包括受益人资源池,那么受益人资源池与容器应用的应用环境、容器应用的区域一起决定所创建的容器实例分配的IP网段以及容器实例的宿主机资源。
负载均衡应用的信息包括负载均衡应用的类型、负载均衡应用的端口信息,其中,负载均衡应用的类型为LVS。负载均衡应用的端口信息可以有一个也可以有多个,负载均衡应用的端口指的是LVS负载均衡应用支持的访问端口,也 就是http模式访问的端口,如80、443等端口。
S102,若接收到设置完成指令,根据所设置的容器应用的信息创建所述容器应用的容器实例。
设置完成指令由用户点击提交等按钮触发,容器应用的信息和负载均衡应用的信息设置完成,接收用户触发的设置完成指令,即可自动化创建容器应用、负载均衡应用、设置容器应用与负载均衡应用的关联关系。在一实施例中,如图3所示,步骤S102包括以下步骤S301-S302。
S301,根据所设置的容器应用的信息中的容器应用的应用环境、容器应用的区域、容器应用的容器实例数量确定所述容器应用的容器实例IP。
S302,根据所设置的容器应用的信息中的容器应用镜像信息、所述容器应用的应用环境、所述容器应用的区域、所述容器应用的容器实例数量创建容器实例,将所确定的容器实例IP设置为所创建的容器实例的IP。
根据容器应用的应用环境、容器应用的区域可确定创建容器应用的位置,即将容器应用创建在具体哪个机房中。如将容器应用创建在测试环境下宝信(地名)区域下的SF(宝信下面的一个更小的区域标识)子区域所在的机房中。获取数据库中对应位置(该机房下)预先分配的用于创建容器实例的IP地址池;从IP地址池中获取与容器应用的容器实例数量相同数量的空闲IP,将该空闲IP确定为容器应用的容器实例的IP。
分配好容器应用的容器实例的IP后,接着创建容器实例。具体地,如图4所示,根据所设置的容器应用的信息中的容器应用镜像信息、所述容器应用的应用环境、所述容器应用的区域、所述容器应用的容器实例数量创建容器实例,将所确定的容器实例IP设置为所创建的容器实例的IP的步骤,即步骤S302,包括以下步骤S401-S403。
S401,根据容器应用的应用环境、容器应用的区域确定用于保存容器应用镜像信息的镜像仓库并根据容器应用镜像信息的镜像类型、镜像版本以及镜像名称从所确定的镜像仓库中提取出创建容器实例所需要使用的具体镜像。
S402,根据容器镜像类型、镜像版本以及镜像名称确定创建容器实例需占用的资源,并根据容器应用的应用环境、容器应用的区域以及创建容器实例需占用的资源确定创建容器实例的宿主机。
S403,根据所确定的具体镜像在所确定的宿主机上创建容器应用的容器实例,并将所创建的容器实例与所确定的容器实例IP进行绑定以将所确定的容器实例IP设置为所创建的容器实例的IP。
以上创建容器实例的过程中,确定具体镜像、确定创建容器实例的宿主机的执行顺序并没有严格限定,在其他实施例中,也可以先确定创建容器实例的宿主机,再确定具体镜像。其中,根据该容器应用的应用环境、该容器应用的区域可确定容器应用创建的位置,即将容器应用创建在具体哪个机房中。需要注意的是,每个应用环境下每个区域中的都对应有保存镜像资源的镜像仓库。在该镜像仓库中保存有该应用环境下该区域所需要使用的所有的镜像资源。获取数据库中对应位置(该机房下)预先分配的用于创建容器实例的宿主机的IP 地址池;根据创建容器实例需占用的资源从宿主机的IP地址池中确定创建容器实例的宿主机。创建容器实例是需要在宿主机上占用一定的资源的,因此需要先确定创建容器实例需占用的资源,以判断宿主机是否有足够的资源来创建该容器实例。其中,创建容器实例需占用的资源包括CPU(CPU核数等)、内存、监控资源等。
其中,步骤S403,即根据所确定的具体镜像在所确定的宿主机上创建容器应用的容器实例,并将所创建的容器实例与所确定的容器实例IP进行绑定以将所确定的容器实例IP设置为所创建的容器实例的IP,包括:通过容器编排工具将所确定的具体镜像发送到所确定创建容器实例的宿主机上,以进行容器实例的创建;若创建完成,通过运维工具如ansible工具去连接容器实例,将所创建的容器实例与所确定的容器实例IP进行绑定以将所确定的容器实例IP设置为所创建的容器实例的IP。容器实例创建成功后,会返回创建成功的消息;容器实例若创建失败,会返回创建失败的原因。
在一实施例中,若当前容器应用的信息中的是否启用监控信息中的标识为启用监控标识,以上容器应用创建的过程中还涉及有为所创建容器应用的容器实例启用监控,对应的步骤还包括:
将容器实例对应的启用监控信息中的启用监控标识推送到所确定的宿主机上,以根据宿主机的监控进程收集该容器实例的运行数据信息。其中,默认所有宿主机上都会安装监控进程且该监控进程是启用状态。将启用监控标识推送到所确定的宿主机上,通过宿主机上安装的监控进程来监控该容器实例。如此,以方便获取该容器应用的所有容器实例的相关信息,方便定位容器应用中出现的异常。
在一实施例中,如图3所示,在步骤S301之前,根据所设置的容器应用的信息创建所述容器应用的容器实例的步骤,还包括:
S301a,根据预设的名称生成规则生成该容器应用的应用名称。
S301b,判断所生成的应用名称在该容器应用对应的区域中是否已经存在,其中,根据所述容器应用的应用环境、所述容器应用的区域确定容器应用对应的区域。若所生成的应用名称在该容器应用对应的区域中不存在,执行步骤S301。若所生成的应用名称在该容器应用对应的区域中已经存在,执行步骤S301d。
S301d,进行提示。在一实施例中,如图3所示,在步骤S301之前,根据所设置的容器应用的信息创建所述容器应用的容器实例的步骤,还包括:
S301c,根据所述容器实例的使用时间、所述容器应用的资源组、所述容器实例数量来判断所述容器应用的资源组中是否有足够金额以用来创建该容器应用的容器实例。若有足够金额来创建该容器应用的容器实例,执行步骤S301。若没有足够金额来创建该容器应用的容器实例,执行步骤S301d。
其中,预先保存所有创建过的容器应用的相关信息,保存的信息包括有容器应用的应用名称、区域。可以理解地,在同一区域中不允许存在两个完全相同的应用名。其中,根据容器应用的容器实例数量、容器实例的使用时间、每 个容器实例的费用计算创建当前容器应用需要支付的金额;判断容器应用的资源组中的剩余金额是否大于或者等于创建当前容器应用需要支付的金额;若是,则确定容器应用的资源组有足够金额以用来创建对应的容器应用;若否,则确定容器应用的资源组没有足够金额来进行创建。
S103,根据所设置的容器应用的信息确定创建LVS负载均衡应用的宿主机,并在所述宿主机上创建LVS容器。
根据容器应用的应用环境、容器应用的区域可确定容器应用创建的位置,即将容器应用创建在具体哪个机房的宿主机中。需要注意的是,一般而言,容器应用的容器实例所在的宿主机与负载均衡应用所在的宿主机不是同一个宿主机,以避免该宿主机出现故障后,会导致负载均衡应用不能使用,同时应用服务也不能使用。另外,容器应用的容器实例所在的宿主机与负载均衡应用所在的宿主机通常是在通一个网段内,以提高网络访问的速度。需要指出的是,创建负载均衡应用的宿主机集群与创建容器应用的宿主机集群可以是同一个宿主机集群,也可以是不同的分别独立的宿主机集群。确定了创建负载均衡应用的宿主机后,接着创建LVS负载均衡应用的LVS容器。
在一实施例中,如图5所示,步骤S103,包括以下步骤S501-S503。
S501,根据所述容器应用的信息中的容器应用的应用环境、容器应用的区域确定LVS镜像信息。
S502,根据所述容器应用的应用环境、容器应用的区域、所述LVS镜像信息确定创建LVS负载均衡应用的宿主机。
S503,根据所述LVS镜像信息在所述宿主机上创建LVS负载均衡应用的容器实例,将所创建的LVS负载均衡应用的容器实例称为LVS容器。
根据所述容器应用的信息中的容器应用的应用环境、容器应用的区域确定用于保存LVS镜像信息的镜像仓库并从镜像仓库中获取LVS镜像信息。根据所述容器应用的应用环境、容器应用的区域、所述LVS镜像信息确定创建LVS负载均衡应用的容器实例需占用的资源,根据所述容器应用的应用环境、容器应用的区域、所确定的创建LVS负载均衡应用的容器实例需占用的资源确定创建LVS负载均衡应用的宿主机。
其中,创建LVS负载均衡应用的容器实例与创建容器应用的容器实例的方法相同,在此不再赘述。其中,在创建LVS负载均衡应用的时候会根据LVS镜像信息会生成一个默认的配置文件,该配置文件保存在一个预设目录中。
S104,为所创建的LVS容器分配虚拟IP和管理IP。其中,虚拟IP(Virtual IP,VIP)即为服务IP,服务IP为提供负载均衡服务所需要使用的IP,也可以理解为对外使用的IP,即外部用户请求进来所对应的IP。管理IP为内部管理该LVS容器所使用的IP,如登陆该LVS容器所需要使用的IP。需要注意的是,由于LVS负载均衡是四层的负载均衡。四层负载均衡通过虚拟IP+端口接收请求,根据请求中的目的地址和源地址对请求进行转发,而无法修改或者判断请求资源的具体类型,然后经过负载均衡算法转发到要处理的请求的真实的服务器,在本实施例中,真实的服务器即为容器应用所对应的容器实例。由于是四 层的负载均衡,所以不用考虑要处理的具体应用,可对所有应用做负载均衡。因此,为LVS容器分配两个IP,方便LVS对外提供服务,同时也方便PaaS平台内部对该LVS容器进行管理。
在一实施例中,步骤S104包括以下步骤:根据所述容器应用的信息中的容器应用的应用环境、容器应用的区域,从预先分配的IP地址池中获取两个空闲IP;将所获取的两个空闲IP作为虚拟IP和管理IP,并将所述虚拟IP和管理IP分配给所创建的LVS容器。其中,根据所述容器应用的信息中的容器应用的应用环境、容器应用的区域可确定预先分配的IP地址池。需要注意的是,虚拟IP(VIP)和管理IP地址可以从两个不同的预先分配的地址池的空闲IP中获取,如VIP地址池和管理IP地址池;也可以是预先分配的一个地址池中获取,即从一个IP地址池中获取两个空闲IP,这两个空闲IP一个为VIP,一个为管理IP。
S105,根据所述虚拟IP、所创建的容器应用的容器实例、所述端口信息重构LVS负载均衡应用的配置文件。由于在创建LVS容器时,会根据LVS镜像信息会生成一个默认的配置文件,而该配置文件并不能真正用来做负载均衡使用。因此,需要重构该配置文件。在一实施例中,如图6所示,步骤S105包括以下步骤S601-S603。
S601,将所述虚拟IP、所创建的容器应用的容器实例、所述端口信息作为变量,传入到预设配置文件生成接口。
S602,根据所述预设配置文件生成接口中集成的配置文件模板生成新的配置文件。
S603,将新的配置文件上传至所述LVS容器的配置文件所在的预设目录中,以替换创建所述LVS负载均衡应用的LVS容器时所生成的配置文件。
其中,在一实施例中,在步骤S602之前,还包括生成配置文件模板。其中,生成配置文件模板的步骤,包括:获取预先设置的LVS负载均衡的参数信息、预先设置的容器实例的参数信息;设置虚拟IP参数、容器实例的IP参数以及负载均衡端口参数;根据预先设置的LVS负载均衡的参数信息、预先设置的容器实例的参数信息、所设置的虚拟IP参数、容器实例的IP参数以及负载均衡端口参数生成配置文件模板。其中,在一实施例中,生成的配置文件模板可按照如下方式来理解:生成的配置文件模板中包括了负载均衡信息和一个容器实例信息,该负载均衡信息包括所设置的虚拟IP参数、负载均衡端口参数、预先设置的LVS负载均衡的参数信息,该一个容器实例信息包括容器实例的IP参数、负载均衡端口参数、预先设置的容器实例的参数信息。在该实施例中,配置文件模板可以理解为一个端口所对应的相关配置信息。
其中,预先设置的LVS负载均衡的参数信息包括LVS负载均衡参数和LVS负载均衡参数所对应的值。LVS负载均衡参数包括LVS负载均衡算法参数(默认为轮询算法(轮询算法可简写为rr))、LVS负载均衡转发模式参数(默认为DR模式,该模式下通过为接收到的请求报文重新封装一下新的MAC地址,以转发到对应的服务器(即容器实例))、LVS负载均衡转发协议参数(默认为TCP协议,该协议默认使用LVS四层负载均衡)等。预先设置的容器实例的参 数信息包括容器实例参数和容器实例参数所对应的值。容器实例参数包括容器实例所对应服务器的权重参数(根据该权重来决定访问请求应该转发到哪个容器实例(服务器),若是轮询算法那么每个容器实例所对应的权重是一样的)、容器实例所对应的TCP健康检查参数(LVS负载均衡要定期检查容器实例(服务器)以检测容器实例是否可用)等。其中,容器实例所对应的TCP健康检查参数包括连接超时时间参数(默认为3s)、重连次数参数(默认为3次)、重连间隔时间参数(默认为3s)、所连接的端口参数(可与负载均衡应用的端口一致)。可以理解地,若在3s内都连接补上,那么认为连接超时,默认重连3次,每次重连间隔时间为3s。若重连3次,每次重连间隔时间为3s后,仍连接超时,那么认为该容器实例是不可用的。需要注意的是,在配置文件模板中所有的参数都是默认值,也可以理解为,配置文件模板中的参数值都是基于当前环境当前应用场景下的最优的值。如在一实施例中,生成的配置文件模板可包括以下内容:
Figure PCTCN2019103260-appb-000001
其中,xxx.yyy.zzz.mmm表示VIP,LVS_port表示负载均衡应用的端口,LVS_algorithm表示LVS负载均衡算法参数,LVS_kind表示LVS负载均衡转发模式参数,protocol表示LVS负载均衡转发协议参数。xxx.yyy.zzz.nnn表示容器实例的IP、weight表示容器实例所对应服务器的权重参数、TCP_CHECK表示容器实例所对应的服务器的TCP健康检查参数,该参数中包括以下参数:connect_timeout表示连接超时时间参数、nb_get_retry表示重连次数参数、delay_before_retry表示重连间隔时间参数、connect_port表示所连接的端口参数。
将VIP、所创建的容器实例、端口信息作为变量,传入到配置文件生成接口。其中,配置文件生成接口可以理解为是接口函数。通过该接口函数中集成的配置文件模板生成新的配置文件。所述根据预设的配置文件生成接口中集成的配置文件模板生成新的配置文件的步骤,包括:对于每一个负载均衡应用的端口,根据所创建的容器实例的数量在配置文件模板中生成相应数量的容器实 例信息,将所创建的容器实例的IP替换每一个容器实例信息中的容器实例的IP参数,将该负载均衡应用的端口替换每一个容器实例信息中的负载均衡端口参数;将VIP、该负载均衡应用的端口信息分别替换负载均衡信息中的所设置的虚拟IP参数、负载均衡端口参数,如此,可生成多个负载均衡应用的端口的相关配置信息,将负载均衡应用的所有端口的相关配置信息一起组成的文件作为新的配置文件。如若所创建的容器实例为第一数量,如4个,端口信息中包括第二数量,如两个端口80,443。那么生成的新的配置文件中,80端口所对应的容器实例信息有4个,443端口中所对应的容器实例数量也有4个。最后生成的新的配置文件中包括80端口的相关配置信息和443端口的相关配置信息。
在一实施例中,负载均衡端口参数是默认的,如默认端口包括80、443端口。如此在配置文件模板中包括了至少两个不同的端口所对应的相关配置信息。生成了新的配置文件后,将新的配置文件上传至LVS容器的配置文件所在的预设目录中,以替换创建LVS容器时根据LVS镜像信息生成的配置文件。如此,新的配置文件中有新分配的VIP、所创建的容器实例信息(IP)、端口信息的值。
S106,开启所述LVS容器的LVS负载均衡服务。在一实施例中,步骤S106包括:将新的配置文件与预设的启动脚本进行关联;执行关联后的预设的启动脚本。启动后,LVS负载均衡服务的状态修改为已启动。在某一实施例中,可使用命令来实现。如xxx/xxxxx/xx/xx/keepalived.conf restart.其中,keepalived.conf为新的配置文件,restart表示重启。
需要注意的是,为了让LVS负载均衡应用可以提供服务,在创建LVS容器时会有对应的负载均衡应用所依赖的环境信息,该环境信息包括子网卡。需要指出的是,子网卡并不是实际上的网络接口设备,但是也可以作为网络接口在系统中出现,如eth0:1、eth1:2这种网络接口。它们必须要依赖于物理网卡,虽然可以与物理网卡的网络接口同时在系统中存在并使用不同的IP地址,但是当所依赖的物理网卡不启用时(Down状态)这些子网卡也将一同不能工作。一个LVS容器可以对应有多个子网卡。开启LVS容器的LVS负载均衡服务的同时,会开启LVS容器所对应的子网卡。
S107,配置所述LVS容器的子网卡,以将所述虚拟IP与所述LVS容器的子网卡进行绑定。可以理解地,将VIP分配给LVS容器的一个子网卡,如此,可通过VIP访问该子网卡。如可以使用命令ifconfig来配置子网卡。需要注意的是,一个VIP对应一个子网卡,因此无论LVS负载均衡的端口有多少个,那么都对应一个子网卡。在一实施例中,配置该LVS容器的子网卡,可使用命令来实现。如:ifconfig eth0:1 192.168.1.54 netmask 255.255.255.255 broadcast 192.168.1.54up。其中,eth0:1表示子网卡eth0的网络接口1,192.168.1.54为VIP,255.255.255.255为掩码地址,192.168.1.54为广播地址。
S108,为配置后的所述子网卡添加路由,以完成在创建容器应用时,创建LVS负载均衡应用。由于LVS负载均衡是四层的负载均衡,因此需要为配置的 子网卡添加一条路由,以在访问负载均衡应用时,使得访问请求可到达该子网卡,再通过子网卡到达LVS容器所对应的宿主机。在一实施例中,可使用命令route add来添加路由。如route add-host 192.168.1.54 dev eth0:1。以上方法实施例自动完成了容器应用的创建以及LVS负载均衡应用的创建,自动实现了创建的负载均衡应用的基本设置,加快了创建的速度和效率。
在一实施例中,完成了LVS容器的基本设置后,还需要进一步验证LVS容器的有效性,即是否真实可用。如在一些情况下,IP已经释放后放回到对应的IP地址池中作为一个空闲IP存在,但是实际上该IP仍然在内存中并没有完全真实的释放。在该实施例中,如图1所示,所述负载均衡应用创建方法还包括以下步骤:
S108a,根据所述虚拟IP验证所述LVS容器的有效性。验证LVS容器的有效性,包括验证LVS的VIP是否真正完全释放,即该VIP是否可以作为一个独立的IP真实以供访问。如可使用arping命令。即向LVS容器的VIP发送ICMP包以对该IP地址进行检测,如果在设定的时间内能收到该VIP的ICMP的回应,则认为可以ping通。若可以ping通,则表示是有效的。若不能ping通,则表示VIP还不能使用,需要进一步核查。
若想每个服务器上的数据可以通过LVS负载均衡应用发送到用户端,那么还需要在每个服务器上设置服务器(容器应用的容器实例)与LVS均衡均衡应用的关联关系。在一实施例中,如图1所示,所述负载均衡应用创建方法还包括以下步骤:
S108b,设置所述容器应用的容器实例与虚拟IP的关联关系,以实现将所述容器应用的容器实例与虚拟IP进行绑定。所创建的容器应用的容器实例即为应用所对应的真实的服务器,即真正为用户访问请求提供服务的服务器。设置容器实例与LVS负载均衡应用的关联关系,具体地,设置容器应用的容器实例与VIP的关联关系,以将容器实例与VIP进行绑定。如此,访问服务器时,首先访问请求经过子网卡到达LVS负载均衡容器,LVS负载均衡容器根据访问请求的端口信息,再通过一定的负载均衡算法,将访问请求分配给某个容器实例(其中一个服务器),以通过容器实例返回访问请求所需要的信息。
以上方法实施例创建容器应用的同时创建LVS负载均衡应用,并且将创建的容器应用与创建的LVS负载均衡应用进行了自动关联,因此无需将创建容器应用和创建LVS负载均衡应用分开进行创建,且无需将两者进行手动关联,加快了创建的速度。以上创建容器应用的同时创建LVS负载均衡应用,且将创建的容器应用与创建的LVS负载均衡应用进行了自动关联,这整个过程自动完成,进一步加快了创建的速度和效率,节约了时间成本和人工成本。
图7是本申请实施例提供的负载均衡应用创建装置的示意性框图。该装置包括用于执行上述负载均衡应用创建方法所对应的单元。具体地,如图7所示,该装置70包括设置单元701、应用创建单元702、LVS创建单元703、IP分配单元704、重构单元705、开启单元706、网卡配置单元707、路由添加单元708。
设置单元701,用于若接收到设置指令,根据所述设置指令调用预设的设 置接口,以通过所述预设的设置接口设置需创建的容器应用的信息以及负载均衡应用的信息,其中,负载均衡应用的信息包括负载均衡应用的类型、负载均衡应用的端口信息,其中,负载均衡应用的类型为LVS。
应用创建单元702,用于若接收到设置完成指令,根据所设置的容器应用的信息创建所述容器应用的容器实例。
在一实施例中,如图8所示,应用创建单元702包括实例IP确定单元801、实例创建单元802。其中,实例IP确定单元801,用于根据所设置的容器应用的信息中的容器应用的应用环境、容器应用的区域、容器应用的容器实例数量确定所述容器应用的容器实例IP。实例创建单元802,用于根据所设置的容器应用的信息中的容器应用镜像信息、所述容器应用的应用环境、所述容器应用的区域、所述容器应用的容器实例数量创建容器实例,将所确定的容器实例IP设置为所创建的容器实例IP。
在一实施例中,如图8所示,应用创建单元702还包括名称生成单元801a、名称判断单元801b、提示单元801d。其中,名称生成单元801a,用于根据预设的名称生成规则生成该容器应用的应用名称。名称判断单元801b,用于判断所生成的应用名称在该容器应用对应的区域中是否已经存在。若所生成的应用名称在该容器应用对应的区域中不存在,触发实例IP确定单元801。提示单元801d,用于若所生成的应用名称在该容器应用对应的区域中已经存在,进行提示。
在一实施例中,如图8所示,应用创建单元702还包括金额判断单元801c。其中,金额判断单元801c,用于根据所述容器实例的使用时间、所述容器应用的资源组、所述容器实例数量来判断所述容器应用的资源组中是否有足够金额以用来创建该容器应用的容器实例。若有足够金额来创建该容器应用的容器实例,触发实例IP确定单元801。若没有足够金额来创建该容器应用的容器实例,触发提示单元801d。
在一实施例中,如图9所示,实例创建单元802包括镜像确定单元901、宿主机确定单元902、应用实例创建单元903。其中,镜像确定单元901,用于根据所述容器应用的应用环境、容器应用的区域确定用于保存容器应用镜像信息的镜像仓库并根据容器应用镜像信息的镜像类型、镜像版本以及镜像名称从所确定的镜像仓库中提取出创建容器实例所需要使用的具体镜像。宿主机确定单元902,用于根据所述镜像类型、镜像版本以及镜像名称确定创建容器实例需占用的资源,并根据容器应用的应用环境、容器应用的区域以及创建容器实例需占用的资源确定创建容器实例的宿主机。应用实例创建单元903,用于根据所确定的具体镜像在所确定的宿主机上创建容器应用的容器实例,并将所创建的容器实例与所确定的容器实例IP进行绑定以将所确定的容器实例IP设置为所创建的容器实例的IP。LVS创建单元703,用于根据所设置的容器应用的信息确定创建LVS负载均衡应用的宿主机,并在所述宿主机上创建LVS容器。
在一实施例中,如图10所示,LVS创建单元703包括LVS镜像确定单元101、LVS宿主机确定单元102、LVS容器创建单元103。其中,LVS镜像确定单元101, 用于根据所述容器应用的信息中的容器应用的应用环境、容器应用的区域确定LVS镜像信息。LVS宿主机确定单元102,用于根据所述容器应用的应用环境、容器应用的区域、所述LVS镜像信息确定创建LVS负载均衡应用的宿主机。LVS容器创建单元103,用于根据所述LVS镜像信息在所述宿主机上创建LVS负载均衡应用的容器实例,将所创建的LVS负载均衡应用的容器实例称为LVS容器。
IP分配单元704,用于为所创建的LVS容器分配虚拟IP和管理IP。重构单元705,用于根据所述虚拟IP、所创建的容器应用的容器实例、所述端口信息重构LVS负载均衡应用的配置文件。
在一实施例中,如图11所示,重构单元705包括参数传入单元111、配置文件生成单元112、替换单元113。其中,参数传入单元111,用于将所述虚拟IP、所创建的容器应用的容器实例、所述端口信息作为变量,传入到预设配置文件生成接口。配置文件生成单元112,用于根据所述预设配置文件生成接口中集成的配置文件模板生成新的配置文件。替换单元113,用于将新的配置文件上传至所述LVS容器的配置文件所在的预设目录中,以替换创建所述LVS负载均衡应用的LVS容器时所生成的配置文件。
在一实施例中,重构单元705还包括模板生成单元。所述模板生成单元用于生成配置文件模板。其中,模板生成单元包括参数获取单元、参数设置单元、配置模板生成单元。其中,参数获取单元,用于获取预先设置的LVS负载均衡参数的信息、预先设置的容器实例的参数信息。参数设置单元,用于设置虚拟IP参数、容器实例的IP参数以及端口参数。配置模板生成单元,用于根据预先设置的LVS负载均衡的参数信息、预先设置的容器实例的参数信息、所设置的虚拟IP参数、容器实例的IP参数以及端口参数生成配置文件模板。
开启单元706,用于开启所述LVS容器的LVS负载均衡服务。网卡配置单元707,用于配置所述LVS容器的子网卡,以将所述虚拟IP与所述LVS容器的子网卡进行绑定。路由添加单元708,用于为配置后的所述子网卡添加路由,以完成在创建容器应用时,创建LVS负载均衡应用。
在一实施例中,如图7所示,所述负载均衡应用创建装置还包括验证单元708a。所述验证单元708a,用于根据所述虚拟IP验证所述LVS容器的有效性。
在一实施例中,如图7所示,所述负载均衡应用创建装置还包括关联设置单元708b。所述关联设置单元708b,用于若所述LVS容器有效,设置所述容器应用的容器实例与虚拟IP的关联关系,以实现将所述容器应用的容器实例与虚拟IP进行绑定。
需要说明的是,所属领域的技术人员可以清楚地了解到,上述装置和各单元的具体实现过程,可以参考前述方法实施例中的相应描述,为了描述的方便和简洁,在此不再赘述。
上述装置可以实现为一种计算机程序的形式,计算机程序可以在如图12所示的计算机设备上运行。图12为本申请实施例提供的一种计算机设备的示意性框图。该设备为终端等设备,如PaaS平台中的服务器等。该设备120包括通过系统总线121连接的处理器122、存储器和网络接口123,其中,存储器可以 包括非易失性存储介质124和内存储器125。
该非易失性存储介质124可存储操作系统1241和计算机程序1242。该非易失性存储介质中所存储的计算机程序1242被处理器122执行时,可实现上述服务器中所述的负载均衡应用创建方法。该处理器122用于提供计算和控制能力,支撑整个设备120的运行。该内存储器125为非易失性存储介质中的计算机程序的运行提供环境,该计算机程序被处理器122执行时,可使得处理器122执行上述服务器中所述的负载均衡应用创建方法。该网络接口123用于进行网络通信。本领域技术人员可以理解,图12中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的设备的限定,具体的设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。
其中,所述处理器122用于运行存储在存储器中的计算机程序,以实现本申请实施例的负载均衡应用创建方法。本领域技术人员可以理解,图12中示出的计算机设备的实施例并不构成对计算机设备具体构成的限定,在其他实施例中,计算机设备可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。例如,在一些实施例中,计算机设备可以仅包括存储器及处理器,在这样的实施例中,存储器及处理器的结构及功能与图12所示实施例一致,在此不再赘述。
应当理解,在本申请实施例中,所称处理器122可以是中央处理单元(Central Processing Unit,CPU),该处理器还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(应用程序lication Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
在本申请的另一实施例中提供计算机可读存储介质。该计算机可读存储介质可以为非易失性的计算机可读存储介质。该计算机可读存储介质存储有计算机程序,其中计算机程序被处理器执行时实现本申请实施例的负载均衡应用创建方法。
所述存储介质为实体的、非瞬时性的存储介质,例如可以是U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、磁碟或者光盘等各种可以存储程序代码的实体存储介质。
所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,上述描述的设备、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到各种等效的修改或替换,这些修改或替换都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以权利要求的保护范围为准。

Claims (20)

  1. 一种负载均衡应用创建方法,包括:
    若接收到设置指令,根据所述设置指令调用预设的设置接口,以通过所述预设的设置接口设置需创建的容器应用的信息以及负载均衡应用的信息,其中,负载均衡应用的信息包括负载均衡应用的类型、负载均衡应用的端口信息,其中,负载均衡应用的类型为Liunx虚拟服务器(Linux Virtual Server,LVS);
    若接收到设置完成指令,根据所设置的容器应用的信息创建所述容器应用的容器实例;
    根据所设置的容器应用的信息确定创建LVS负载均衡应用的宿主机,并在所述宿主机上创建LVS容器;
    为所创建的LVS容器分配虚拟IP和管理IP;
    根据所述虚拟IP、所创建的容器应用的容器实例、所述端口信息重构LVS负载均衡应用的配置文件;
    开启所述LVS容器的LVS负载均衡服务;
    配置所述LVS容器的子网卡,以将所述虚拟IP与所述LVS容器的子网卡进行绑定;
    为配置后的所述子网卡添加路由,以完成在创建容器应用时,创建LVS负载均衡应用。
  2. 根据权利要求1所述的方法,其中,所述根据所设置的容器应用的信息确定创建LVS负载均衡应用的宿主机,并在所述宿主机上创建LVS容器,包括:
    根据所述容器应用的信息中的容器应用的应用环境、容器应用的区域确定LVS镜像信息;
    根据所述容器应用的应用环境、容器应用的区域、所述LVS镜像信息确定创建LVS负载均衡应用的宿主机;
    根据所述LVS镜像信息在所述宿主机上创建LVS负载均衡应用的容器实例,将所创建的LVS负载均衡应用的容器实例称为LVS容器。
  3. 根据权利要求1所述的方法,其中,所述根据所述虚拟IP、所创建的容器应用的容器实例、所述端口信息重构LVS负载均衡应用的配置文件,包括:
    将所述虚拟IP、所创建的容器应用的容器实例、所述端口信息作为变量,传入到预设配置文件生成接口;
    根据所述预设配置文件生成接口中集成的配置文件模板生成新的配置文件;
    将新的配置文件上传至所述LVS容器的配置文件所在的预设目录中,以替换创建所述LVS负载均衡应用的LVS容器时所生成的配置文件。
  4. 根据权利要求3所述的方法,其中,所述方法还包括生成配置文件模板,所述生成配置文件模板,包括:
    获取预先设置的LVS负载均衡的参数信息、预先设置的容器实例的参数信息;
    设置虚拟IP参数、容器实例的IP参数以及端口参数;
    根据预先设置的LVS负载均衡的参数信息、预先设置的容器实例的参数信息、所设置的虚拟IP参数、容器实例的IP参数以及端口参数生成配置文件模板。
  5. 根据权利要求1所述的方法,其中,所述根据所设置的容器应用的信息创建所述容器应用的容器实例,包括:
    根据所设置的容器应用的信息中的容器应用的应用环境、容器应用的区域、容器应用的容器实例数量确定所述容器应用的容器实例IP;
    根据所设置的容器应用的信息中的容器应用镜像信息、所述容器应用的应用环境、所述容器应用的区域、所述容器应用的容器实例数量创建容器实例,将所确定的容器实例IP设置为所创建的容器实例的IP。
  6. 根据权利要求5所述的方法,其中,所述根据所设置的容器应用的信息中的容器应用镜像信息、所述容器应用的应用环境、所述容器应用的区域、所述容器应用的容器实例数量创建容器实例,将所确定的容器实例IP设置为所创建的容器实例的IP,包括:
    根据所述容器应用的应用环境、容器应用的区域确定用于保存容器应用镜像信息的镜像仓库并根据容器应用镜像信息的镜像类型、镜像版本以及镜像名称从所确定的镜像仓库中提取出创建容器实例所需要使用的具体镜像;
    根据所述镜像类型、镜像版本以及镜像名称确定创建容器实例需占用的资源,并根据容器应用的应用环境、容器应用的区域以及创建容器实例需占用的资源确定创建容器实例的宿主机;
    根据所确定的具体镜像在所确定的宿主机上创建容器应用的容器实例,并将所创建的容器实例与所确定的容器实例IP进行绑定以将所确定的容器实例IP设置为所创建的容器实例的IP。
  7. 根据权利要求6所述的方法,其中,所述根据所确定的具体镜像在所确定的宿主机上创建容器应用的容器实例,并将所创建的容器实例与所确定的容器实例IP进行绑定以将所确定的容器实例IP设置为所创建的容器实例的IP,包括:
    通过容器编排工具将所确定的具体镜像发送到所确定创建容器实例的宿主机上,以进行容器实例的创建;
    根据所述容器实例的创建结果,返回对应的消息;其中,在所述容器实例创建成功后,返回创建成功的消息;在所述容器实例创建失败时,返回创建失败的原因;
    在创建完成后,通过运维工具连接容器实例,将所创建的容器实例与所确定的容器实例IP进行绑定以将所确定的容器实例IP设置为所创建的容器实例的IP。
  8. 根据权利要求1所述的方法,其中,所述为所创建的LVS容器分配虚拟IP和管理IP,包括:根据所述容器应用的信息中的容器应用的应用环境以及容器应用的区域,从预先分配的IP地址池中获取两个空闲IP;
    将获取的所述两个空闲IP分别作为虚拟IP和管理IP;
    将所述虚拟IP和所述管理IP分配给所创建的LVS容器。
  9. 根据权利要求1所述的方法,其中,所述方法还包括:
    根据所述虚拟IP验证所述LVS容器的有效性;
    若所述LVS容器有效,设置所述容器应用的容器实例与虚拟IP的关联关系,以实现将所述容器应用的容器实例与虚拟IP进行绑定。
  10. 一种负载均衡应用创建装置,包括:
    设置单元,用于若接收到设置指令,根据所述设置指令调用预设的设置接口,以通过所述预设的设置接口设置需创建的容器应用的信息以及负载均衡应用的信息,其中,负载均衡应用的信息包括负载均衡应用的类型、负载均衡应用的端口信息,其中,负载均衡应用的类型为Liunx虚拟服务器(Linux Virtual Server,LVS);
    应用创建单元,用于若接收到设置完成指令,根据所设置的容器应用的信息创建所述容器应用的容器实例;
    LVS创建单元,用于根据所设置的容器应用的信息确定创建LVS负载均衡应用的宿主机,并在所述宿主机上创建LVS容器;
    IP分配单元,用于为所创建的LVS容器分配虚拟IP和管理IP;
    重构单元,用于根据所述虚拟IP、所创建的容器应用的容器实例、所述端口信息重构LVS负载均衡应用的配置文件;
    开启单元,用于开启所述LVS容器的LVS负载均衡服务;
    网卡配置单元,用于配置所述LVS容器的子网卡,以将所述虚拟IP与所述LVS容器的子网卡进行绑定;
    路由添加单元,用于为配置后的所述子网卡添加路由,以完成在创建容器应用时,创建LVS负载均衡应用。
  11. 一种计算机设备,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,其中,所述处理器执行所述计算机程序时实现以下步骤:
    若接收到设置指令,根据所述设置指令调用预设的设置接口,以通过所述预设的设置接口设置需创建的容器应用的信息以及负载均衡应用的信息,其中,负载均衡应用的信息包括负载均衡应用的类型、负载均衡应用的端口信息,其中,负载均衡应用的类型为Liunx虚拟服务器(Linux Virtual Server,LVS);
    若接收到设置完成指令,根据所设置的容器应用的信息创建所述容器应用的容器实例;
    根据所设置的容器应用的信息确定创建LVS负载均衡应用的宿主机,并在所述宿主机上创建LVS容器;
    为所创建的LVS容器分配虚拟IP和管理IP;
    根据所述虚拟IP、所创建的容器应用的容器实例、所述端口信息重构LVS负载均衡应用的配置文件;
    开启所述LVS容器的LVS负载均衡服务;
    配置所述LVS容器的子网卡,以将所述虚拟IP与所述LVS容器的子网卡进 行绑定;
    为配置后的所述子网卡添加路由,以完成在创建容器应用时,创建LVS负载均衡应用。。
  12. 根据权利要求11所述的计算机设备,其中,所述根据所设置的容器应用的信息确定创建LVS负载均衡应用的宿主机,并在所述宿主机上创建LVS容器,包括:
    根据所述容器应用的信息中的容器应用的应用环境、容器应用的区域确定LVS镜像信息;
    根据所述容器应用的应用环境、容器应用的区域、所述LVS镜像信息确定创建LVS负载均衡应用的宿主机;
    根据所述LVS镜像信息在所述宿主机上创建LVS负载均衡应用的容器实例,将所创建的LVS负载均衡应用的容器实例称为LVS容器。
  13. 根据权利要求11所述的计算机设备,其中,所述根据所述虚拟IP、所创建的容器应用的容器实例、所述端口信息重构LVS负载均衡应用的配置文件,包括:
    将所述虚拟IP、所创建的容器应用的容器实例、所述端口信息作为变量,传入到预设配置文件生成接口;
    根据所述预设配置文件生成接口中集成的配置文件模板生成新的配置文件;
    将新的配置文件上传至所述LVS容器的配置文件所在的预设目录中,以替换创建所述LVS负载均衡应用的LVS容器时所生成的配置文件。
  14. 根据权利要求13所述的计算机设备,其中,所述处理器执行所述计算机程序时还包括实现生成配置文件模板的步骤;
    所述生成配置文件模板,包括:获取预先设置的LVS负载均衡的参数信息、预先设置的容器实例的参数信息;设置虚拟IP参数、容器实例的IP参数以及端口参数;根据预先设置的LVS负载均衡的参数信息、预先设置的容器实例的参数信息、所设置的虚拟IP参数、容器实例的IP参数以及端口参数生成配置文件模板。
  15. 根据权利要求11所述的计算机设备,其中,所述根据所设置的容器应用的信息创建所述容器应用的容器实例,包括:
    根据所设置的容器应用的信息中的容器应用的应用环境、容器应用的区域、容器应用的容器实例数量确定所述容器应用的容器实例IP;
    根据所设置的容器应用的信息中的容器应用镜像信息、所述容器应用的应用环境、所述容器应用的区域、所述容器应用的容器实例数量创建容器实例,将所确定的容器实例IP设置为所创建的容器实例的IP。
  16. 根据权利要求15所述的计算机设备,其中,所述根据所设置的容器应用的信息中的容器应用镜像信息、所述容器应用的应用环境、所述容器应用的区域、所述容器应用的容器实例数量创建容器实例,将所确定的容器实例IP设置为所创建的容器实例的IP,包括:
    根据所述容器应用的应用环境、容器应用的区域确定用于保存容器应用镜像信息的镜像仓库并根据容器应用镜像信息的镜像类型、镜像版本以及镜像名称从所确定的镜像仓库中提取出创建容器实例所需要使用的具体镜像;
    根据所述镜像类型、镜像版本以及镜像名称确定创建容器实例需占用的资源,并根据容器应用的应用环境、容器应用的区域以及创建容器实例需占用的资源确定创建容器实例的宿主机;
    根据所确定的具体镜像在所确定的宿主机上创建容器应用的容器实例,并将所创建的容器实例与所确定的容器实例IP进行绑定以将所确定的容器实例IP设置为所创建的容器实例的IP。
  17. 根据权利要求16所述的计算机设备,其中,所述根据所确定的具体镜像在所确定的宿主机上创建容器应用的容器实例,并将所创建的容器实例与所确定的容器实例IP进行绑定以将所确定的容器实例IP设置为所创建的容器实例的IP,包括:
    通过容器编排工具将所确定的具体镜像发送到所确定创建容器实例的宿主机上,以进行容器实例的创建;
    根据所述容器实例的创建结果,返回对应的消息;其中,在所述容器实例创建成功后,返回创建成功的消息;在所述容器实例创建失败时,返回创建失败的原因;
    在创建完成后,通过运维工具连接容器实例,将所创建的容器实例与所确定的容器实例IP进行绑定以将所确定的容器实例IP设置为所创建的容器实例的IP。
  18. 根据权利要求11所述的计算机设备,其中,所述为所创建的LVS容器分配虚拟IP和管理IP,包括:根据所述容器应用的信息中的容器应用的应用环境以及容器应用的区域,从预先分配的IP地址池中获取两个空闲IP;
    将获取的所述两个空闲IP分别作为虚拟IP和管理IP;
    将所述虚拟IP和所述管理IP分配给所创建的LVS容器。
  19. 根据权利要求11所述的计算机设备,其中,所述处理器执行所述计算机程序时还包括实现如下步骤:
    根据所述虚拟IP验证所述LVS容器的有效性;
    若所述LVS容器有效,设置所述容器应用的容器实例与虚拟IP的关联关系,以实现将所述容器应用的容器实例与虚拟IP进行绑定。
  20. 一种计算机可读存储介质,其中,所述计算机可读存储介质存储有计算机程序,所述计算机程序当被处理器执行时使所述处理器执行以下操作:
    若接收到设置指令,根据所述设置指令调用预设的设置接口,以通过所述预设的设置接口设置需创建的容器应用的信息以及负载均衡应用的信息,其中,负载均衡应用的信息包括负载均衡应用的类型、负载均衡应用的端口信息,其中,负载均衡应用的类型为Liunx虚拟服务器(Linux Virtual Server,LVS);
    若接收到设置完成指令,根据所设置的容器应用的信息创建所述容器应用的容器实例;
    根据所设置的容器应用的信息确定创建LVS负载均衡应用的宿主机,并在所述宿主机上创建LVS容器;
    为所创建的LVS容器分配虚拟IP和管理IP;
    根据所述虚拟IP、所创建的容器应用的容器实例、所述端口信息重构LVS负载均衡应用的配置文件;
    开启所述LVS容器的LVS负载均衡服务;
    配置所述LVS容器的子网卡,以将所述虚拟IP与所述LVS容器的子网卡进行绑定;
    为配置后的所述子网卡添加路由,以完成在创建容器应用时,创建LVS负载均衡应用。
PCT/CN2019/103260 2019-05-17 2019-08-29 负载均衡应用创建方法、装置、计算机设备及存储介质 WO2020232890A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910414034.8 2019-05-17
CN201910414034.8A CN110266761B (zh) 2019-05-17 2019-05-17 负载均衡应用创建方法、装置、计算机设备及存储介质

Publications (1)

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

Family

ID=67913413

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/103260 WO2020232890A1 (zh) 2019-05-17 2019-08-29 负载均衡应用创建方法、装置、计算机设备及存储介质

Country Status (2)

Country Link
CN (1) CN110266761B (zh)
WO (1) WO2020232890A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113672337A (zh) * 2021-07-16 2021-11-19 广东浪潮智慧计算技术有限公司 一种应用迁移方法、装置、设备及计算机可读存储介质

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110830574B (zh) * 2019-11-05 2023-01-20 浪潮云信息技术股份公司 一种基于docker容器实现内网负载均衡的方法
CN112905210B (zh) * 2021-03-24 2023-09-15 青岛聚看云科技有限公司 服务器及灰度发布方法
CN113497765B (zh) * 2021-09-08 2021-11-30 中兴通讯股份有限公司 一种路由管理的方法、装置、电子设备和存储介质
CN113992683B (zh) * 2021-10-25 2024-02-13 重庆紫光华山智安科技有限公司 实现同一集群中双网络有效隔离的方法、系统、设备及介质

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104780115A (zh) * 2014-01-14 2015-07-15 上海盛大网络发展有限公司 云计算环境中负载均衡方法及系统
CN105979009A (zh) * 2016-07-06 2016-09-28 乾云众创(北京)信息科技研究院有限公司 一种针对云应用容器的增加负载自动均衡方法
CN106302771A (zh) * 2016-08-23 2017-01-04 浪潮电子信息产业股份有限公司 一种基于Docker容器创建的应用的域名配置方法
WO2018120800A1 (zh) * 2016-12-29 2018-07-05 华为技术有限公司 一种负载均衡的方法、装置和系统
CN108829384A (zh) * 2018-06-13 2018-11-16 平安科技(深圳)有限公司 容器的管理方法、装置、计算机设备及存储介质
CN109343963A (zh) * 2018-10-30 2019-02-15 杭州数梦工场科技有限公司 一种容器集群的应用访问方法、装置及相关设备

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108512872A (zh) * 2017-02-27 2018-09-07 长沙六人行网络科技合伙企业(有限合伙) 一种基于虚拟服务器集群负载均衡策略方法
CN108023953B (zh) * 2017-12-04 2021-07-09 北京星选科技有限公司 Ftp服务的高可用实现方法和装置
CN108833163B (zh) * 2018-06-13 2020-08-28 平安科技(深圳)有限公司 Linux虚拟服务器的创建方法、装置、计算机设备及存储介质
CN109167702A (zh) * 2018-08-28 2019-01-08 新华三大数据技术有限公司 一种基于负载均衡的分布式测试方法及装置

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104780115A (zh) * 2014-01-14 2015-07-15 上海盛大网络发展有限公司 云计算环境中负载均衡方法及系统
CN105979009A (zh) * 2016-07-06 2016-09-28 乾云众创(北京)信息科技研究院有限公司 一种针对云应用容器的增加负载自动均衡方法
CN106302771A (zh) * 2016-08-23 2017-01-04 浪潮电子信息产业股份有限公司 一种基于Docker容器创建的应用的域名配置方法
WO2018120800A1 (zh) * 2016-12-29 2018-07-05 华为技术有限公司 一种负载均衡的方法、装置和系统
CN108829384A (zh) * 2018-06-13 2018-11-16 平安科技(深圳)有限公司 容器的管理方法、装置、计算机设备及存储介质
CN109343963A (zh) * 2018-10-30 2019-02-15 杭州数梦工场科技有限公司 一种容器集群的应用访问方法、装置及相关设备

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113672337A (zh) * 2021-07-16 2021-11-19 广东浪潮智慧计算技术有限公司 一种应用迁移方法、装置、设备及计算机可读存储介质
CN113672337B (zh) * 2021-07-16 2024-02-13 广东浪潮智慧计算技术有限公司 一种应用迁移方法、装置、设备及计算机可读存储介质

Also Published As

Publication number Publication date
CN110266761A (zh) 2019-09-20
CN110266761B (zh) 2022-04-19

Similar Documents

Publication Publication Date Title
WO2020232890A1 (zh) 负载均衡应用创建方法、装置、计算机设备及存储介质
CN110224860B (zh) 负载均衡应用创建方法、装置、计算机设备及存储介质
US11252228B2 (en) Multi-tenant multi-session catalogs with machine-level isolation
EP3316532B1 (en) Computer device, system and method for implementing load balancing
US20220200926A1 (en) Virtual network interface objects
US10411947B2 (en) Hot swapping and hot scaling containers
JP6670025B2 (ja) クラウド・ネットワーキングのためのマルチテナント認識型動的ホスト構成プロトコル(dhcp)機構
US10684888B1 (en) Self-organizing server migration to service provider systems
WO2019184164A1 (zh) 自动部署Kubernetes从节点的方法、装置、终端设备及可读存储介质
WO2020024413A1 (zh) 一种云计算平台部署的控制方法、服务器及存储介质
WO2019237588A1 (zh) Linux虚拟服务器的创建方法、装置、计算机设备及存储介质
CN110289983B (zh) 负载均衡应用创建方法、装置、计算机设备及存储介质
US11388261B2 (en) Cross-domain brokering protocol cloud proxy
US10826723B1 (en) Virtual network address space auto-migration
US11108673B2 (en) Extensible, decentralized health checking of cloud service components and capabilities
CN114070723A (zh) 裸金属服务器的虚拟网络配置方法、系统及智能网卡
CN113810230A (zh) 对容器集群中的容器进行网络配置的方法、装置及系统
CN110166544B (zh) 负载均衡应用创建方法、装置、计算机设备及存储介质
US20180248952A1 (en) Protocol independent storage discovery and enablement
US11783066B2 (en) Securely sharing files with user devices based on location
US20240039923A1 (en) Method and apparatus for deploying network device, device, system, and storage medium
WO2020252921A1 (zh) 多活负载均衡应用的扩容方法、装置、设备及存储介质
CN116264538A (zh) 数据处理方法、装置、设备及计算机存储介质
CN110365742B (zh) 多活负载均衡应用创建方法、装置、计算机设备及存储介质
US11870647B1 (en) Mapping on-premise network nodes to cloud network nodes

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

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

Country of ref document: EP

Kind code of ref document: A1