deployment.tpl 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. apiVersion: apps/v1
  2. kind: Deployment
  3. metadata:
  4. name: {{.Name}}
  5. namespace: {{.Namespace}}
  6. labels:
  7. app: {{.Name}}
  8. spec:
  9. replicas: {{.Replicas}}
  10. revisionHistoryLimit: {{.Revisions}}
  11. selector:
  12. matchLabels:
  13. app: {{.Name}}
  14. template:
  15. metadata:
  16. labels:
  17. app: {{.Name}}
  18. spec:{{if .ServiceAccount}}
  19. serviceAccountName: {{.ServiceAccount}}{{end}}
  20. containers:
  21. - name: {{.Name}}
  22. image: {{.Image}}
  23. {{if .ImagePullPolicy}}imagePullPolicy: {{.ImagePullPolicy}}
  24. {{end}}ports:
  25. - containerPort: {{.Port}}
  26. readinessProbe:
  27. tcpSocket:
  28. port: {{.Port}}
  29. initialDelaySeconds: 5
  30. periodSeconds: 10
  31. livenessProbe:
  32. tcpSocket:
  33. port: {{.Port}}
  34. initialDelaySeconds: 15
  35. periodSeconds: 20
  36. resources:
  37. requests:
  38. cpu: {{.RequestCpu}}m
  39. memory: {{.RequestMem}}Mi
  40. limits:
  41. cpu: {{.LimitCpu}}m
  42. memory: {{.LimitMem}}Mi
  43. volumeMounts:
  44. - name: timezone
  45. mountPath: /etc/localtime
  46. {{if .Secret}}imagePullSecrets:
  47. - name: {{.Secret}}
  48. {{end}}volumes:
  49. - name: timezone
  50. hostPath:
  51. path: /usr/share/zoneinfo/Asia/Shanghai
  52. ---
  53. apiVersion: v1
  54. kind: Service
  55. metadata:
  56. name: {{.Name}}-svc
  57. namespace: {{.Namespace}}
  58. spec:
  59. ports:
  60. {{if .UseNodePort}}- nodePort: {{.NodePort}}
  61. port: {{.Port}}
  62. protocol: TCP
  63. targetPort: {{.TargetPort}}
  64. type: NodePort{{else}}- port: {{.Port}}
  65. targetPort: {{.TargetPort}}{{end}}
  66. selector:
  67. app: {{.Name}}
  68. ---
  69. apiVersion: autoscaling/v2beta2
  70. kind: HorizontalPodAutoscaler
  71. metadata:
  72. name: {{.Name}}-hpa-c
  73. namespace: {{.Namespace}}
  74. labels:
  75. app: {{.Name}}-hpa-c
  76. spec:
  77. scaleTargetRef:
  78. apiVersion: apps/v1
  79. kind: Deployment
  80. name: {{.Name}}
  81. minReplicas: {{.MinReplicas}}
  82. maxReplicas: {{.MaxReplicas}}
  83. metrics:
  84. - type: Resource
  85. resource:
  86. name: cpu
  87. target:
  88. type: Utilization
  89. averageUtilization: 80
  90. ---
  91. apiVersion: autoscaling/v2beta2
  92. kind: HorizontalPodAutoscaler
  93. metadata:
  94. name: {{.Name}}-hpa-m
  95. namespace: {{.Namespace}}
  96. labels:
  97. app: {{.Name}}-hpa-m
  98. spec:
  99. scaleTargetRef:
  100. apiVersion: apps/v1
  101. kind: Deployment
  102. name: {{.Name}}
  103. minReplicas: {{.MinReplicas}}
  104. maxReplicas: {{.MaxReplicas}}
  105. metrics:
  106. - type: Resource
  107. resource:
  108. name: memory
  109. target:
  110. type: Utilization
  111. averageUtilization: 80