kedgeproject / kedge

Kedge : Simple, Concise & Declarative Kubernetes Applications
Apache License 2.0
298 stars 41 forks source link

Add support for defining `Job` controller #52

Closed surajssd closed 7 years ago

surajssd commented 7 years ago

Right now we by default create Deployment as the controller, so come up with a way to define the Job controller.

Read more about job:

kadel commented 7 years ago

Cron jobs are still alpha feature. I don't think we should add support for it until they are out of alpha.

But Jobs are in stable v1, and we should definetly support that.

concaf commented 7 years ago

Talking with @kadel, we thought that -

So, we can do something like this with jobs -

type JobSpecMod struct {
    Name                string
    api_v1.PodSpec      `json:",inline"`
    ext_v1beta1.JobSpec `json:",inline"`
}

type App struct {
    Name              string             `json:"name"`
        ...
        ...
    Jobs              []JobSpecMod       `json:"jobs,omitempty"`
}

This lets us defining jobs like -

name: httpd
containers:
- image: centos/httpd
services:
  - name: httpd
    type: NodePort
    ports:
    - port: 8080
      targetPort: 80
jobs:
- name: piStuff
  activeDeadlineSeconds: 100 # part of JobSpec
  containers: # part of PodSpec
  - name: pi
    image: perl
    command: ["perl",  "-Mbignum=bpi", "-wle", "print bpi(2000)"]
  restartPolicy: Never

This also means, that defining solo jobs will be possible like -

name: httpd
jobs:
- name: piStuff
  activeDeadlineSeconds: 100 # part of JobSpec
  containers: # part of PodSpec
  - name: pi
    image: perl
    command: ["perl",  "-Mbignum=bpi", "-wle", "print bpi(2000)"]
  restartPolicy: Never

How does this look @kedgeproject/maintainers? Lazy consensus in effect! :yum:

concaf commented 7 years ago

@kadel also, about the name auto generation part, I think it's safe to auto generate names for any number of jobs specified in the spec, since there are no services, etc associated with these, and no one talks to them (which is sad) but they need to communicate outside.

surajssd commented 7 years ago

Since https://github.com/kedgeproject/kedge/pull/253 is merged closing this one!