Method for publishing network time protocol service and electronic device
By building and loading the image of the Network Time Protocol (NTP) service into a container, the resource contention and security issues between virtual machines are resolved, enabling efficient service publishing and management, and improving the system's flexibility and security.
Patent Information
- Application Number
- CN202511612297.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-05
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2045-11-05
AI Technical Summary
When multiple virtual machines run on the same physical host, performance degradation and network latency are caused by competition for system resources. Logical isolation or access control is required between virtual machines to prevent lateral attacks or resource exhaustion, which leads to poor compatibility and makes it difficult to drive adaptation and cross-platform management.
The first and second images of the Network Time Protocol (NTP) service are constructed and loaded into their respective containers. The service is then published by obtaining the address identifier and writing configuration data, thereby decoupling the service from the configuration and improving the flexibility of the architecture and the security of the system.
It solves the problems of performance degradation and network latency caused by system resource contention, enhances system security and operation and maintenance automation, reduces system resource consumption, and is suitable for network service scenarios with limited resources or high performance requirements.
Smart Images

Figure CN121070528B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of cloud computing, and particularly relates to a network time protocol service publishing method and an electronic device. BACKGROUND
[0002] In the related art, a network time protocol (NTP for short) can be built using a virtual machine, for example, a plurality of virtual machines are installed and started, and a network is configured for each virtual machine, and then an NTP service is installed, and a synchronization source and other options are set by editing an NTP configuration file.
[0003] However, in the related art, when a plurality of virtual machines are run on the same physical host, because each virtual machine needs certain system resources, performance degradation and network delay can be caused by system resource competition, in addition, logical isolation or access control is needed between virtual machines to prevent cross-attack or resource exhaustion between virtual machines, which leads to poor compatibility, difficulty in driving adaptation and cross-platform management, and the like, and improvement is needed. SUMMARY
[0004] The present application provides a network time protocol service publishing method and an electronic device to at least solve the problem in the related art that when a plurality of virtual machines are run on the same physical host, because each virtual machine needs certain system resources, performance degradation and network delay can be caused by system resource competition, in addition, logical isolation or access control is needed between virtual machines to prevent cross-attack or resource exhaustion between virtual machines, which leads to poor compatibility, difficulty in driving adaptation and cross-platform management, and the like.
[0005] The present application provides a network time protocol service publishing method, comprising the following steps: based on at least one service feature of a network time protocol service, constructing a first image for providing the network time protocol service and a second image for configuring the network time protocol service; loading the first image and the second image into containers corresponding to the first image and the second image respectively to construct a first container and a second container; obtaining an address identifier of the network time protocol service in the first container, and writing the address identifier into configuration data of the second container, so as to obtain the address identifier according to the configuration data, and publish a corresponding network time protocol service according to the address identifier.
[0006] The second aspect embodiment of the present application provides a network time protocol service publishing device, comprising the following steps: a first construction module, configured to construct a first image for providing a network time protocol service and a second image for configuring the network time protocol service based on at least one service feature of the network time protocol service; a second construction module, configured to load the first image and the second image into containers corresponding to the first image and the second image respectively to construct a first container and a second container; and a publishing module, configured to obtain an address identifier of the network time protocol service in the first container, and write the address identifier into configuration data of the second container, so as to obtain the address identifier according to the configuration data and publish a corresponding network time protocol service according to the address identifier.
[0007] The present application also provides an electronic device, comprising a memory for storing a computer program and a processor for executing the computer program to implement the steps of any of the network time protocol service publishing methods.
[0008] The present application also provides a computer readable storage medium, which stores a computer program, wherein the computer program is executed by a processor to implement the steps of any of the network time protocol service publishing methods.
[0009] The present application also provides a computer program product comprising a computer program, wherein the computer program is executed by a processor to implement the steps of any of the network time protocol service publishing methods.
[0010] According to the present application, the corresponding first image and the second image for configuring the network time protocol service can be constructed according to the service features of the network time protocol service, and the first image and the second image are loaded into the corresponding containers to construct the first container and the second container, and the address identifier of the network time protocol service obtained is written into the configuration data of the second container to publish the corresponding network time protocol service according to the configuration data, so that the technical problems in the related art, such as performance degradation and network delay caused by system resource competition due to the need of each virtual machine for certain system resources when multiple virtual machines run on the same physical host, the need of logical isolation or access control between virtual machines to prevent horizontal attacks or resource exhaustion between virtual machines, poor compatibility, difficulty in driving adaptation and cross-platform management, etc., can be solved, the service and configuration are decoupled, the architecture flexibility is improved, the operation and maintenance automation is enhanced, the system security is improved, the system resource consumption is greatly reduced under the premise of ensuring the integrity of the functions, and the technical effects of being suitable for resource-limited or high-performance network service scenarios are achieved. BRIEF DESCRIPTION OF DRAWINGS
[0011] In order to more clearly illustrate the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments. Obviously, the drawings described below only illustrate some of the embodiments of the present application, and other drawings can be obtained by those skilled in the art without any creative effort on the basis of these drawings.
[0012] Figure 1 The flow chart of a network time protocol service publishing method according to an embodiment of the present application;
[0013] Figure 2 The flow chart of the working principle of a network time protocol service publishing method according to an embodiment of the present application;
[0014] Figure 3 The block schematic diagram of a network time protocol service publishing device according to an embodiment of the present application.
[0015] Reference signs:
[0016] Among them, 10-network time protocol service publishing device; 100-first construction module, 200-second construction module, 300-publishing module. DETAILED DESCRIPTION
[0017] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without any creative effort fall within the protection scope of the present application.
[0018] It should be noted that in the description of the present application, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that the processes, methods, articles or devices comprising a series of elements not only include those elements, but also include other elements not explicitly listed or inherent to such processes, methods, articles or devices. The terms "first", "second" and the like in the present application are used to distinguish similar objects, not to describe a specific order or sequence.
[0019] In order to make those skilled in the art better understand the present application, the present application will be further described in detail below with reference to the drawings and specific embodiments.
[0020] The embodiments of the present application provide a network time protocol service publishing method, which is described in detail in combination with the execution flow of the network time protocol service publishing method.
[0021] Specifically,Figure 1 A flowchart of a method for publishing a network time protocol service according to an embodiment of the present application.
[0022] As shown in Figure 1 The method for publishing a network time protocol service includes the following steps:
[0023] In step S101, based on at least one service feature of the network time protocol service, a first image for providing the network time protocol service and a second image for configuring the network time protocol service are constructed.
[0024] It can be understood that in the embodiments of the present application, the NTP service is a protocol for synchronizing computer system time, which can synchronize the time of a device with one or more time servers through the Internet or a local area network, ensuring that all devices use uniform and accurate time.
[0025] The dynamic host configuration protocol (DHCP) is a protocol for automatically allocating Internet protocol addresses and other network configuration parameters, and is widely used in local area networks, so that devices can automatically obtain Internet protocol addresses, subnet masks, default gateways, domain name system servers and other information when accessing the network, without manual configuration.
[0026] The NTP server option is a standard option defined in the DHCP protocol, which is used to provide the address information of the NTP service to the client. It allows the DHCP service to issue one or more Internet protocol addresses of the NTP time server when allocating the Internet protocol address, so that the client can automatically configure the time synchronization service.
[0027] Therefore, based on the service features of the NTP service, the embodiments of the present application can select the DHCP service for address configuration.
[0028] As a possible implementation manner, the embodiments of the present application can construct the first image and the second image for configuring the NTP service according to the service features of the NTP service.
[0029] The first image, as the core running environment of the NTP service, can encapsulate the NTP service software (such as ntpd or chronyd) and its dependent libraries, to ensure the high-precision time synchronization capability of the service; the second image encapsulates the configuration management tool of the NTP service, to realize dynamic configuration update and monitoring.
[0030] Optionally, in an embodiment of the present application, the first image for providing the network time protocol service and the second image for configuring the network time protocol service are constructed, comprising: selecting a network driver mode suitable for communicating with the client based on the construction environment data; determining first image parameters corresponding to the network time protocol service based on the network driver mode, so as to construct the first image according to the first image parameters; and determining second image parameters corresponding to the network time protocol service based on the network driver mode, so as to construct the second image according to the second image parameters.
[0031] It can be understood that, in the embodiments of the present application, the construction environment data can include, but is not limited to, basic environment dependencies, a construction tool chain, configuration parameters, and environment variables, and the present application does not make specific limitations. The basic environment dependencies can include an operating system, a kernel version, and dependent libraries, and the present application does not make specific limitations; the construction tool chain can include a compiler version, a package management tool, and a construction tool, and the present application does not make specific limitations.
[0032] Further, in the embodiments of the present application, the network driver mode can include, but is not limited to, a bridge mode, a host mode, an overlay network mode, and a MAC (Media Access Control Address) address virtualization mode, and the present application does not make specific limitations.
[0033] The bridge mode is suitable for container communication on the same host and external communication through network address translation and port mapping; the host mode shares the host network and is suitable for high-performance scenarios; the overlay network mode is suitable for distributed environments; and the MAC address virtualization mode assigns independent MAC addresses to containers and is suitable for scenarios that need to directly access the physical network. It is a network virtualization technology provided by the Linux kernel, which allows you to create multiple virtual interfaces with independent MAC addresses on the same physical network interface. Each MAC virtual local area network interface can have its own Internet Protocol address and be directly connected to the physical network, just like an independent physical device. This is very useful in a container environment, especially when containers obtain real Internet Protocol addresses in the same subnet as the host, rather than communicating through network address translation or bridge networks. The specific settings can be made by those skilled in the art according to actual conditions, and the present application does not make specific limitations.
[0034] In actual execution, the embodiments of the present application can select a suitable network driver mode according to the construction environment data, and then determine the first image parameters and the second image parameters, so as to construct the first image and the second image. The first image parameters can include, but are not limited to, a basic environment and network configuration, and the second image parameters can include, but are not limited to, a basic environment and network configuration, and the present application does not make specific limitations.
[0035] The embodiment of the present application can select a network drive mode suitable for communication with the client by constructing environment data, and then determine corresponding first mirror parameters and second mirror parameters, so as to construct the first mirror and the second mirror, adapt the drive mode, reduce communication delay, optimize network performance, avoid deployment failure caused by environment incompatibility, enhance cross-environment compatibility, automate parameter generation, reduce human error, improve operation and maintenance efficiency, and optimize resource utilization.
[0036] Optionally, in an embodiment of the present application, before constructing the first mirror for providing the network time protocol service and the second mirror for configuring the network time protocol service, the method further comprises: obtaining construction environment data of the first mirror and the second mirror; determining whether the construction environment data meets preset environment conditions; if the construction environment data does not meet the preset environment conditions, adjusting at least one environment parameter in the construction environment data based on the first mirror and the second mirror until the construction environment data that meets the preset environment conditions is obtained to allow the construction of the first mirror and the second mirror; and if the construction environment data meets the preset environment conditions, allowing the construction of the first mirror and the second mirror.
[0037] It can be understood that the embodiment of the present application can determine whether the obtained construction environment data meets certain environment conditions, and if not, adjust the environment parameters in the construction environment data until the certain environment conditions are met and the construction of the first mirror and the second mirror is allowed. The certain environment conditions can be set by those skilled in the art according to actual conditions, and the present application does not make specific limitations.
[0038] The environment parameters can include, but are not limited to, operating system version, dependent library, network drive mode, security configuration, etc., and the present application does not make specific limitations. For example, if the operating system version is too old and does not meet certain environment conditions, the embodiment of the present application can upgrade the operating system version until the certain environment conditions are met; if the dependent library is missing and does not meet certain environment conditions, the embodiment of the present application can reinstall the dependent library until the certain environment conditions are met; if the network setting is incorrect and does not meet certain environment conditions, the embodiment of the present application can adjust the port mapping or the network mode until the certain environment conditions are met, etc.
[0039] The embodiment of the application can obtain the build environment data of the first image and the second image before constructing the first image and the second image, and determine whether the build environment data meets certain environment conditions. If not, the environment parameters are adjusted until the build environment data meeting certain environment conditions is obtained, and the construction of the first image and the second image is allowed. If yes, the construction of the first image and the second image is allowed, avoiding the interruption of image construction or runtime error caused by environment incompatibility, reducing the deployment failure rate, parameter optimization automation, reducing manual intervention, improving resource utilization, strengthening security compliance, and meeting audit requirements.
[0040] Optionally, in an embodiment of the application, obtaining the build environment data of the first image and the second image comprises: obtaining first base dependent environment data, first build tool chain data, first configuration parameter data and first environment variable data of the first image; obtaining second base dependent environment data, second build tool chain data, second configuration parameter data and second environment variable data of the second image; and obtaining the build environment data based on the first base dependent environment data, the first build tool chain data, the first configuration parameter data, the first environment variable data, the second base dependent environment data, the second build tool chain data, the second configuration parameter data and the second environment variable data.
[0041] In some embodiments, the embodiment of the application can obtain the build environment data based on the first base dependent environment data, the first build tool chain data, the first configuration parameter data and the first environment variable data of the first image.
[0042] For example, the first base dependent environment data of the first image of the embodiment of the application includes an operating system version, a kernel version, a dependent library, etc., the first build tool chain data includes a compiler version, a package management tool, a build tool, etc.; the first configuration parameter data includes a list of upstream servers, a local clock driver configuration, a base image label, an exposed port, user permissions, etc.; and environment variables, etc. The application does not make specific limitations, and the build environment data is obtained.
[0043] In some embodiments, the embodiment of the application can obtain the build environment data based on the second base dependent environment data, the second build tool chain data, the second configuration parameter data and the second environment variable data of the second image.
[0044] For example, the second base dependent environment data of the second image of the embodiment of the application includes an operating system version, a kernel version, a dependent library, etc., the second build tool chain data includes a compiler version, a package management tool, a build tool, etc.; the second configuration parameter data includes subnet definition, address pool range, lease time, base image, exposed port, persistent volume, etc.; and environment variables, etc. The application does not make specific limitations, and the build environment data is obtained.
[0045] The embodiment of the present application obtains the first base dependent environment data, the first build tool chain data, the first configuration parameter data and the first environment variable data of the first image and the second base dependent environment data, the second build tool chain data, the second configuration parameter data and the second environment variable data of the second image, obtains the build environment data, the environment data is transparent, the problem positioning efficiency is improved, different base dependencies, tool chains and the like are combined, the build environment data suitable for different scenes is quickly generated, multi-scene reuse is supported, and the manual operation risk is reduced.
[0046] Optionally, in an embodiment of the present application, the first image for providing a network time protocol service and the second image for configuring the network time protocol service are constructed, comprising: respectively verifying whether the first image and the second image match corresponding target images; if the first image does not match the corresponding target image, adjusting at least one image parameter in the first image based on the corresponding target image until the first image matching the corresponding target image is obtained; and if the second image does not match the corresponding target image, adjusting at least one image parameter in the second image based on the corresponding target image until the second image matching the corresponding target image is obtained.
[0047] It can be understood that the embodiment of the present application can verify whether the first image and the second image match the corresponding target image through the label, content, configuration parameter and the like of the image.
[0048] In some embodiments, the embodiment of the present application can verify whether the first image matches the corresponding target image, if not, determine the image parameter when adjusting the first image according to the target image, and then obtain the first image matching the target image.
[0049] In some embodiments, the embodiment of the present application can verify whether the second image matches the corresponding target image, if not, determine the image parameter when adjusting the second image according to the target image, and then obtain the second image matching the target image.
[0050] The embodiment of the present application verifies whether the first image and the second image match the corresponding target image, and adjusts the image parameter when not matching, and then obtains the first image or the second image matching the corresponding target image, ensures that the construction result is completely consistent with the target, eliminates the implicit deviation, automatically analyzes the difference type and makes corresponding adjustment, does not need manual investigation, reduces manual intervention, combines static verification and dynamic verification, improves the image quality and improves the cross-environment reusability.
[0051] Optionally, in an embodiment of the present application, verifying whether the first image and the second image match the corresponding target images comprises: respectively obtaining image hash values of the first image, the second image and the corresponding target images; and verifying whether the first image and the second image match the corresponding target images based on the image hash values.
[0052] It can be understood that the image hash value or the image tag of the image can be used as a standard for distinguishing different images.
[0053] In some embodiments, the embodiments of the present application can verify whether the first image matches the target image according to the hash value of the first image and the hash value of the corresponding target image.
[0054] In some embodiments, the embodiments of the present application can verify whether the second image matches the target image according to the hash value of the second image and the hash value of the corresponding target image.
[0055] The embodiments of the present application can verify whether the first image and the second image match the corresponding target images through the image hash value, which simplifies the verification process and improves the construction efficiency. In addition, the hash value can accurately identify the difference in image content by 100%, avoiding the problem of "verification passed but actual content error" caused by metadata forgery or collision attack, preventing malicious tampering, reducing invalid construction and transmission resource consumption.
[0056] In step S102, the first image and the second image are respectively loaded into the containers corresponding to the first image and the second image to construct the first container and the second container.
[0057] It can be understood that in the embodiments of the present application, the container is one of the most core technologies in modern software development and operation, which provides a lightweight virtualization method to package the application and its dependencies together for consistent operation in different environments. Podman is an open source tool for developing, managing and running OCI (Open Container Initiative) container images. It is similar to Docker, but has some key differences, especially in terms of not requiring a daemon and supporting non-privileged mode.
[0058] In some embodiments, the embodiments of the present application can first confirm the existence and parameters of the first image, and then load the first image into the corresponding container to construct the first container.
[0059] In some embodiments, the embodiments of the present application can first confirm the existence and parameters of the second image, and then load the second image into the corresponding container to construct the second container.
[0060] Exemplarily, the embodiment of the present application can confirm the existence and parameters of the first image and the second image, load the images into the containers using the Docker command or equivalent method, configure the running parameters of the containers such as port mapping, environment variable, storage volume, etc., ensure that the containers can run correctly and provide NTP service or DHCP service, and then build the first container or the second container.
[0061] Optionally, in an embodiment of the present application, the first image and the second image are loaded into the containers corresponding to the first image and the second image respectively to build the first container and the second container, comprising: obtaining target host data of the first container and the second container; determining first resource data and first network data of the first container, and second resource data and second network data of the second container based on the target host data; loading the first image into the container corresponding to the first image based on the first resource data and the first network data to build the first container; and loading the second image into the container corresponding to the second image based on the second resource data and the second network data to build the second container.
[0062] It can be understood that in the embodiment of the present application, the target host data can be the central processing unit, memory, network configuration and other data of the virtual machine, or the central processing unit, memory, network configuration and other data of the physical machine, which can be set by the person skilled in the art according to the actual situation, and the present application does not make specific limitation.
[0063] Further, the embodiment of the present application can determine the first resource data and the first network data of the first container, such as the central processing unit, memory, service port, etc., according to the target host data, and the present application does not make specific limitation.
[0064] Exemplarily, the embodiment of the present application can limit the central processing unit of the first container to 1 core when the target host central processing unit usage exceeds 80%, and limit the memory of the first container to 512 MB when the target host memory usage exceeds 80%, and the present application does not make specific limitation.
[0065] Further, the embodiment of the present application can load the first image into the corresponding container according to the first resource data and the first network data, thereby building the first container.
[0066] In some embodiments, the embodiment of the present application can determine the second resource data and the second network data of the second container, such as the central processing unit, memory, service port, etc., according to the target host data and the first resource data and the first network data of the first container, and the present application does not make specific limitation.
[0067] For example, the embodiment of the present application can limit the central processor of the second container to 1 core when the central processor usage of the target host exceeds 80% and the central processor of the first container is 1 core; limit the memory of the second container to 256 MB when the memory usage of the target host exceeds 80% and the memory of the first container is 512 MB, and the present application does not make specific limitation.
[0068] Further, the embodiment of the present application can load the second image into the corresponding container according to the second resource data and the second network data, thereby constructing the second container.
[0069] The embodiment of the present application can determine the first resource data and the first network data of the first container and the second resource data and the second network data of the second container according to the target host data of the first container and the second container, further construct the corresponding container, dynamically perceive the host state, customize the resource and network configuration for each container, avoid performance decline or resource contention caused by host environment difference, allocate resources on demand, improve host utilization, dynamically plan network configuration, avoid port conflict and network storm, guarantee service stability, and adapt to dynamic load.
[0070] Optionally, in an embodiment of the present application, after the first container and the second container are constructed, it further includes: based on the first container and the second container, respectively establishing health detection instructions applicable to the first container and the second container; based on the health detection instructions, respectively judging whether the first container and the second container meet the preset health detection target; if the first container does not meet the preset health detection target, obtaining a first health detection result of the first container to determine a first health adjustment instruction of the first container meeting the preset health detection target according to the first health detection result; if the second container does not meet the preset health detection target, obtaining a second health detection result of the second container to determine a second health adjustment instruction of the second container meeting the preset health detection target according to the second health detection result.
[0071] It can be understood that the embodiment of the present application can respectively establish health detection instructions applicable to the first container and the second container, further judge whether the first container and the second container meet a certain health detection target, if not, obtain the corresponding health detection result, thereby determining the corresponding health adjustment instruction, and further obtaining the first container and the second container meeting the certain health detection target. The certain health detection target can be set by those skilled in the art according to the actual situation, and the present application does not make specific limitation.
[0072] The health detection instruction for the first container (NTP service) can include, but is not limited to, detection of a time synchronization state, detection of a running state, detection of a port and a log, and the like, without specific limitation in the application; and the health detection instruction for the second container (DHCP service) can include, but is not limited to, detection of a service state, detection of a port and a log, detection of an address pool health degree, and the like, without specific limitation in the application.
[0073] Further, in the embodiment of the application, the first health adjustment instruction and the second health adjustment instruction can include, but are not limited to, restarting a container or a service; adjusting resource limits; updating an image or a service version; optimizing network configuration, and the like, without specific limitation in the application.
[0074] The embodiment of the application can establish the health detection instruction applicable to the first container and the second container after the first container and the second container are constructed, and then determine whether the containers meet a certain health detection target, and generate a corresponding health adjustment instruction when the containers meet the certain health detection target, to actively manage the health, prevent fault propagation, analyze multi-dimensional health detection results, accurately locate the root cause of the fault, shorten the repair time, dynamically generate adjustment instructions, realize automatic repair of the container state, reduce manual intervention, adapt to service characteristics, and avoid excessive adjustment and resource waste.
[0075] Optionally, in an embodiment of the application, the first health adjustment instruction for determining that the first container meets the preset health detection target according to the first health detection result includes: determining at least one of a time synchronization deviation value, a response delay time, a response success rate and a resource usage rate of the first container based on the first health detection result; determining at least one of a corresponding time synchronization deviation target value, a response delay target time, a response success target rate and a resource usage target rate based on the at least one of the time synchronization deviation value, the response delay time, the response success rate and the resource usage rate; and determining the first health adjustment instruction based on at least one of the time synchronization deviation target value, the response delay target time, the response success target rate and the resource usage target rate, and the at least one of the time synchronization deviation value, the response delay time, the response success rate and the resource usage rate.
[0076] It can be understood that, in order to obtain the first container meeting a certain health detection target, the embodiment of the application can be optimized from the time synchronization deviation value, the response delay time, the response success rate and the resource usage rate of the first container, and then the first health adjustment instruction is determined.
[0077] For example, the embodiment of the present application can set the time synchronization deviation target value to be ≤±10 ms (high-precision scenarios can be tightened to ±5 ms, which is not limited in the present application); set the response delay target time to be ≤200 ms (95% quantile, which is not limited in the present application); set the response success target rate to be ≥99.9% (which is not limited in the present application); and set the resource usage target rate to include the target value of the central processor utilization rate, the target value of the memory occupation, the target value of the network bandwidth, etc., such as the target value of the central processor utilization rate ≤70%, the target value of the memory occupation ≤128 MB, and the target value of the network bandwidth ≤10 Mbps. The actual situation can be set by those skilled in the art, which is not limited in the present application.
[0078] Further, when the time synchronization deviation value is >10 ms, the embodiment of the present application can determine the first health adjustment instruction to be restarting the ntpd service and checking the time source configuration; when the response delay time is >200 ms, the first health adjustment instruction is determined to be checking the firewall rule and the NTP service configuration; and when the log is abnormal, the first health adjustment instruction is determined to be updating the image or adjusting the NTP verification function, which can be set by those skilled in the art according to the actual situation, which is not limited in the present application.
[0079] The embodiment of the present application can determine the time synchronization deviation value, the response delay time, the response success rate and the resource usage rate of the first container according to the first health detection result, and determine the first health adjustment instruction in combination with the corresponding time synchronization deviation target value, the response delay target time, the response success target rate and the resource usage target rate, so as to quantify the health status, eliminate subjective judgment errors, avoid single index false positives in combination with the abnormal combination of multiple health indexes, dynamically adjust the threshold, adapt to business scenario requirements, reduce manual intervention, and optimize the operation efficiency.
[0080] Optionally, in an embodiment of the present application, the second health adjustment instruction for determining that the second container meets the preset health detection target according to the second health detection result comprises: determining at least one of a request success rate, a response time, a resource usage rate, a port availability result, an address pool utilization rate and a subnet configuration result of the second container based on the second health detection result; determining at least one of a corresponding request success target rate, a target response time, a target resource usage rate, a target port availability result, a target address pool utilization rate and a target subnet configuration result based on at least one of the request success rate, the response time, the resource usage rate, the port availability result, the address pool utilization rate and the subnet configuration result; and determining the second health adjustment instruction based on at least one of the request success rate, the response time, the resource usage rate, the port availability result, the address pool utilization rate and the subnet configuration result and at least one of the corresponding request success target rate, the target response time, the target resource usage rate, the target port availability result, the target address pool utilization rate and the target subnet configuration result.
[0081] It can be understood that, in order to obtain the second container meeting the certain health detection target, the embodiment of the present application can be optimized from the aspects of the request success rate, the response time, the resource usage rate, the port availability result, the address pool utilization rate and the subnet configuration result, and then the second health adjustment instruction is determined.
[0082] For example, the embodiment of the present application can set the request success target rate to be ≥99.9%; set the target response time to be ≤150 ms (95% quantile value, which is not limited in the present application); set the target resource usage rate to include a target value of central processing unit utilization rate, a target value of memory occupation, disk input / output, etc., such as the target value of central processing unit utilization rate ≤60%, the target value of memory occupation ≤256 MB, and the Internet protocol address pool read / write delay of disk input / output ≤10 ms, which can be set by a person skilled in the art according to actual conditions, and is not limited in the present application.
[0083] Further, in the case of an application programming interface (API) response timeout, the embodiment of the present application determines the second health adjustment instruction to be increasing container resource limits or optimizing service configuration; in the case of resource usage rate exceeding the limit, the embodiment of the present application determines the second health adjustment instruction to be adjusting Docker running parameters; and in the case of service state being abnormal, the embodiment of the present application determines the second health adjustment instruction to be executing a health check endpoint self-healing script, which can be set by a person skilled in the art according to actual conditions, and is not limited in the present application.
[0084] The embodiment of the application can determine the request success rate, response time, resource usage rate, port availability result, address pool utilization rate and subnet configuration result of the second container according to the second health detection result, and determine the second health adjustment instruction in combination with the corresponding request success target rate, target response time, target resource usage rate, target port availability result, target address pool utilization rate and target subnet configuration result, multi-index comprehensive evaluation, eliminate monitoring blind area, quantify health status, realize accurate fault positioning, meet differentiated business needs, realize resource and performance balance, and optimize operation efficiency.
[0085] In step S103, the address identifier of the network time protocol service in the first container is acquired, and the address identifier is written into the configuration data of the second container, so as to acquire the address identifier according to the configuration data, and publish the corresponding network time protocol service according to the address identifier.
[0086] In some embodiments, the embodiment of the application can first acquire the address identifier of the network time protocol service in the first container, and then write the address identifier into the configuration data of the second container, so as to send the address identifier corresponding to the network time protocol service to the client through the configuration data, and then publish the corresponding network time protocol service.
[0087] For example, the NTP service is published in the manner proposed in the embodiment of the application, and the beneficial effects are shown in Tables 1 to 4. Table 1 is a schematic table of saving effects under different categories according to one embodiment of the application; Table 2 is a schematic table of performance advantages of different components according to one embodiment of the application; Table 3 is a comparison table of different service modes according to one embodiment of the application; and Table 4 is a configuration table of different scenarios according to one embodiment of the application.
[0088] Table 1
[0089]
[0090] Table 2
[0091]
[0092] Table 3
[0093]
[0094] Table 4
[0095]
[0096] Optionally, in an embodiment of the present application, writing the address identifier into the configuration data of the second container comprises: determining a communication mode between the first container and the second container based on the communication mechanism feature between the first container and the second container in the network driver mode; determining an address allocation mode for writing the address identifier into the second container based on the communication mode; and writing the configuration data based on the address allocation mode.
[0097] In some embodiments, in the case that the network driver mode of the embodiment of the present application is the bridge mode, the communication mechanism feature is that the containers communicate through a virtual bridge, and the Docker automatically allocates a private Internet Protocol address, at this time, the communication mode between the first container and the second container can be direct communication or port mapping, and then the address allocation mode is obtained, and the address identifier is written into the corresponding configuration data according to the obtained address allocation mode.
[0098] In some embodiments, in the case that the network driver mode of the embodiment of the present application is the host mode, the communication mechanism feature is that the containers directly use the host network stack (without independent Internet Protocol address), and the service binds the host Internet Protocol address and port, at this time, the communication mode between the first container and the second container can be direct access, and then the address allocation mode is obtained, and the address identifier is written into the corresponding configuration data according to the obtained address allocation mode.
[0099] In some embodiments, in the case that the network driver mode of the embodiment of the present application is the overlay network mode, the communication mechanism feature is that the containers are supported for name resolution based on a virtual extensible local area network tunnel and built-in domain name system, and the Docker automatically allocates a globally unique Internet Protocol address, at this time, the communication mode between the first container and the second container can be service name access or load balancing, and then the address allocation mode is obtained, and the address identifier is written into the corresponding configuration data according to the obtained address allocation mode.
[0100] In some embodiments, in the case that the network driver mode of the embodiment of the present application is the MAC address virtualization mode, the communication mechanism feature is that the containers obtain independent MAC addresses, directly access the physical network, and manually allocate an Internet Protocol address in the same network segment as the physical network, at this time, the communication mode between the first container and the second container can be broadcast / multicast, and then the address allocation mode is obtained, and the address identifier is written into the corresponding configuration data according to the obtained address allocation mode.
[0101] The embodiment of the present application can determine the communication mode between the first container and the second container according to the communication mechanism characteristics between the first container and the second container in the network driver mode, and then determine the address allocation mode of writing the address identifier into the second container, so as to write the configuration data, dynamically adapt the communication mode, eliminate the configuration conflict, automatically allocate the address, reduce the manual intervention, realize the dynamic address pool management, avoid the address waste, optimize the network resource utilization, enhance the network isolation and security.
[0102] Optionally, in an embodiment of the present application, the corresponding network time protocol service is published according to the address identifier, comprising: starting the second container to obtain the corresponding address identifier; responding to the service request of the corresponding network time protocol service; and publishing the corresponding network time protocol service based on the service request and the corresponding address identifier.
[0103] In some embodiments, the embodiment of the present application can obtain the corresponding address identifier by starting the second container, and respond to the service request of the corresponding network time protocol service, and then publish the corresponding network time protocol service.
[0104] For example, when the embodiment of the present application starts the second container, the container runtime allocates a network namespace for it, configures a network interface through a container network interface plug-in, obtains the corresponding address identifier, responds to the service request of the network time protocol service, and the service registry center binds the container address and the NTP service based on the address identifier, and then publishes the corresponding network time protocol service.
[0105] The embodiment of the present application can obtain the corresponding address identifier by starting the second container, and respond to the service request of the corresponding network time protocol service, and then publish the corresponding network time protocol service, dynamically bind the address, realize the service plug and play, realize the accurate service publishing, avoid the resource waste, dynamically adapt the address, ensure the service availability in the hybrid network environment, support the complex network environment, guarantee the high availability, and realize the fault self-healing.
[0106] Optionally, in an embodiment of the present application, the address identifier of the network time protocol service in the first container is obtained, comprising: identifying the configuration data of the network time protocol service; and obtaining the address identifier based on the configuration data.
[0107] It can be understood that, in the embodiment of the present application, the NTP service can be injected by an environment variable to determine the corresponding configuration data, or can be registered to a service discovery system to determine the corresponding configuration data, and the present application does not make specific limitation.
[0108] For example, in Docker or Kubernetes, the configuration data of the NTP service can be obtained through an environment variable, and then the address identifier of the network time protocol service is obtained; or the corresponding configuration data can be identified by registering with the service discovery system, and then the address identifier of the network time protocol service is obtained.
[0109] It should be noted that the embodiment of the present application also provides a physical network verification service, which aims to verify whether the entire system can provide services to the clients on the physical network. The main content is: first, set a static Internet Protocol address in the same network segment as the DHCP and NTP services on the Linux client, and use the ping command to verify network connectivity: if the static Internet Protocol address can ping the target address, set the static Internet Protocol address to DHCP acquisition, and observe whether the dynamic Internet Protocol address can be acquired, if the dynamic Internet Protocol address can be acquired, use the dynamic Internet Protocol address to ping the DHCP and NTP services, and observe whether it can be pinged, if it can be pinged, use the packet capture tool to check whether the NTP information is contained in the DHCP information, if the NTP information is contained in the DHCP information, set the NTP information obtained by the client as the NTP service address, start time synchronization, and observe whether the time has been synchronized, which can systematically ensure the reliability of the whole process from the client entering the network to the business use in the physical network, and provide a stable time reference and network service basis for the production environment. The ping command is a network diagnostic tool used to test the connectivity between two hosts in the network.
[0110] The embodiment of the present application identifies the configuration data of the network time protocol service to obtain the address identifier, directly analyzes the configuration data to obtain the address, avoids manual configuration errors, responds to configuration changes in real time, realizes automatic adaptation, supports dynamic environment, can cover complex scenarios, directly analyzes the local configuration data to obtain the address identifier, avoids external dependence, reduces system complexity and fault points, improves system independence, simplifies operation and maintenance operations, and prevents address leakage.
[0111] The working principle of the network time protocol service publishing method proposed in the embodiment of the present application will be introduced below in combination with a specific embodiment.
[0112] Embodiment one:
[0113] The embodiment of the present application constructs multiple NTP service containers (i.e. first containers) in combination with virtual machines, Podman, and MAC address virtualization networks, and constructs a DHCP container (i.e. a second container), each NTP container needs to be directly accessed by the physical network, and the NTP information is published out using the DHCP container, the main content is as shown in Figure 2 The following content is included:
[0114] Step S201: preparing a virtual machine.
[0115] In the embodiments of the present application, the build environment data is ensured to meet certain environment conditions, such as operating system version, dependent library, network driver mode, etc., which are not limited in the present application.
[0116] Step S202: installing dependent software.
[0117] In the embodiments of the present application, Podman, Chrony (NTP service) and Internet Systems Consortium Dynamic Host Configuration Protocol server can be installed on the virtual machine.
[0118] Step S203: creating a MAC address virtualization network.
[0119] In the embodiments of the present application, the MAC address virtualization network can be configured to allow the container to communicate with the external physical network.
[0120] Step S204: building an NTP image.
[0121] In the embodiments of the present application, a Docker image can be created based on chronyd to provide NTP service, i.e., a first image is obtained.
[0122] Step S205: building a DHCP image.
[0123] In the embodiments of the present application, a Docker image containing dhcpd can be created to allocate Internet Protocol addresses, and a second image is obtained.
[0124] Step S206: starting an NTP container.
[0125] In the embodiments of the present application, multiple NTP containers can be run, each of which is configured with a static Internet Protocol address (for example, 192.168.1.101~102, which is not limited in the present application).
[0126] Step S207: starting a DHCP container.
[0127] In the embodiments of the present application, the DHCP container can be run, and a fixed Internet Protocol address (for example, 192.168.1.100, which is not limited in the present application) is set.
[0128] Step S208: updating the DHCP configuration file.
[0129] In the embodiments of the present application, the dhcpd.conf file can be edited to add the ntp-servers option.
[0130] Step S209: Restarting the DHCP container.
[0131] In the embodiments of the present application, the new configuration can be implemented by starting the DHCP container.
[0132] Step S210: Obtaining the NTP service.
[0133] In the embodiments of the present application, the client can obtain the Internet protocol address of the client and the Internet protocol address of the NTP service through the Podman, the MAC address virtualization network and the DHCP service.
[0134] Step S211: Synchronizing the time.
[0135] In the embodiments of the present application, the client can synchronize the time by using the Internet protocol address of the NTP service obtained from the DHCP service.
[0136] Through the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be realized by means of software and the necessary general hardware platform, of course, it can also be realized by hardware, but in many cases the former is a better embodiment.
[0137] According to the network time protocol service publishing method provided by the embodiments of the present application, the corresponding first image and the second image for configuring the network time protocol service can be constructed according to the service characteristics of the network time protocol service, and the first image and the second image are loaded into the corresponding containers respectively to construct the first container and the second container. By writing the obtained address identifier of the network time protocol service into the configuration data of the second container, the corresponding network time protocol service is published according to the configuration data, so that the technical problems in the related art can be solved, such as when multiple virtual machines are running on the same physical host, each virtual machine needs certain system resources, which may cause performance degradation and network delay due to system resource competition. In addition, logical isolation or access control is needed between virtual machines to prevent cross-attack or resource exhaustion between virtual machines, resulting in poor compatibility, difficulty in driving adaptation and cross-platform management, etc. The technical effects of decoupling services and configurations, improving architecture flexibility, enhancing operation and maintenance automation, improving system security, greatly reducing system resource consumption under the premise of ensuring functional integrity, and being suitable for resource-constrained or high-performance network service scenarios are achieved.
[0138] The embodiments of the present application also provide a network time protocol service publishing device.
[0139] Figure 3 A block diagram of the network time protocol service publishing device provided by the embodiments of the present application is shown.
[0140] AsFigure 3 As shown, the network time protocol service publishing device 10 comprises a first construction module 100, a second construction module 200 and a publishing module 300.
[0141] The first construction module 100 is configured to construct a first image for providing the network time protocol service and a second image for configuring the network time protocol service based on at least one service feature of the network time protocol service.
[0142] The second construction module 200 is configured to load the first image and the second image into containers corresponding to the first image and the second image respectively to construct a first container and a second container.
[0143] The publishing module 300 is configured to obtain an address identifier of the network time protocol service in the first container and write the address identifier into configuration data of the second container, so as to obtain the address identifier according to the configuration data and publish the corresponding network time protocol service according to the address identifier.
[0144] Optionally, in an embodiment of the present application, the network time protocol service publishing device 10 further comprises an obtaining module, a first judging module, a third construction module and a fourth construction module.
[0145] The obtaining module is configured to obtain construction environment data of the first image and the second image before the first image and the second image are constructed.
[0146] The first judging module is configured to judge whether the construction environment data satisfies a preset environment condition.
[0147] The third construction module is configured to adjust at least one environment parameter in the construction environment data based on the first image and the second image when the construction environment data does not satisfy the preset environment condition, until the construction environment data satisfying the preset environment condition is obtained, so as to allow the first image and the second image to be constructed.
[0148] The fourth construction module is configured to allow the first image and the second image to be constructed when the construction environment data satisfies the preset environment condition.
[0149] Optionally, in an embodiment of the present application, the obtaining module comprises a first obtaining unit, a second obtaining unit and a first generating unit.
[0150] The first obtaining unit is configured to obtain first basic dependent environment data, first construction tool chain data, first configuration parameter data and first environment variable data of the first image.
[0151] The second obtaining unit is configured to obtain second basic dependent environment data, second construction tool chain data, second configuration parameter data and second environment variable data of the second image.
[0152] The first generating unit is configured to obtain the build environment data based on the first basic dependent environment data, the first build tool chain data, the first configuration parameter data, the first environment variable data, the second basic dependent environment data, the second build tool chain data, the second configuration parameter data, and the second environment variable data.
[0153] Optionally, in an embodiment of the present application, the first build module 100 comprises a selection unit, a first build unit, and a second build unit.
[0154] The selection unit is configured to select a network drive mode suitable for communication with the client based on the build environment data.
[0155] The first build unit is configured to determine first image parameters corresponding to the network time protocol service based on the network drive mode, so as to build a first image according to the first image parameters.
[0156] The second build unit is configured to determine second image parameters corresponding to the network time protocol service based on the network drive mode, so as to build a second image according to the second image parameters.
[0157] Optionally, in an embodiment of the present application, the publishing module 300 comprises a first determination unit, a second determination unit, and a writing unit.
[0158] The first determination unit is configured to determine a communication mode between the first container and the second container based on a communication mechanism feature between the first container and the second container in the network drive mode.
[0159] The second determination unit is configured to determine an address allocation mode of writing the address identifier into the second container based on the communication mode.
[0160] The writing unit is configured to write the configuration data based on the address allocation mode.
[0161] Optionally, in an embodiment of the present application, the publishing module 300 comprises a starting unit, a response unit, and a publishing unit.
[0162] The starting unit is configured to start the second container to obtain a corresponding address identifier.
[0163] The response unit is configured to respond to a service request of the corresponding network time protocol service.
[0164] The publishing unit is configured to publish the corresponding network time protocol service based on the service request and the corresponding address identifier.
[0165] Optionally, in an embodiment of the present application, the second construction module 200 comprises: a third acquisition unit, a third determination unit, a third construction unit and a fourth construction unit.
[0166] The third acquisition unit is configured to acquire target host data of the first container and the second container.
[0167] The third determination unit is configured to determine first resource data and first network data of the first container and second resource data and second network data of the second container based on the target host data.
[0168] The third construction unit is configured to load the first image into the container corresponding to the first image based on the first resource data and the first network data, so as to construct the first container.
[0169] The fourth construction unit is configured to load the second image into the container corresponding to the second image based on the second resource data and the second network data, so as to construct the second container.
[0170] Optionally, in an embodiment of the present application, the method further comprises: a establishing module, a second judging module, a first determining module and a second determining module.
[0171] The establishing module is configured to establish a health detection instruction applicable to the first container and the second container based on the first container and the second container after the first container and the second container are constructed.
[0172] The second judging module is configured to judge whether the first container and the second container meet a preset health detection target based on the health detection instruction.
[0173] The first determining module is configured to acquire a first health detection result of the first container when the first container does not meet the preset health detection target, so as to determine a first health adjustment instruction for the first container to meet the preset health detection target according to the first health detection result.
[0174] The second determining module is configured to acquire a second health detection result of the second container when the second container does not meet the preset health detection target, so as to determine a second health adjustment instruction for the second container to meet the preset health detection target according to the second health detection result.
[0175] Optionally, in an embodiment of the present application, the first acquisition module comprises: a fourth acquisition unit, a verification unit, a first matching unit and a second matching unit.
[0176] The fourth acquisition unit is configured to acquire image hash values of the first image, the second image and the corresponding target image respectively.
[0177] The verification unit is configured to verify whether the first image and the second image respectively match the corresponding target image based on the image hash value.
[0178] The first matching unit is configured to adjust at least one image parameter in the first image based on the corresponding target image until the first image matches the corresponding target image when the first image does not match the corresponding target image.
[0179] The second matching unit is configured to adjust at least one image parameter in the second image based on the corresponding target image until the second image matches the corresponding target image when the second image does not match the corresponding target image.
[0180] The features of the embodiments of the network time protocol service publishing device can be referred to the related descriptions of the embodiments of the network time protocol service publishing method, which will not be repeated here.
[0181] The network time protocol service publishing device provided by the embodiments of the present application can construct the corresponding first image and the second image for configuring the network time protocol service according to the service features of the network time protocol service, and load the first image and the second image into the corresponding containers to construct the first container and the second container. By writing the address identifier of the obtained network time protocol service into the configuration data of the second container, the corresponding network time protocol service is published according to the configuration data, so that the technical problems in the related art can be solved, such as the performance degradation and network delay caused by system resource competition when multiple virtual machines run on the same physical host, in addition, logical isolation or access control is needed between virtual machines to prevent cross-attack or resource exhaustion between virtual machines, resulting in poor compatibility, difficulty in driving adaptation and cross-platform management, and the like. The technical effects of decoupling service and configuration, improving architecture flexibility, enhancing operation and maintenance automation, improving system security, greatly reducing system resource consumption under the premise of ensuring functional integrity, and being suitable for resource-constrained or high-performance network service scenarios are achieved.
[0182] The embodiments of the present application also provide an electronic device, comprising a memory and a processor, the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any of the network time protocol service publishing method embodiments.
[0183] The embodiments of the present application also provide a computer readable storage medium, which stores a computer program, wherein the computer program is configured to execute the steps in any of the network time protocol service publishing method embodiments when running.
[0184] In an example embodiment, the computer readable storage medium described above can include, but is not limited to, a U disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and various media that can store computer programs.
[0185] Embodiments of the present application also provide a computer program product, which comprises a computer program, and the computer program, when executed by a processor, implements the steps in any of the network time protocol service publishing method embodiments described above.
[0186] Embodiments of the present application also provide another computer program product, which comprises a non-volatile computer readable storage medium, and the non-volatile computer readable storage medium stores a computer program, and the computer program, when executed by a processor, implements the steps in any of the network time protocol service publishing method embodiments described above.
[0187] The skilled in the art can further realize that the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein can be realized in electronic hardware, computer software or a combination of both. In order to clearly illustrate the interchangeability of hardware and software, the components and steps of the examples have been described in the above description in general terms. Whether the functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. The skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.
[0188] The above describes in detail a network time protocol service publishing method provided by the present application. The principles and implementation modes of the present application are described by applying specific examples in this paper, and the above example descriptions are only used to help understand the method of the present application and its core idea. It should be pointed out that, for those skilled in the art, without departing from the principles of the present application, some improvements and modifications can be made to the present application, and these improvements and modifications also fall within the protection scope of the claims of the present application.
Claims
1. A method for publishing a Network Time Protocol (NTP) service, characterized in that, Includes the following steps: Based on at least one service feature of the Network Time Protocol (NTP) service, a first image for providing the NTP service and a second image for configuring the NTP service are constructed. The first image and the second image are loaded into containers corresponding to the first image and the second image, respectively, to construct the first container and the second container; Obtain the address identifier of the Network Time Protocol (NTP) service in the first container, and write the address identifier into the configuration data of the second container, so as to obtain the address identifier according to the configuration data and publish the corresponding NTP service according to the address identifier; After constructing the first and second containers, the process also includes: Based on the first container and the second container, establish health detection instructions applicable to the first container and the second container respectively; Based on the health detection instructions, determine whether the first container and the second container meet the preset health detection targets; If the first container does not meet the preset health detection target, then the first health detection result of the first container is obtained, so as to determine the first health adjustment instruction that the first container meets the preset health detection target based on the first health detection result; If the second container does not meet the preset health detection target, then the second health detection result of the second container is obtained, so as to determine the second health adjustment instruction that the second container meets the preset health detection target based on the second health detection result; The construction of a first image for providing the Network Time Protocol (NTP) service and a second image for configuring the NTP service includes: Obtain the image hash values of the first image, the second image, and the corresponding target image, respectively; Based on the image hash value, verify whether the first image and the second image match the corresponding target image; If the first image does not match the corresponding target image, then at least one image parameter in the first image is adjusted based on the corresponding target image until a first image that matches the corresponding target image is obtained; If the second image does not match the corresponding target image, then at least one image parameter in the second image is adjusted based on the corresponding target image until a second image that matches the corresponding target image is obtained; The step of writing the address identifier into the configuration data of the second container includes: Based on the communication mechanism characteristics between the first container and the second container in the network-driven mode of communicating with the client, the communication method between the first container and the second container is determined. Based on the communication method, determine the address allocation method for writing the address identifier into the second container; Based on the address allocation method, the configuration data is written.
2. The method according to claim 1, characterized in that, Before constructing the first image for providing the Network Time Protocol (NTP) service and the second image for configuring the NTP service, the following steps are also included: Obtain the build environment data for the first image and the second image; Determine whether the constructed environment data meets the preset environment conditions; If the build environment data does not meet the preset environment conditions, then based on the first image and the second image, at least one environment parameter in the build environment data is adjusted until build environment data that meets the preset environment conditions is obtained, so as to allow the build of the first image and the second image; If the construction environment data meets the preset environment conditions, then the construction of the first image and the second image is allowed.
3. The method according to claim 2, characterized in that, The step of obtaining the build environment data for the first image and the second image includes: Obtain the first basic dependency environment data, the first build toolchain data, the first configuration parameter data, and the first environment variable data of the first image; Obtain the second base dependency environment data, the second build toolchain data, the second configuration parameter data, and the second environment variable data of the second image; The build environment data is obtained based on the first basic dependency environment data, the first build toolchain data, the first configuration parameter data, the first environment variable data, the second basic dependency environment data, the second build toolchain data, the second configuration parameter data, and the second environment variable data.
4. The method according to claim 2, characterized in that, The construction of a first image for providing the Network Time Protocol (NTP) service and a second image for configuring the NTP service includes: Based on the aforementioned construction environment data, select a network driver mode suitable for communication with the client; Based on the network driving mode, the first image parameters corresponding to the network time protocol service are determined, so as to construct the first image according to the first image parameters; Based on the network-driven mode, the corresponding second image parameters for configuring the network time protocol service are determined, so as to construct the second image according to the second image parameters.
5. The method according to claim 1, characterized in that, The step of publishing the corresponding Network Time Protocol (NTP) service based on the address identifier includes: Start the second container to obtain the corresponding address identifier; Respond to service requests for the corresponding Network Time Protocol service; Based on the service request and the corresponding address identifier, the corresponding Network Time Protocol (NTP) service is published.
6. The method according to claim 1, characterized in that, The step of loading the first image and the second image into containers corresponding to the first image and the second image, respectively, to construct the first container and the second container, includes: Obtain the target host data for the first container and the second container; Based on the target host data, the first resource data and the first network data of the first container, and the second resource data and the second network data of the second container are determined respectively. Based on the first resource data and the first network data, the first image is loaded into the container corresponding to the first image to construct the first container; Based on the second resource data and the second network data, the second image is loaded into the container corresponding to the second image to construct the second container.
7. An electronic device, characterized in that, include: A memory, a processor, and a computer program stored in the memory and executable on the processor, the processor executing the program to implement the method for publishing a Network Time Protocol service as described in any one of claims 1-6.