Containerized configuration file hot loading method based on micro service

By containerized deployment of haproxy+keepalived and externally mounting configuration files, the service interruption problem caused by HAProxy configuration update is solved, and a seamless hot restart is achieved to ensure zero downtime and service continuity without connection interruption.

CN120378307APending Publication Date: 2025-07-25QIMING INFORMATION TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510507476.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-22
Publication Date
2025-07-25

AI Technical Summary

Technical Problem

Traditional HAProxy updates or configuration changes cause service outages and connection outages, affecting the user experience.

Method used

The microservice containerized configuration file hot loading method is adopted, haproxy+keepalived is deployed in containerized, and the configuration files are mounted externally, and configuration modifications are taken into effect in the alternate environment, supporting grayscale release and error rollback.

Benefits of technology

Enable zero downtime and no connection interruption configuration updates to ensure service continuity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120378307A_ABST
    Figure CN120378307A_ABST
Patent Text Reader

Abstract

The invention discloses a method for hot loading of a containerized configuration file based on micro-service. The method comprises the following steps: S1, deploying haploxy + keepalived through containerization; s2, externally mounting a configuration file of the haploxy; and S3, modifying the haploxy configuration file and enabling the haploxy configuration file to take effect. And immediately rolling back to the version before modification when an error occurs in the version after the haploxy configuration file is modified. Seamless hot restart is introduced, so that zero downtime and no connection interruption can be realized when configuration is updated or modified.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software operation and maintenance, and specifically provides a method for hot loading a configuration file based on microservice containerization. Background Art

[0002] Haproxy is highly performant. As a reliable and powerful solution, it is widely used in various network service load balancing environments. Haproxy distributes business requests to each backend server, ensuring load balancing of the business, as well as fault transfer and recovery of the business, and guaranteeing high availability of the business.

[0003] When it is necessary to update or change the configuration of HAProxy, the traditional restart method will cause service interruption and connection interruption, bringing inconvenience and delay to users. Summary of the Invention

[0004] To solve the above problems, the present invention provides a method for hot loading a configuration file based on microservice containerization, including the following steps: S1. Deploy haproxy + keepalived through containerization; S2. Externally mount the configuration file of haproxy; S3. Modify the haproxy configuration file and make it effective.

[0005] Further, the specific steps of S1 are as follows: Make images of haproxy and keealived, deploy them through k8s, and store data and logs in pvc.

[0006] Further, the specific steps of S2 include the following sub-steps: Externally mount the configuration file of haproxy and create a gray release v1 version file.

[0007] Further, the specific steps of creating the gray release v1 version file include the following sub-steps: S21. Select the access method of the gateway and enable the gateway and link tracing; S22. Add key-value pairs and provide configuration information; S23. Create a gray release v1 version file and determine the maintenance information.

[0008] Further, the access methods of the gateway in S21 specifically include: NodePort, LoadBalancer; the maintenance information in S23 specifically includes: domain name, protocol, path, service, port.

[0009] Further, the specific steps of S3 are as follows: Create a gray release v2 version file, create a standby environment identical to the existing execution environment, modify the haproxy configuration file and make it effective in the standby environment.

[0010] Further, it also includes an error rollback step: when an error occurs in the version after modifying the haproxy configuration file, immediately roll back to the version before the modification.

[0011] The present invention provides a method for hot loading a microservice containerized configuration file, which has the following beneficial effects: The present invention introduces seamless hot restart, enabling zero downtime and no connection interruption when updating or modifying the configuration. Description of the Drawings

[0012] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on the structures shown in these drawings.

[0013] Figure 1 It is a flowchart of the method provided by the present invention. Detailed Embodiments

[0014] It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0015] The following will detail the implementation method of the present invention with reference to the drawings. What is described is only part of the embodiments, not all embodiments. For the purpose of clarity, the representations and descriptions unrelated to the present invention are omitted in the drawings and the description.

[0016] For a clearer understanding of the technical features, objectives, and beneficial effects of the present invention, the following will detail the technical solutions of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all embodiments, and should not be construed as limiting the scope of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the protection scope of the present invention.

[0017] As Figure 1 shown, the present invention provides a method for hot loading a microservice containerized configuration file, including the following steps: S1. Deploy haproxy + keepalived through containerization; S2. Externally mount the configuration file of haproxy; S3. Modify the haproxy configuration file and make it effective.

[0018] The specific content of step S1 is: Make images of haproxy and keealived, deploy them through k8s, and store data and logs in pvc.

[0019] keepalived configuration file (keepalived.conf): vrrp_instance VI_1 { state MASTER interface eth0 virtual_router_id 51 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1234 } virtual_ipaddress { 192.168.1.100 } }。

