job.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package k8s
  2. // 无环境区分
  3. var jobTmeplate = `apiVersion: batch/v1beta1
  4. kind: CronJob
  5. metadata:
  6. name: {{.name}}
  7. namespace: {{.namespace}}
  8. spec:
  9. successfulJobsHistoryLimit: {{.successfulJobsHistoryLimit}}
  10. schedule: "{{.schedule}}"
  11. jobTemplate:
  12. spec:
  13. template:
  14. spec:
  15. containers:
  16. - name: {{.name}}
  17. image: registry-vpc.cn-hangzhou.aliyuncs.com/{{.namespace}}/
  18. env:
  19. - name: aliyun_logs_k8slog
  20. value: "stdout"
  21. - name: aliyun_logs_k8slog_tags
  22. value: "stage={{.env}}"
  23. - name: aliyun_logs_k8slog_format
  24. value: "json"
  25. resources:
  26. limits:
  27. cpu: {{.limitCpu}}m
  28. memory: {{.limitMem}}Mi
  29. requests:
  30. cpu: {{.requestCpu}}m
  31. memory: {{.requestMem}}Mi
  32. command:
  33. - ./{{.serviceName}}
  34. - -f
  35. - ./{{.name}}.json
  36. volumeMounts:
  37. - name: timezone
  38. mountPath: /etc/localtime
  39. imagePullSecrets:
  40. - name: {{.namespace}}
  41. restartPolicy: OnFailure
  42. volumes:
  43. - name: timezone
  44. hostPath:
  45. path: /usr/share/zoneinfo/Asia/Shanghai`