Kubernetes job scheduler for Python
Project description
k8s-job-scheduler
A package for managing Kubernetes jobs and cron jobs from Python. It allows running CLI scripts and Python functions within native Kubernetes job engine.
No need to package separate Docker images with functions to be executed - the package can remotely "inject" the Python function using dill
into publicly available Docker images.
Installation
pip install k8s-job-scheduler
Getting Started
from k8s_job_scheduler import JobManager
def add(a, b):
return a + b
manager = JobManager(docker_image="python:3.11.1-slim-bullseye")
job = manager.create_instant_python_job(add, 1, 2)
This example will create a Kubernetes job and run the function add
with arguments 1 and 2 inside Python Docker container.
Other Prerequisites
Executing Python functions withing Kubernetes containers
- Docker images should include Python interpreter and all the dependencies required to execute the function.
dill
package is used to send the execution function and it's arguments when Docker container is created.dill
is dynamically installed on job container execution start when job is created withcreate_instant_python_job
. You can usepip_packages
argument to add extra Python packages to be installed, or removedill
if you use docker image with preinstalleddill
.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
k8s_job_scheduler-0.2.2.tar.gz
(27.9 kB
view details)
Built Distribution
File details
Details for the file k8s_job_scheduler-0.2.2.tar.gz
.
File metadata
- Download URL: k8s_job_scheduler-0.2.2.tar.gz
- Upload date:
- Size: 27.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffd5de640d3284e563d1a92468d29268c322ac8efa1c8b7e46f243400cf955fa |
|
MD5 | 7f260e0e29f5342a910f6804390f3fd5 |
|
BLAKE2b-256 | ff99ab2a7d72fffd5adb449e91890e2f047765058c1d41aa3d75bce2716277a7 |
File details
Details for the file k8s_job_scheduler-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: k8s_job_scheduler-0.2.2-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b815c017d1fd466351a7f1a604242b4b5476579b793d18c21744bc2effa08801 |
|
MD5 | 79c1428d716fa23fd357af6dd951b908 |
|
BLAKE2b-256 | 0e9c94df9ff35e229c23526b9c37b3acc1456d4527a86aa2a3892435e7d51125 |