[0020] Configure haproxy.cnf: global log 127.0.0.1 local0 chroot / var / lib / haproxy pidfile / var / run / haproxy.pid maxconn 655350 user haproxy group haproxy daemon defaults mode tcp log global option tcplog retries 3 maxconn 65535 timeout connect 10s timeout client 120m timeout server 120m listen stats mode http bind 0.0.0.0:8888 #haproxy port listening stats enable stats hide-version stats uri / haproxystats stats realm Haproxy stats stats auth admin:P@55w0rd! stats admin if TRUE listen https bind *:443 mode tcp balance roundrobin server backend-node01 192.168.1.101:443 check weight 1 server backend-node02 192.168.1.101:443 check weight 1 listen http bind *:80 mode tcp balance roundrobin server backend-node01 192.168.1.101:80 check weight 1 server backend-node02 192.168.1.101:80 check weight 1。

[0021] Blue-green deployment creates an identical standby environment where the new application version is run, providing an efficient way to release a new version without downtime or service interruption. By this method, all traffic is routed to one of the versions, i.e., only one environment receives traffic at any given time. If any problems occur with the new build version, it can be immediately rolled back to the previous version.

[0022] The specific steps in S2 include the following sub-steps: externally mount the configuration file of haproxy and create a gray release v1 version file (implement the configuration file of haproxy through mounting, so that the modification of configuration parameters can be made more flexible): S21. Select the access method of the gateway (NodePort: access the node port corresponding to the service through the gateway, LoadBalancer: access the separate IP address of the service through the gateway) and enable the gateway and link tracing. In the gateway enabling dialog box, link tracing can be enabled. When creating a self-developed application, link tracing must be enabled to use the link tracing function and different gray release strategies. If you cannot access the route after enabling link tracing, add an annotation in the route (Ingress), such as: nginx.ingress.kubernetes.io / service-upstream: true.

[0023] S22. Add key-value pairs and provide configuration information for the system components of the NGINX Ingress controller.

[0024] S23. Create a gray release v1 version file and determine the maintenance information.

[0025] The specific steps of S3 are: create a gray release v2 version file, create a standby environment identical to the existing execution environment, modify the haproxy configuration file and make it take effect in the standby environment.

[0026] It also includes an error rollback step: when an error occurs in the version after modifying the haproxy configuration file, immediately roll back to the version before the modification.

[0027] The containerized deployment of Haproxy is completed, the configuration file is mounted out, and a gray release v1 version is created. When the configuration of haproxy needs to be modified, a gray release v2 version needs to be created. The v2 version takes over all traffic. This design is a seamless restart that will not cause business interruption, and the service automatically connects and forwards the backend load. Take the gray release v1 offline. Existing services are also involved in forwarding failures.

[0028] The present invention introduces seamless hot restart, enabling zero downtime and no connection interruption when updating or modifying the configuration.

[0029] The above are only the preferred embodiments of the present invention. It should be understood that the present invention is not limited to the form disclosed herein, should not be regarded as an exclusion of other embodiments, but can be used in various other combinations, modifications and environments, and can be changed within the scope of the concept described herein through the above teachings or the technology or knowledge in related fields. And the changes and variations made by those skilled in the art that do not depart from the spirit and scope of the present invention should all be within the protection scope of the appended claims of the present invention.

Claims

1. A method for hot loading of microservice containerized configuration files, characterized in that, It includes the following steps: S1. Deploy haproxy + keepalived through containerization; S2. Mount the configuration file of haproxy externally; S3. Modify the haproxy configuration file and make it take effect.

2. The method for hot loading of a microservice containerized configuration file according to claim 1, wherein The specific content of step S1 is: Create images of haproxy and keepalived, deploy them through k8s, and store data and logs in pvc.

3. The method for hot loading of a microservice containerized configuration file according to claim 1, characterized in that The specific content of step S2 includes the following sub-steps: Mount the configuration file of haproxy externally and create a v1 version file for gray release.

4. The method for hot loading of a microservice containerized configuration file according to claim 3, characterized in that The specific content of creating the v1 version file for gray release includes the following sub-steps: S21. Select the access method of the gateway and enable the gateway and link tracing; S22. Add key-value pairs and provide configuration information; S23. Create a v1 version file for gray release and determine the maintenance information.

5. The method for hot loading of a microservice containerized configuration file according to claim 4, characterized in that The access methods of the gateway in step S21 specifically include: NodePort, LoadBalancer; the maintenance information in step S23 specifically includes: domain name, protocol, path, service, port.

6. The method for hot loading of a microservice containerized configuration file according to claim 1, wherein The specific content of step S3 is: Create a v2 version file for gray release, create a standby environment identical to the existing execution environment, modify the haproxy configuration file and make it take effect in the standby environment.

7. The method for hot loading of a microservice containerized configuration file according to claim 1, wherein It also includes an error rollback step: When an error occurs in the version after modifying the haproxy configuration file, immediately roll back to the version before modification.