func (s *Service) PostJobs(c *gin.Context) {
	req.Entry(c).Debug("PostJobs")
	tjob := &model.TJob{}
	err := c.BindJSON(tjob)
	if err != nil {
		c.AbortWithError(400, err)
		return
	}
	cm, service, job, err := NewTmpl(s.config).newtjob(tjob)
	if err == nil {
		_, err = s.engine.CoreV1().ConfigMaps(s.config.JobNamespace).Create(cm)
	}
	if err == nil {
		_, err = s.engine.CoreV1().Services(s.config.JobNamespace).Create(service)
	}
	if err == nil {
		_, err = s.engine.Batch().Jobs(s.config.JobNamespace).Create(job)
	}
	if err != nil {
		c.AbortWithError(400, err)
		return
	}
	c.JSON(200, tjob)
}
PostJobs : add tjob     -> add job (set replica to 0)
package service
import (
	"fmt"
	"strings"
	"time"
	"github.com/Sirupsen/logrus"
	"github.com/gin-gonic/gin"
	meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	batch_v1 "k8s.io/client-go/pkg/apis/batch/v1"
	"github.com/arlert/ymir/model"
	req "github.com/arlert/ymir/utils/reqlog"
)
func (s *Service) GetJobs(c *gin.Context) {
	tjobname := c.Param("tjobname")
	req.Entry(c).Debugln("GetJobs", tjobname)
	selector := "app=" + model.AppName
	if len(tjobname) > 0 {
		selector += ",job=" + tjobname
	}
	jobs, err := s.engine.Batch().Jobs(s.config.JobNamespace).List(meta_v1.ListOptions{
		LabelSelector: selector,
	})
	if err != nil {
		c.AbortWithError(400, err)
		return
	}
	ret := make([]model.TJob, 0)
	for index := range jobs.Items {
		tjob, err := s.getTJob(&jobs.Items[index])
		if err != nil {
			c.AbortWithError(400, err)
			return
		}
		ret = append(ret, *tjob)
	}
	c.JSON(200, ret)
}
func (s *Service) getTJob(job *batch_v1.Job) (tjob *model.TJob, err error) {
	cm, err := s.engine.CoreV1().ConfigMaps(s.config.JobNamespace).Get(job.Name, meta_v1.GetOptions{})
	if err != nil {
		return nil, err
	}
	nodes := strings.Split(job.Labels[model.NodeSelectedKey], "..")
	script := cm.Data[model.ScriptKey]
	tjob = &model.TJob{
		Name:          job.Name,
		Description:   job.Labels[model.DescriptionKey],
		Script:        script,
		Replicas:      len(nodes),
		NodesSelected: nodes,
		Status:        jobStatus2String(job),
		Created:       job.CreationTimestamp.Time,
	}
	return
}