Daemon Job CRD in K8s with CompositeController

Harsh Manvar
Google Cloud - Community
4 min readApr 4, 2023

--

Daemonjob in Kubernetes on each node

Overview

I recently came across a situation where we had to execute a Kubernetes task on each worker node. It would be challenging to complete the task using the typical Kubernetes Job or Cronjob, and Daemonset’s pods stay even after the work is finished.

This article will walk you through how to use the Metacontroller Composite Controller (API) to build a Custom Resource Definition (CRD) in Kubernetes.

Daemonjob in Kubernetes

Metacontroller

The Kubernetes add-on Metacontroller makes it simple to create and distribute custom controllers. The add-on operates the same in any Kubernetes cluster, it’s open-source initiative was initiated at Google.

CompositeController (API)

In this article, we will be using the composite controller. To help custom controllers handle a group of child objects based on the desired state defined in a parent object, Metacontroller provides the CompositeController API.

Using the Kubernetes Daemonset controller, we will attempt to extend behavior to jobs so that when we execute a job, childs get scheduled on all of the available nodes in the k8s cluster.

--

--