Giter Site home page Giter Site logo

helm-cronjobs's Introduction

helm-cronjobs

You can define an array of jobs in values.yaml helm will take care of creating all the CronJobs.

How to use as a starter chart

  1. Find your Helm data directory, HELM_DATA_HOME

    helm env
    
  2. cd to this directory, then

    mkdir starters
    cd starters
    
  3. Clone this repo

  4. In your cronjob project, set up your new chart with

    helm create -p helm-cronjobs your_chart_name
    

Configuration

Via values.yaml

Overview

jobs:
  jobname-1:
    # job definition
  jobname-2:
    # job definition
  jobname-n:
    # job definition

Details

jobs:
  ### REQUIRED ###
  <job_name>:
    image:
      repository: <image_repo>
      tag: <image_tag>
      imagePullPolicy: <pull_policy>
    schedule: "<cron_schedule>"
    failedJobsHistoryLimit: <failed_history_limit>
    successfulJobsHistoryLimit: <successful_history_limit>
    concurrencyPolicy: <concurrency_policy>
    restartPolicy: <restart_policy>
  ### OPTIONAL ###
    imagePullSecrets:
    - username: <user>
      password: <password>
      email: <email>
      registry: <registry>
    env:
    - name: ENV_VAR
      value: ENV_VALUE
    envFrom:
    - secretRef:
      name: <secret_name>
    - configMapRef:
      name: <configmap_name>
    command: ["<command>"]
    args:
    - "<arg_1>"
    - "<arg_2>"
    resources:
      limits:
        cpu: <cpu_count>
        memory: <memory_count>
      requests:
        cpu: <cpu_count>
        memory: <memory_count>
    serviceAccount:
      name: <account_name>
      annotations:  # Optional
        my-annotation-1: <value>
        my-annotation-2: <value>
    nodeSelector:
      key: <value>
    tolerations:
    - effect: NoSchedule
      operator: Exists
    volumes:
      - name: config-mount
        configMap:
          name: configmap-name
          items:
            - key: configuration.yml
              path: configuration.yml
    volumeMounts:
      - name: config-mount
        mountPath: /etc/config
    affinity:
      nodeAffinity:
        requiredDuringSchedulingIgnoredDuringExecution:
          nodeSelectorTerms:
          - matchExpressions:
            - key: kubernetes.io/e2e-az-name
              operator: In
              values:
              - e2e-az1
              - e2e-az2

Examples

$ helm install test-cron-job .
NAME:   cold-fly
LAST DEPLOYED: Fri Feb  1 15:29:21 2019
NAMESPACE: default
STATUS: DEPLOYED

RESOURCES:
==> v1/CronJob
NAME                    AGE
cold-fly-hello-world    1s
cold-fly-hello-ubuntu   1s
cold-fly-hello-env-var  1s

list cronjobs:

$ kubectl get cronjob
NAME                     SCHEDULE      SUSPEND   ACTIVE    LAST SCHEDULE   AGE
cold-fly-hello-env-var   * * * * *     False     0         23s             1m
cold-fly-hello-ubuntu    */5 * * * *   False     0         23s             1m
cold-fly-hello-world     * * * * *     False     0         23s             1m

list jobs:

$ kubectl get jobs
NAME                                DESIRED   SUCCESSFUL   AGE
cold-fly-hello-env-var-1549056600   1         1            45s
cold-fly-hello-ubuntu-1549056600    1         1            45s
cold-fly-hello-world-1549056600     1         1            45s

helm-cronjobs's People

Contributors

bambash avatar daemondude23 avatar enribd avatar fireflycons avatar kirrmann avatar knotking avatar lyz-code avatar pradhyu avatar zanhsieh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

helm-cronjobs's Issues

Deploy configmaps with the chart

Several cronjobs require a configuration file.

With the current chart, we need to deploy the configmap manually and use it in the chart.

It will be nice if the chart is able to create the configmap from a list of files.

I have no experience with chart development, but if you agree on the feature I can try to implement it

nil pointer evaluating interface {}.repository

Hi,
Creating a brand new cron job works fine, but when helm upgrade --install is called to update an existing cron job I see the following error....

helm.go:76: [debug] template: app/charts/datacollector/templates/cronjob.yaml:44:27: executing "app/charts/datacollector/templates/cronjob.yaml" at <$job.image.repository>: nil pointer evaluating interface {}.repository

my values.yaml looks like this...

  jobs:
  - name: pdschedule
    image:
      repository: private/pdschedule
      tag: 2
      imagePullPolicy: IfNotPresent
    schedule: 0 */4 * * *
    failedJobsHistoryLimit: 1
    successfulJobsHistoryLimit: 3
    concurrencyPolicy: Forbid
    restartPolicy: OnFailure
    command:
    - /bin/sh
    args:
    - -c
    - java $JAVA_OPTS -jar /app.jar com.example.app

An error occurs when deploying this chart

Run command on gitlab runner:

$ helm upgrade --install "${COMPONENT}" chartmuseum/helm-cronjobs --version "${API_BACKEND_CHART_VERSION}" --namespace "${CI_K8S_NAMESPACE}" --values ./deploy/${VALUES}.yaml --wait --timeout "${HELM_TIMEOUT}"

When deploying to a dev environment in k8s, an error occurs:

coalesce.go:175: warning: skipped value for helm-cronjobs.jobs: Not a table.
Error: UPGRADE FAILED: template: helm-cronjobs/templates/serviceaccount.yaml:6:21: executing "helm-cronjobs/templates/serviceaccount.yaml" at <$job>: wrong type for value; expected map[string]interface {}; got string

How can this error be fixed?

Deploy service accounts

Several cronjobs require a service account to run correctly.

With the current chart, they are not supported.

It will be nice if the chart is able to create the service account and attach it to the jobs.

I have no experience with chart development, but if you agree on the feature I can try to implement it

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.