An open API service indexing awesome lists of open source software.

https://github.com/teslacn/elasticjob-kubernetes

A new ElasticJob Cloud on Kubernetes
https://github.com/teslacn/elasticjob-kubernetes

distributed-schedule-system distributed-scheduling elasticjob kubernetes kubernetes-operator schedule scheduler scheduling

Last synced: about 1 month ago
JSON representation

A new ElasticJob Cloud on Kubernetes

Awesome Lists containing this project

README

          

= ElasticJob on Kubernetes

== Getting Started

=== Implements Your ElasticJob

[source,java]
....
import org.apache.shardingsphere.elasticjob.api.ShardingContext;
import org.apache.shardingsphere.elasticjob.simple.job.SimpleJob;
public class MyLogSimpleJob implements SimpleJob {
@Override
public void execute(final ShardingContext shardingContext) {
// Do what you want.
}
}
....

=== Launch Your Job using ElasticJob-Cloud API
[source,java]
....
import icu.wwj.elasticjob.example.job.MyLogSimpleJob;
import org.apache.shardingsphere.elasticjob.cloud.api.JobBootstrap;

public class Main {
public static void main(String[] args) {
JobBootstrap.execute(new MyLogSimpleJob());
}
}
....

=== Build Image and Make Image Ready in Image Registry

See example.

=== Deploy ElasticJob Operator

TODO

=== Create ElasticJob CR

See example.

[source,bash]
....
kubectl apply -f https://raw.githubusercontent.com/TeslaCN/elasticjob-kubernetes/main/example/k8s/transient/elasticjob.yaml
....

[source,yaml]
....
apiVersion: icu.wwj.elasticjob/v1alpha1
kind: ElasticJob
metadata:
name: hello-transient-job
namespace: elasticjob-cloud
spec:
template:
metadata:
labels:
app: elasticjob
spec:
restartPolicy: OnFailure
containers:
- name: job-container
imagePullPolicy: IfNotPresent
image: teslacn/elasticjob-kubernetes-example:latest
jobExecutionType: TRANSIENT
shardingTotalCount: 3
shardingItemParameters:
1: a
2: b
0: c
jobParameter: 'common parameter'
# Transient job only support minute level cron. The second expression would be ignored.
cron: '0 * * * * ?'
misfire: true
description: ''
props:
a: b
disabled: false
....

=== Scale Job via kubectl

[source,bash]
....
kubectl scale --replicas=5 -n elasticjob-cloud elasticjob/hello-transient-job
....

== Basic Concept

*ElasticJob on Kubernetes* vs *ElasticJob Cloud 3.0 (Mesos)*

|===
| ElasticJob concept | ElasticJob Kubernetes | ElasticJob Mesos
| API | CRD elasticjobs.icu.wwj.elasticjob | Restful API
| Scheduler | ElasticJob Operator | base on Mesos Scheduler & Executor
| Application | An Image | A Tarball
|===

Kubernetes resource:
|===
| Job Execution Type | DAEMON | TRANSIENT
| ElasticJob with CRON | ✅ StatefulSet | ✅ CronJob
| ElasticJob without CRON | ❌ StatefulSet | ✅ Job
|===

* ✅ means supported
* ❌ means unsupported for now

== Limitations

[.lead]
Transient cron job (Kubernetes CronJob) only support UNIX cron. The second expression would be ignored.

For example, set the following cron in ElasticJob CR:
[source,yaml]
....
jobExecutionType: TRANSIENT
cron: '0/15 * * * * ?'
....

The actual cron of CronJob would be:
....
* * * * ?
....