Operator for CronJob resources
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
Vladimir Smagin 8b74051da2 Изменить 'README.md' 1 mês atrás
build bootstrap operator 1 mês atrás
cmd/manager bootstrap operator 1 mês atrás
deploy security context, node selections and resources limiting 1 mês atrás
pkg security context, node selections and resources limiting 1 mês atrás
version security context, node selections and resources limiting 1 mês atrás
.gitignore create cronjobs 1 mês atrás
Dockerfile bootstrap operator 1 mês atrás
Makefile create cronjobs 1 mês atrás
README.md Изменить 'README.md' 1 mês atrás
VERSION security context, node selections and resources limiting 1 mês atrás
go.mod security context, node selections and resources limiting 1 mês atrás
go.sum envConfigmap, restartPolicy, backoffLimit, concurrencyPolicy, history limits 1 mês atrás
logo.png add logo 1 mês atrás
tools.go bootstrap operator 1 mês atrás

README.md

Cron operator for Kubernetes

Manages multiple CronJobs with same image, but different commands and workdirs. Supports mounting of persistent volume to save results somewhere, ENV variables configmaps, concurrency and restart policy.

Build sources

Prebuilt images

You can find images here https://hub.docker.com/r/iam21h/cron-operator. Pin version number in operator.yaml if you do not want automaticaly get new features and bugs.

Deploy operator

Cluster scoped installation:

kubectl -f deploy/crds/blindage_v1alpha1_cronop_crd.yaml
kubectl -f deploy/clusterrole.yaml
kubectl -f deploy/clusterrole_binding.yaml # service account namespace here
kubectl -n default -f deploy/service_account.yaml
kubectl -n default -f deploy/operator.yaml

Change operator.yaml if you want operator watch only specified namespace. Check deploy directory, may be you want to use Role instead of ClusterRole.

Settings

In your CronOp resource you can set image, parameters and tasks. CronJobs is a result of reconciling tasks section, some parameters can be global and overrided in each task. Remember, CronJob, Pod and Job is a different things.

This parameters can be set in global section or each task:

  • Set Configmap with ENV variables
    envConfigmap: default empty

  • How to restart Pod
    restartPolicy: OnFailure | Never | Always

  • Limit Job restarts
    backoffLimit: 0 | integer

  • Allow Cronjob to run concurrent Jobs
    concurrencyPolicy: Allow | Forbid | Replace

  • Set standard kubernetes Pod security context podSecurityContext: default empty

Global history limits:

  • successfulJobsHistoryLimit: 3 | integer
  • failedJobsHistoryLimit: 3 | integer

Also you can save intermediate results in mounted persistent volume. You can set PVC name with PersistentVolumeName, mount point with PersistentVolumePath and PersistentVolumeSubPath. It’s easy.

Global affinity, node selection and tolerations, have standard kubernetes specs:

  • nodeSelector: default empty
  • affinity: default empty
  • tolerations: default empty

Global resource limiting also kubernetes standard, but separated:

  • podRequests: default empty
  • podLimits: default empty

Look into pkg/apis/blindage/v1alpha1/cronop_types.go for your CustomResource syntax.

Your first CronOp deployment

Good sample you can find in deploy/test-cron.yaml, see it in case of questions.

This resource can help you run your first tasks:

---
apiVersion: blindage.org/v1alpha1
kind: CronOp
metadata:
  name: mycron
spec:
  image: "python:3"
  tasks:
  - name: print-test
    commands: ['python','-c', 'print("doing nothing")']
    schedule: "* * * * *"

If you delete this resource operator will delete CronJobs and Jobs.


Copyright by Vladimir Smagin (21h) 2019
http://blindage.org email: 21h@blindage.org
Project page: https://git.blindage.org/21h/cron-operator