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
Methods:
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
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 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
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
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 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | |
Methods:
__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, 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
2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 | |
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, and signals the waiting kill_and_wait() batch (if any) once every uuid in it is 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 |