Upgrade to Pro — share decks privately, control downloads, hide ads and more …

DevOpsDays Columbus 2018: Kubernetes Cron Jobs

Chris Short
September 19, 2018

DevOpsDays Columbus 2018: Kubernetes Cron Jobs

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 if systems were down! In this talk, we discuss Kubernetes’ killer feature: Cron Jobs.

Chris Short

September 19, 2018


  1. @ChrisShort devopsish.com 99999 Crons on the Wall 31 different daily

    newspapers Hundreds of cron jobs to run One RHEL 3 server running them The top of the hour was a nightmare sometimes No idea what broke when a cron failed
  2. @ChrisShort devopsish.com Kubernetes Kubernetes is an open-source system for automating

    deployment, scaling, and management of containerized applications. https://kubernetes.io
  3. Pods Pods are the smallest deployable units of computing that

    can be created and managed in Kubernetes. A Pod is a group of one or more containers (such as Docker containers) with shared storage/network and a specification for how to run the containers. https://kubernetes.io/docs/concepts/workloads/pods/pod/ @ChrisShort devopsish.com
  4. Jobs "A job creates one or more pods and ensures

    that a specified number of them successfully terminate. As pods successfully complete, the job tracks the successful completions. When a specified number of successful completions is reached, the job itself is complete." https://kubernetes.io/docs/concepts/workloads/controllers /jobs-run-to-completion/ @ChrisShort devopsish.com
  5. CronJob A Cron Job creates Jobs on a time-based schedule.

    One CronJob object is like one line of a crontab (cron table) file. It runs a job periodically on a given schedule, written in Cron format. https://kubernetes.io/docs/concepts/workloads/controllers /cron-jobs/ @ChrisShort devopsish.com
  6. Use Case My newsletter, DevOps’ish, is a static site generated

    with Hugo and run on Netlify I can write the newsletter set to a date in the future Hugo won't build page until date Netlify provides a build hook that will trigger builds when called. Calling the build hook URL via curl is a way to implement scheduled posts with Hugo on Netlify. @ChrisShort devopsish.com
  7. Conclusion Built a Docker container Pushed the image to a

    private registry Configured Kubernetes to use the private registry Created secret to store the build hook URL Created the CronJob
  8. References Everything but the secret The Children's Illustrated Guide to

    Kubernetes What is a Job? | Kubernetes CronJob | Kubernetes Secret | Kubernetes Kubernetes: Cron Jobs chrisshort/k8s-cron-job-demo Google Cloud Registry (GCR) with external Kubernetes