How to creates Kubernetes jobs with Python
In this blog post I will do a quick guide, with some code examples, on how to deploy a Kubernetes Job programmatically, using Python as the language of choice. For this I’m using GKE (Google Kubernetes Engine), logging via StackTrace and haveana image available on Google Container Registry. The architecture should be something like this: The code that I created:
- A Dockerfile for my container
- A Python App that has the code to run (this will be the Job)
- Commit the code to the GCP Source Code Repositories
- A CloudBuild trigger (docs: https://cloud.google.com/cloud-build/docs/) that creates the container
- Create a trigger (can be a CronJob) that runs the code that deploys the Job.
- For this exercise, I’m going to trigger the Job creation from my own laptop.
- Job object
- Contains a metadata object
- Contains a job spec object
- Contains a pod template object
- Contains a pod template spec object
- Contains a container object
- Contains a pod template spec object
- Contains a pod template object
Share this
Previous story
← How to run RHEL5/Centos5 in Google Cloud
You May Also Like
These Related Stories
GCP features wish list for Google Next 2018
GCP features wish list for Google Next 2018
Jul 20, 2018
2
min read
Creating dynamic tasks using Apache Airflow
Creating dynamic tasks using Apache Airflow
Apr 24, 2018
7
min read
Apache beam pipelines with Scala: part 1 - template
Apache beam pipelines with Scala: part 1 - template
Dec 12, 2017
3
min read
No Comments Yet
Let us know what you think