k8s_process_manager
drunc.process_manager.k8s_process_manager
Classes
K8sPodWatcherThread(pm)
Bases: Thread
Initialize the pod watcher thread that monitors and notifies on pod events.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pm
|
The K8sProcessManager instance to watch. |
required |
Source code in drunc/process_manager/k8s_process_manager.py
Functions
run()
Run the pod watcher loop.
Continuously watches for Kubernetes pod events across all namespaces managed by the process manager. Detects terminal pod states (Succeeded, Failed, or Deleted) and notifies the process manager of terminations. Automatically restarts the watch stream on API errors or disconnections.
Source code in drunc/process_manager/k8s_process_manager.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |
K8sProcessManager(configuration, **kwargs)
Bases: ProcessManager
Manages processes as Kubernetes Pods. This ProcessManager interfaces with the Kubernetes API to start, stop, and monitor applications running in Pods.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
configuration
|
ProcessManagerConfHandler
|
The process manager configuration object containing image, settings (labels, service, pod_management, volumes, cleanup, checking), and other runtime parameters. |
required |
**kwargs
|
Additional keyword arguments passed to the parent ProcessManager. |
{}
|
Raises:
| Type | Description |
|---|---|
ConfigException
|
If the Kubernetes configuration cannot be loaded. |
Source code in drunc/process_manager/k8s_process_manager.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | |
Functions
__boot(boot_request, uuid)
Internal boot method for creating a pod and waiting for critical services.
Orchestrates the full boot sequence: determines tree labels and roles, runs pre-boot validation, prepares the namespace, stores the boot request, creates the pod and its service, adds the UUID label, and performs blocking readiness waits for the LCS or root controller if applicable.
Returns:
| Type | Description |
|---|---|
ProcessInstance
|
process_instance - a ProcessInstance protobuf with RUNNING status |
Source code in drunc/process_manager/k8s_process_manager.py
is_alive(podname, session)
Checks if a pod is currently in the 'Running' phase.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
podname
|
str
|
The name of the pod to check. |
required |
session
|
str
|
The Kubernetes namespace (session) containing the pod. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the pod exists and its phase is 'Running', False otherwise. |
Source code in drunc/process_manager/k8s_process_manager.py
notify_termination(proc_uuid, exit_code, reason, session)
Callback for when a pod terminates.
Updates the final exit code, broadcasts a status update, and signals the termination_complete_event when all pending deletions are confirmed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proc_uuid
|
str
|
The UUID string of the terminated process. |
required |
exit_code
|
int
|
The integer exit code of the terminated pod. |
required |
reason
|
str
|
A string describing the termination reason (e.g. 'GracefulShutdown', 'PodDeleted'). |
required |
session
|
str
|
The Kubernetes namespace (session) the pod belonged to. |
required |