Library documentation can be found here.
# From PyPI (preferred once published)
pip install kratix-sdk
# From the main branch
pip install git+https://github.com/syntasso/kratix-python.git
# Editable install for local development
pip install -e .import kratix_sdk as ks
import yaml
# Initialize the sdk
sdk = ks.KratixSDK()
resource = sdk.read_resource_input()
# Read from resource input
name = resource.get_value("spec.key")
# Write workload documents to OUTPUT_DIR
manifest = {
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {"name": name, "labels": {"app": name}},
"spec": {
"replicas": 1,
"selector": {"matchLabels": {"app": name}},
"template": {
"metadata": {"labels": {"app": name}},
"spec": {
"containers": [
{"name": name, "image": "busybox"}
]
},
},
},
}
data = yaml.safe_dump(manifest).encode("utf-8")
sdk.write_output("deployment.yaml", data)
# Publish status during workflow run
status = ks.Status()
status.set("phase", "updates-from-mid-stage")
sdk.publish_status(resource, status)
# Set status
status = ks.Status()
status.set("message", f"created deployment {key}")
sdk.write_status(status)
# Write destination selectors for dynamic scheduling
selectors: List[ks.DestinationSelector] = [
ks.DestinationSelector(match_labels={"environment": "test"})
]
sdk.write_destination_selectors(selectors)Library is under kratix_sdk. Examples of Promises using this library can be found under examples.
-
make installinstalls all dependencies -
make testruns all tests undertests/ -
make fmtcode formatting usingruff -
make lintlinting usingruff
See RELEASING.md for the tested release workflow when publishing to TestPyPI/PyPI.