DaemonJob

command module
v0.0.0-...-894882a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

README

DaemonJob

Idea

This project is the response to problem that from time to time every Kubernetes developer come across - Resource that works like DaemonSet, but triggers Jobs instead.

Kubernetes from years hasn't resolved multiple issues submitions (like this one) so working on custom resource for contrail-operator I've came with an idea of kubernetes operator that implements custom resource DaemonJob.

Implementation

This is Kubernetes operator written in Go with support of operator-sdk so it managing pod running in target cluster as well as apply manifests with CRDs, RBAC etc.

Logic of DaemonJob is that all parameters are declared as for standard Job resource except for parrarel and completions fields which are filled based on number of applicable nodes (which you may control with for example nodeSelector). DaemonJob has Anti-affinity added so that on single node only one pod will be run. Having that connected together we achieve pretty much logic of DaemonSet.

The only disadvantage is restrictive policy of Job resource which does not allow to edit completions or parrarel fields on the go (or even a lot of pod spec values). Because of that with every such change DaemonJob has to delete and create new Job.

Deployment

This repository contains useful Makefile. In order to apply all required manifests onto cluster just run make install.

Afterwards, you'll need Pod with a manager running. You may create one with:

make deploy

NOTE: You may of course apply your own image (for example with edits necessary for your project). In that case just export IMG as your image (e.g. export IMG=dysproz/daemon-job).

And that's it. Now you may create your own manifests for DaemonJob and apply them to the cluster. Example manifest may be found under config/samples/dj_v1_daemonjob.yaml.

Builing your own image

In case you want to edit this code, build and then push your own image you may do that by:

  • exporting IMG variable `export IMG=[CONTAINER REPOSITORY]/[CONTAINER NAME]:[TAG]
  • building operator with make docker-build
  • pushing it to the registry (remember to first log in) make docker-push

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
api
v1
Package v1 contains API Schema definitions for the dj v1 API group +kubebuilder:object:generate=true +groupName=dj.dysproz.io
Package v1 contains API Schema definitions for the dj v1 API group +kubebuilder:object:generate=true +groupName=dj.dysproz.io

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL