A method to restart Kubernetes Pod

By inserting the management container Sidecar in the Kubernetes Pod, calling the CRI interface to restart the application container, solve the problem of restarting POD time and changing IP address in existing technology, and achieve a fast and stable POD restart.

CN113986371BActive Publication Date: 2025-01-28SHANDONG LANGCHAO YUNTOU INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111167940.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-30
Publication Date
2025-01-28
Estimated Expiration
2041-09-30

AI Technical Summary

Technical Problem

The prior art has a long time to restart Kubernetes Pod in container instance products and the Pod IP address changes, which cannot meet the needs of container instance products.

Method used

By inserting the management container SIDECAR in the POD, using Sidecar to call the CRI interface to restart the application container in the POD, to realize the rapid restart and keep the POD IP address unchanged.

Benefits of technology

The speed of restarting POD has been improved, the problem of changes in restarting time and changes in IP address is solved, and the needs of container instance products are met.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113986371B_ABST
    Figure CN113986371B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for restarting a Kubernetes Pod, and relates to the technical field of Kubernetes. Its implementation involves three components: an application manager Manager, a WebHook plug-in Injector, and a management container Sidecar, wherein: the application manager Manager is responsible for accepting a request to restart the Pod, and sending it to the management container Sidecar; the WebHook plug-in Injector is responsible for monitoring the Kubernetes API, and when monitoring a request to create a Pod, inserting the management container Sidecar into the Pod; the management container Sidecar receives the request of the application manager Manager in real time, and calls a CRI interface to restart the application container in the Pod. The present invention solves the problem of a long time consuming restart of the Pod and the change of the IP address in the container instance product.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of Kubernetes, and in particular to a method for restarting a Kubernetes Pod. Background Art

[0002] Kubernetes is a container orchestration technology solution that can provide a series of functions for container applications, such as deployment and operation, resource scheduling, service discovery, and dynamic scaling.

[0003] Container instances are services provided in containers, Pod as a Service, which has advantages over traditional Kubernetes applications, such as fast startup and resource saving. Therefore, using Kubernetes' excellent container orchestration capabilities to implement container instance products is the only choice in the industry.

[0004] However, Kubernetes manages the lifecycle of Pods by managing components (Deployment, Daemonset, Statefulset, etc.), including creation, deletion, and update, but does not provide a restart API. Usually, the purpose of restarting Pods is achieved through the elastic scaling function of components, that is, the Pod is first deleted and then rebuilt indirectly. However, this method has problems such as long time consumption and changes in the IP address of the rebuilt Pod, which is unacceptable for scenarios such as container instance products. Summary of the invention

[0005] In view of the needs and shortcomings of current technological development, the present invention provides a method for restarting a Kubernetes Pod to solve the problems of long restarting of a Pod and changes in the IP address in a container instance product.

[0006] A method for restarting a Kubernetes Pod of the present invention solves the above technical problems by adopting the following technical solutions:

[0007] A method for restarting a Kubernetes Pod, the implementation of which involves three components: application manager, WebHook plugin Injector, and management container Sidecar, where:

[0008] The application manager is responsible for accepting the request to restart the Pod and sending it to the management container Sidecar;

[0009] The WebHook plugin Injector is responsible for listening to the Kubernetes API and inserting the management container Sidecar into the Pod when it receives a request to create a Pod.

[0010] The management container Sidecar receives requests from the application manager Manager in real time and calls the CRI interface to restart the application container in the Pod.

[0011] Specifically, the application manager Manager involved is a Web management program that is deployed in the Kubernetes cluster as an application service and is responsible for managing the life cycle of the Pod, including four operations: create, delete, update, and restart.

[0012] More specifically, after the application manager receives the request to restart the Pod, it directly sends the request to the management container Sidecar of the Pod without calling the Kubernetes API interface to change the number of Replicas of the component.

[0013] Specifically, the Kubernetes involved contains two admission controllers: MutatingAdmissionWebhook and ValidatingAdmissionWebhook. MutatingAdmissionWebhook is responsible for modifying objects and rejecting requests, while ValidatingAdmissionWebhook is only responsible for rejecting requests, and all mutation actions occur before validation actions.

[0014] The WebHook plugin Injector is an implementation of the MutatingAdmissionWebhook interface. When the WebHook plugin Injector listens to a request to create a Pod, it inserts the management container Sidecar into the Pod.

[0015] More specifically, the WebHook plug-in Injector involved is a Web service that can be deployed in a Kubernetes cluster or in an external network, as long as the WebHook plug-in Injector is reachable to the Kubernetes cluster network.

[0016] Specifically, the management container Sidecar is inserted into the Pod by the WebHook plug-in Injector in the "sidecar mode";

[0017] The management container Sidecar monitors the status of the application container in the Pod in real time, listens to requests from the application manager, and takes corresponding actions based on the requests.

[0018] More specifically, the management container Sidecar queries the ID information of all application containers in the Pod through the Kubernetes API.

[0019] More specifically, the management container Sidecar mounts the socket file through environment variables.

[0020] More specifically, the management container Sidecar restarts the application container in the Pod by calling the CRI interface.

[0021] A method for restarting a Kubernetes Pod of the present invention has the following beneficial effects compared with the prior art:

[0022] (1) The present invention does not require the introduction of third-party components. By inserting a management container Sidecar into the Pod, the management container Sidecar calls the CRI interface to restart the Pod's application container, thereby improving the speed of restarting the Pod and solving the problem of long restart time and IP address change in the container instance product.

[0023] (2) The present invention is simple to implement, has reliable performance, and can be independently modularized, making it convenient to modify and transplant existing systems. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Attached Figure 1 It is a schematic flow chart of the method of the present invention. DETAILED DESCRIPTION

