Python SDK for QScaler - Kubernetes-native queue worker autoscaler
Project description
QScaler-SDK
Python SDK for integration with QScaler, a Kubernetes-native queue worker autoscaler.
OverviewOverview
QScaler-SDK enables efficient scaling of queue workers in a Kubernetes environment. It works by monitoring changes in the QWORKER_NAME Custom Resource Definition (CRD) managed by the QScaler controller.
Key Features
- Automatically detects changes in desired replica counts or pod specifications.
- Gracefully shuts down when necessary to ensure smooth scaling and resource optimization.
- Continuously loops to process tasks unless a change is detected.
How It Works
- Monitor Changes: The worker watches the
QWORKER_NAMECRD for updates. - Trigger Actions:
- If a change in the desired replica count or pod specification hash is detected:
- The worker removes its owner reference.
- Initiates a graceful shutdown process.
- If no changes are detected, the worker:
- Continues running indefinitely.
- Periodically checks for differences at intervals defined by
PULLING_INTERVAL.
- If a change in the desired replica count or pod specification hash is detected:
- Task Processing: During each loop, the worker processes tasks unless a termination condition is met.
Setup
To use QScaler-SDK, configure the following environment variables:
Environment Variables
| Variable | Description |
|---|---|
QWORKER_NAME |
Name of the QWorker CRD to monitor. |
PULLING_INTERVAL |
Interval (in seconds) for checking the QWorker CRD status when no tasks are running. |
POD_SPEC_HASH |
Hash of the current pod specification. Used to detect changes in the CRD and trigger shutdown. |
HOSTNAME |
Name of the pod, automatically set by Kubernetes. |
Example
A complete example is provided in the example folder, including the following files:
worker.py
qworker.yaml
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qscaler-0.0.1-py3-none-any.whl.
File metadata
- Download URL: qscaler-0.0.1-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.13.1 Linux/6.11.0-1015-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64cdf2bb8a852953753aef701399b958b221527278e741d2b443076f60c0156c
|
|
| MD5 |
743e7e9e4cac845647a64fd4771db8fc
|
|
| BLAKE2b-256 |
5d4ec0b4f252aef376d506ec063ed89d663b95f57170f3affb1fe0b365488d9e
|