job.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package k8s
  2. var jobTmeplate = `apiVersion: batch/v1beta1
  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: registry-vpc.cn-hangzhou.aliyuncs.com/{{.namespace}}/
  17. env:
  18. - name: aliyun_logs_k8slog
  19. value: "stdout"
  20. - name: aliyun_logs_k8slog_tags
  21. value: "stage={{.env}}"
  22. - name: aliyun_logs_k8slog_format
  23. value: "json"
  24. resources:
  25. limits:
  26. cpu: {{.limitCpu}}m
  27. memory: {{.limitMem}}Mi
  28. requests:
  29. cpu: {{.requestCpu}}m
  30. memory: {{.requestMem}}Mi
  31. command:
  32. - ./{{.serviceName}}
  33. - -f
  34. - ./{{.name}}.json
  35. volumeMounts:
  36. - name: timezone
  37. mountPath: /etc/localtime
  38. imagePullSecrets:
  39. - name: {{.namespace}}
  40. restartPolicy: OnFailure
  41. volumes:
  42. - name: timezone
  43. hostPath:
  44. path: /usr/share/zoneinfo/Asia/Shanghai
  45. `