job.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package kube
  2. var jobTmeplate = `apiVersion: batch/v1
  3. kind: CronJob
  4. metadata:
  5. name: {{.Name}}
  6. namespace: {{.Namespace}}
  7. spec:
  8. successfulJobsHistoryLimit: {{.SuccessfulJobsHistoryLimit}}
  9. schedule: "{{.Schedule}}"
  10. jobTemplate:
  11. spec:
  12. template:
  13. spec:
  14. containers:
  15. - name: {{.Name}}
  16. image: # todo image url
  17. resources:
  18. requests:
  19. cpu: {{.RequestCpu}}m
  20. memory: {{.RequestMem}}Mi
  21. limits:
  22. cpu: {{.LimitCpu}}m
  23. memory: {{.LimitMem}}Mi
  24. command:
  25. - ./{{.ServiceName}}
  26. - -f
  27. - ./{{.Name}}.yaml
  28. volumeMounts:
  29. - name: timezone
  30. mountPath: /etc/localtime
  31. imagePullSecrets:
  32. - name: # registry secret, if no, remove this
  33. restartPolicy: OnFailure
  34. volumes:
  35. - name: timezone
  36. hostPath:
  37. path: /usr/share/zoneinfo/Asia/Shanghai
  38. `