Termination of sidecar containers
In various examples there is a method performed by a controller in Kubernetes cluster. The method comprises: identifying a job to be completed by the cluster, from a plurality of jobs. In response to identifying a job to be completed by the cluster, determining at least one sidecar container associated with the job. In response to identifying a job to be completed by the cluster, determining that the job has been completed by querying a Kubernetes control plane of the cluster. In response to determining that the job has been completed, triggering termination of the sidecar container.
1 . A method performed by a centralized controller in a Kubernetes cluster, the centralized controller executing in a container of the Kubernetes cluster that is separate from other containers in the Kubernetes cluster that are running jobs in the Kubernetes cluster, the centralized controller communicatively coupled to a Kubernetes control plane of the Kubernetes cluster, the method comprising:
identifying, by the centralized controller, a job to be completed by the Kubernetes cluster from a plurality of jobs running in containers in the Kubernetes cluster that are separate from the container in which the centralized controller is executing;
in response to identifying, by the centralized controller, the job to be completed by the Kubernetes cluster:
determining, by the centralized controller via the Kubernetes control plane, a sidecar container associated with the job; and
determining, by the centralized controller, that the job has been completed based on job completion status reported by the Kubernetes control plane independently of execution state of the sidecar container; and
in response to determining that the job has been completed while the sidecar container remains running, triggering, by the centralized controller, termination of the sidecar container to allow the Kubernetes cluster to recognize completion of the job.
2 . The method according to claim 1 , wherein the controller is running in a pod that is separate from any of the plurality of jobs.
3 . The method according to claim 1 , wherein the job and the sidecar container are running in the same pod.
4 . The method according to claim 1 , wherein determining the sidecar container associated with the job comprises using a list of sidecar containers or a label on the sidecar container.
5 . The method according to claim 1 , wherein the Kubernetes cluster is a virtualized network function (VNF) of a 5G or 6G telecommunications network.
6 . The method according to claim 1 , wherein determining the sidecar container associated with the job comprising using a portion of an identifier of the sidecar container.
7 . The method according to claim 1 , wherein determining the sidecar container associated with the job comprises using a portion of an environmental variable of the sidecar container.
8 . The method according to claim 1 , wherein the job is identified using a parameter provided to the controller.
9 . The method according to claim 1 , wherein the job is identified using a preconfigured label on the job.
10 . The method according to claim 1 , wherein the job is identified using a portion of an identifier of the job.
11 . The method according to claim 1 , wherein the job is identified using a portion of an environmental variable of the job.
12 . The method according to claim 1 , wherein the termination is achieved via the controller gracefully terminating the sidecar container by triggering graceful termination on the sidecar container.
13 . The method according to claim 12 , wherein the controller gracefully terminates the sidecar container by:
connecting to the sidecar container; and
running an operating system exit command to trigger the termination of the sidecar container.
14 . The method according to claim 12 , wherein the controller connects to the sidecar container via a network tunnel in order to terminate the sidecar container.
15 . The method according to claim 1 , wherein the controller terminates the sidecar container by using a Kubernetes API.
16 . The method according to claim 1 , wherein the controller terminates the sidecar container by performing a sequence of different termination methods, including at least one graceful method, and at least one non-graceful method.
17 . The method according to claim 10 , wherein the identifier of the job is accessed by:
determining a list of containers in the Kubernetes cluster,
removing, from the list, sidecar containers to form a resulting list, and
accessing identifiers of jobs on the resulting list.
18 . The method according to claim 1 , wherein the controller determines that the job has completed by:
connecting to a pod running on the Kubernetes cluster; and
determining any non-sidecar processes running in the pod.
19 . A system comprising a plurality of networked computers executing a Kubernetes cluster comprising:
a control plane;
a plurality of pods, at least one of the pods comprising a first container for implementing a job and a sidecar container of the job; and
a centralized controller, the centralized controller executing in a second container of the Kubernetes cluster that is separate from other containers in the Kubernetes cluster that are running jobs in the Kubernetes cluster, the centralized controller communicatively coupled to the control plane, the centralized controller configured to perform operations comprising:
accessing an identifier of a job to be completed by the Kubernetes cluster from a plurality of jobs;
determining that the job has been completed based on job completion status reported by the control plane independently of execution state of the sidecar container by;
determining, via the control plane, the sidecar container associated with the job; and
in response to determining, while the sidecar container remains running, that the job has been completed, triggering termination of the sidecar container to allow the Kubernetes cluster to recognize completion of the job.
20 . A computer-implemented method performed by a centralized controller container executing in a cluster of a 5G or 6G communications network comprising a plurality of computers, the cluster comprising a plurality of containers, wherein the cluster is separate from other containers in the cluster that are running jobs in the cluster, the centralized controller container communicatively coupled to a control plane of the cluster, the method comprising:
identifying, by the centralized controller container, a job to be completed by the cluster from a plurality of jobs;
in response to identifying the job to be completed by the cluster:
determining, by the centralized controller container via the control plane, a sidecar container in the cluster associated with the job; and
determining, by the centralized controller container, that the job has been completed based on job completion status reported by the control plane independently of execution state of the sidecar container; and
in response to determining, while the sidecar container remains running, that the job has been completed, triggering, by the centralized controller container, termination of the sidecar container to allow the cluster to recognize completion of the job.