MandarJKulkarni / KubeCron

Create a kubernetes cron job to call a Python script

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

KubeCron

Create a kubernetes cron job to call a Python script

Prerequisites: Access to a Google Cloud project and Cloud Shell

Steps to follow:

Create a simple (or any) Python script which you want to call through the Kubernetes cron.
(It could be a micro-service as well)

Create dockerfile to create the image containing your Python script.

Build the docker image and push it to Google container registry
   docker build -t test-cron .
   docker tag test-cron gcr.io/gcp-project/test-cron
   docker push gcr.io/gcp-project/test-cron

Create a Kubernetes cron yaml to call the script at a specified interval

Login to the Google Cloud Console and set the project where you want to create cronjob.
   'gcloud config set project my-project'

Run 'kubectl apply -f test_cron.yaml' in the Google Cloud shell
        
To delete the cron you can run
   'kubectl delete cronjob test-cron'

About

Create a kubernetes cron job to call a Python script


Languages

Language:Dockerfile 82.2%Language:Python 17.8%