Skip to main content

Kubernetes job scheduler for Python

Project description

Project generated with PyScaffold Coveralls PyPI-Server

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_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. If you wish to use standard Python Docker images or custom images which does not have dill package preinstalled, it is possible to specify dynamic_dill_install=True when calling create_instant_python_job. In this case dill will be dynamically installed before running the code.

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.1.1.tar.gz (27.4 kB view hashes)

Uploaded Source

Built Distribution

k8s_job_scheduler-0.1.1-py3-none-any.whl (9.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page