[0025] In order to make the technical solution, the technical problem solved and the technical effect of the present invention more clearly understood, the technical solution of the present invention is clearly and completely described below in conjunction with specific embodiments.

[0026] Embodiment 1:

[0027] Combined with Figure 1 This embodiment proposes a method for restarting a Kubernetes Pod, the implementation of which involves three components: an application manager Manager, a WebHook plug-in Injector, and a management container Sidecar.

[0028] The application manager is a web management program that is deployed in the Kubernetes cluster as an application service. It is responsible for managing the life cycle of the Pod, including four operations: create, delete, update, and restart. After receiving the request to restart the Pod, the application manager directly sends the request to the management container Sidecar of the Pod, without calling the Kubernetes API interface to change the number of Replicas of the component.

[0029] The WebHook plugin Injector is responsible for listening to the Kubernetes API and inserting the management container Sidecar into the Pod when it listens to a request to create a Pod. In this embodiment, the Kubernetes WebHook is an HTTP callback that can forward requests sent to the API Server to an external Web service and accept an admission control response parameter. Kubernetes contains two admission controllers: MutatingAdmissionWebhook and ValidatingAdmissionWebhook, where MutatingAdmissionWebhook is responsible for modifying objects and rejecting requests, and ValidatingAdmissionWebhook is only responsible for rejecting requests, and all Mutation actions occur before Validation actions. The WebHook plugin Injector is an implementation of the MutatingAdmissionWebhook interface. When the WebHook plugin Injector listens to a request to create a Pod, it inserts the management container Sidecar into the Pod. It should be added that the WebHook plugin Injector is a Web service that can be deployed in a Kubernetes cluster or in an external network, as long as the WebHook plugin Injector and the Kubernetes cluster network are reachable.

[0030] The management container Sidecar receives requests from the application manager in real time and calls the CRI interface to restart the application container in the Pod. Specifically, the management container Sidecar completes the following tasks:

[0031] (a) The “sidecar mode” is used to be inserted into the Pod by the WebHook plugin Injector;

[0032] (b) Monitor the status of application containers in the Pod in real time, listen to requests from the application manager, and take corresponding actions based on the requests;

[0033] (c) Query the ID information of all application containers in the Pod through the Kubernetes API;

[0034] (d) Mount the socket file through environment variables. Some of the configurations are as follows:

[0035]

[0036] (e) Restart the application container in the Pod by calling the CRI interface.

[0037] It should be added that the management container Sidecar exposes a service port, which cannot overlap with the application service port and supports configuration.

[0038] In summary, the method for restarting a Kubernetes Pod of the present invention solves the problem of a long time spent restarting a Pod and a change in the IP address in a container instance product without introducing a third-party component.

[0039] The above specific examples are used to explain the principles and implementation methods of the present invention in detail. These examples are only used to help understand the core technical content of the present invention. Based on the above specific embodiments of the present invention, any improvements and modifications made to the present invention by technicians in this technical field without departing from the principles of the present invention should fall within the scope of patent protection of the present invention.

Claims

1. A method for restarting a Kubernetes Pod, characterized in that: The Kubernetes of this method contains two admission controllers: MutatingAdmissionWebhook and ValidatingAdmissionWebhook. MutatingAdmissionWebhook is responsible for modifying objects and rejecting requests, while ValidatingAdmissionWebhook is only responsible for rejecting requests, and all mutation actions occur before validation actions. The WebHook plugin Injector is an implementation of the MutatingAdmissionWebhook interface. When the WebHook plugin Injector listens to a request to create a Pod, it inserts the management container Sidecar into the Pod. The implementation of the method involves three components: application manager, WebHook plugin injector, and management container sidecar, among which: The application manager is responsible for accepting the request to restart the Pod and sending it to the management container Sidecar; The WebHook plugin Injector is responsible for listening to the Kubernetes API and inserting the management container Sidecar into the Pod when it receives a request to create a Pod. The management container Sidecar receives requests from the application manager Manager in real time and calls the CRI interface to restart the application container in the Pod.

2. A method for restarting a Kubernetes Pod according to claim 1, characterized in that: The application manager Manager is a web management program that is deployed in the Kubernetes cluster as an application service and is responsible for managing the life cycle of the Pod, including four operations: create, delete, update, and restart.

3. A method for restarting a Kubernetes Pod according to claim 2, characterized in that: After receiving the request to restart the Pod, the application manager directly sends the request to the management container Sidecar of the Pod without calling the Kubernetes API interface to change the number of Replicas of the component.

4. A method for restarting a Kubernetes Pod according to claim 1, characterized in that: The WebHook plugin Injector is a web service that can be deployed in a Kubernetes cluster or in an external network, as long as the WebHook plugin Injector is reachable to the Kubernetes cluster network.

5. A method for restarting a Kubernetes Pod according to claim 1, characterized in that: The management container Sidecar adopts the "sidecar mode" and is inserted into the Pod by the WebHook plug-in Injector; The management container Sidecar monitors the status of the application container in the Pod in real time, listens to requests from the application management program Manager, and takes corresponding actions based on the requests.

6. A method for restarting a Kubernetes Pod according to claim 5, characterized in that: The management container Sidecar queries the ID information of all application containers in the Pod through the Kubernetes API.

7. A method for restarting a Kubernetes Pod according to claim 5, characterized in that: The management container Sidecar mounts the Socket file by means of environment variables.

8. A method for restarting a Kubernetes Pod according to claim 5, characterized in that: The management container Sidecar restarts the application container in the Pod by calling the CRI interface.

Citation Information

Patent Citations

  • Containerized management system

    CN107688322A

  • Kubernetes-based container resource dynamic adjustment method

    CN110287029A