I worked for a large company with several hundred cron jobs running on two systems. Managing these jobs was cumbersome. Resource use during peak times brought things to a halt. Imagine what it was like when systems were down! In this talk, we discuss Kubernetes' killer feature: Cron Jobs.
Kubernetes, Jobs, and Cron Jobs
- What is Kubernetes?
- Kubernetes has the concept of Jobs
- Kubernetes Cron Jobs are a relatively new thing
- Former employer had several hundred cron jobs running on two systems
- Resource contention during peak times brought the systems to a halt
- If one cron job didn’t run it was hard to determine what task failed or didn’t run based on user tickets
- Chaos if the systems were offline for one reason or another
Using minikube and Docker running locally…
The Docker Bits
- Example: The cron job that automates my newsletter publishing
- Demonstrate simplicity of Dockerfile creation
- docker build -t devopsish-netlify-cron .
- Using Google Container Registry (GCR) to distribute Docker images
The Kubernetes Bits
- Configure Kubernetes to pull images from GCR
- Demonstrate creating Kubernetes secrets
- Demonstrate Kubernetes Cron Job Configuration
- kubectl apply -f devopsish-netlify-cronjob.yml
- kubectl get cronjob
- Watch a job/pod run!
We have built a Docker container, deployed the image to Google Container Registry, configured the Kubernetes cluster to pull images from GCR, created a secret to store the build hook, and created the CronJob. Imagine the possibilities of having all cron jobs in version control, the distribution of jobs so they can run in better parts of a cluster, etc.