Skip to content

Python package for managing and scheduling Jobs in Kubernetes

License

Notifications You must be signed in to change notification settings

imubit/k8s-job-scheduler

Repository files navigation

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_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 with create_instant_python_job. You can use pip_packages argument to add extra Python packages to be installed, or remove dill if you use docker image with preinstalled dill.

About

Python package for managing and scheduling Jobs in Kubernetes

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages