Python SDK for the Cohestra control plane
Project description
cohestra-sdk
Python SDK for the Cohestra control plane — deploy, scale, rollback, and observe Apache Flink jobs on any Kubernetes cluster.
Install
pip install cohestra-sdk
# with Lambda extras:
pip install cohestra-sdk[lambda]
Quick start
from cohestra_sdk import CohestraClient, DeploymentSpec, ResourceShape
client = CohestraClient("https://cohestra.yourcluster.internal:8080", token="...")
# Register a deployment
client.register("prod", "streaming", "orders", owner="platform-team")
# Get a deployment handle
orders = client.deployment("prod", "streaming", "orders")
# Deploy a new version
orders.deploy(
DeploymentSpec(
image_digest="registry.example/orders@sha256:abc123",
parallelism=8,
max_parallelism=128,
resources=ResourceShape(task_manager_cpu=2, task_manager_memory_mib=4096,
task_manager_count=2, slots_per_manager=4),
flink_config={"state.backend.type": "rocksdb"},
),
requester="ci-pipeline",
approved=True,
)
# Wait for healthy
orders.wait_healthy(timeout=300)
# Check status
print(orders.status())
Operations
orders.scale(16, approved=True, reason="traffic spike")
orders.savepoint()
orders.suspend(reason="maintenance window")
orders.resume()
orders.rollback(target_version=3, reason="regression in v4")
orders.enable_autoscaler()
orders.freeze_autoscaler()
Custom autoscaler
from cohestra_sdk import CohestraClient, AutoscalerBase, ScaleDecision
class MyAutoscaler(AutoscalerBase):
def evaluate(self, status):
lag = status["currentVersion"]["healthSummary"]["kafkaLag"]
current = status["currentVersion"]["spec"]["parallelism"]
if lag > 100_000 and current < 32:
return ScaleDecision(current * 2, reason=f"lag={lag}")
return None
client = CohestraClient("http://localhost:8080")
scaler = MyAutoscaler(client, "prod", "streaming", "orders")
scaler.run_loop(interval=60)
See examples/kafka_lag_autoscaler.py for an AWS Lambda-ready implementation.
Cluster operations
client.freeze_cluster("prod", "streaming", reason="incident")
client.unfreeze_cluster("prod", "streaming")
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 Distribution
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 cohestra_sdk-0.1.1.tar.gz.
File metadata
- Download URL: cohestra_sdk-0.1.1.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8921259fb1cb2e2a7c5ac6c02c5b11cde54d772512c16bbb8aea35f008a91b73
|
|
| MD5 |
7b54943601c2a34f00cbcd79d3d5b400
|
|
| BLAKE2b-256 |
ad6231da0dcd9e5afb9069cb04d7484f2bae4f45aa2dc029bb4e4455cfdf3854
|
Provenance
The following attestation bundles were made for cohestra_sdk-0.1.1.tar.gz:
Publisher:
publish-pypi.yml on as791/Cohestra
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cohestra_sdk-0.1.1.tar.gz -
Subject digest:
8921259fb1cb2e2a7c5ac6c02c5b11cde54d772512c16bbb8aea35f008a91b73 - Sigstore transparency entry: 2006777565
- Sigstore integration time:
-
Permalink:
as791/Cohestra@606fdd05ae097aca8c9c613d7dcb27cb1a61baae -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/as791
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@606fdd05ae097aca8c9c613d7dcb27cb1a61baae -
Trigger Event:
push
-
Statement type:
File details
Details for the file cohestra_sdk-0.1.1-py3-none-any.whl.
File metadata
- Download URL: cohestra_sdk-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2be6a8dc6670e746f0a72c773c061abba7e35a6df4f9dda570c9402b3e9a857
|
|
| MD5 |
622815f9aa68d2ec020e764fb0c8148b
|
|
| BLAKE2b-256 |
8c592530923afb04fe0bf8feb770dbf6e3722411ebc49e71242f1650ad2adfd7
|
Provenance
The following attestation bundles were made for cohestra_sdk-0.1.1-py3-none-any.whl:
Publisher:
publish-pypi.yml on as791/Cohestra
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cohestra_sdk-0.1.1-py3-none-any.whl -
Subject digest:
f2be6a8dc6670e746f0a72c773c061abba7e35a6df4f9dda570c9402b3e9a857 - Sigstore transparency entry: 2006777650
- Sigstore integration time:
-
Permalink:
as791/Cohestra@606fdd05ae097aca8c9c613d7dcb27cb1a61baae -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/as791
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@606fdd05ae097aca8c9c613d7dcb27cb1a61baae -
Trigger Event:
push
-
Statement type: