deploy-tmp-template.yaml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. ---
  2. apiVersion: apps/v1
  3. kind: StatefulSet
  4. metadata:
  5. name: [APP]
  6. namespace: [ENV]
  7. labels:
  8. app: [APP]
  9. spec:
  10. serviceName: [APP]
  11. replicas: [REPLICA]
  12. selector:
  13. matchLabels:
  14. app: [APP]
  15. template:
  16. metadata:
  17. labels:
  18. app: [APP]
  19. spec:
  20. readinessGates:
  21. - conditionType: InPlaceUpdateReady
  22. terminationGracePeriodSeconds: 180
  23. dnsPolicy: ClusterFirstWithHostNet
  24. dnsConfig:
  25. nameservers:
  26. - 223.5.5.5
  27. - 114.114.114.114
  28. initContainers:
  29. - name: init
  30. image: hub.evbj.easou.com/dev/busybox
  31. command: [ "chmod","777","-R","/data" ]
  32. imagePullPolicy: IfNotPresent
  33. volumeMounts:
  34. - name: volume
  35. mountPath: /data
  36. #nodeSelector:
  37. # app.touchrs: touchrs
  38. affinity:
  39. podAntiAffinity:
  40. preferredDuringSchedulingIgnoredDuringExecution:
  41. - weight: 100
  42. podAffinityTerm:
  43. labelSelector:
  44. matchExpressions:
  45. - key: app
  46. operator: In
  47. values:
  48. - [APP]
  49. topologyKey: kubernetes.io/hostname
  50. containers:
  51. - name: [APP]
  52. image: hub.evbj.easou.com/[ENV]/[APP]:[TAG]
  53. imagePullPolicy: IfNotPresent
  54. env:
  55. - name: MY_NODE_NAME
  56. valueFrom:
  57. fieldRef:
  58. fieldPath: spec.nodeName
  59. - name: MY_POD_IP
  60. valueFrom:
  61. fieldRef:
  62. fieldPath: status.podIP
  63. - name: MY_POD_NAME
  64. valueFrom:
  65. fieldRef:
  66. fieldPath: metadata.name
  67. - name: MY_POD_NAMESPACE
  68. valueFrom:
  69. fieldRef:
  70. fieldPath: metadata.namespace
  71. - name: JAVA_OPTS
  72. value: "-server [DEBUG_OPTS] -Xmx2g -Xms2g -Xss512k -Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom -Dspring.profiles.active=[PROFILE]"
  73. ports:
  74. - containerPort: 8080
  75. name: port
  76. - containerPort: 8001
  77. name: "jvm-debug"
  78. volumeMounts:
  79. - name: volume
  80. mountPath: /data
  81. lifecycle:
  82. preStop:
  83. exec:
  84. command: ["/bin/sh","-c","curl -H 'loginName:admin' -H 'password:ea1so2ua3dm4in5' -X POST 127.0.0.1:8080/actuator/shutdown"]
  85. livenessProbe:
  86. httpGet:
  87. path: /actuator/health
  88. port: 8080
  89. httpHeaders:
  90. - name: loginName
  91. value: admin
  92. - name: password
  93. value: ea1so2ua3dm4in5
  94. initialDelaySeconds: 40 #60s后启动第一次探测
  95. periodSeconds: 15 # 每隔10s启动一次探测
  96. timeoutSeconds: 3 # 超时时间3s
  97. successThreshold: 1 # 成功1次即表示容器健康
  98. failureThreshold: 5 # 连续5次失败,则判定容器不健康,默认3次
  99. readinessProbe:
  100. tcpSocket:
  101. port: 8080
  102. initialDelaySeconds: 40
  103. periodSeconds: 15
  104. - image: hub.evbj.easou.com/pro/filebeat:7.13.3
  105. imagePullPolicy: IfNotPresent
  106. name: filebeat
  107. volumeMounts:
  108. - name: volume #日志同时挂载在nginx和filebeat中
  109. mountPath: /data
  110. - name: filebeat-config
  111. mountPath: /usr/share/filebeat/filebeat.yml
  112. subPath: filebeat.yml
  113. volumes:
  114. - name: filebeat-config
  115. configMap:
  116. name: filebeat-config-[APP]
  117. items:
  118. - key: filebeat.yml
  119. path: filebeat.yml
  120. volumeClaimTemplates:
  121. - metadata:
  122. name: volume
  123. spec:
  124. accessModes: [ "ReadWriteOnce" ]
  125. storageClassName: ceph-block
  126. resources:
  127. requests:
  128. storage: 100Gi
  129. ---
  130. apiVersion: v1
  131. kind: Service
  132. metadata:
  133. name: [APP]-svc
  134. namespace: [ENV]
  135. labels:
  136. app: [APP]-svc
  137. spec:
  138. type: NodePort
  139. ports:
  140. - port: 80
  141. targetPort: 8080
  142. name: "main"
  143. selector:
  144. app: [APP]
  145. ---
  146. apiVersion: networking.k8s.io/v1
  147. kind: Ingress
  148. metadata:
  149. name: [APP]-ingress
  150. namespace: [ENV]
  151. spec:
  152. rules:
  153. - host: [ENV]-[APP].ieasou.cn
  154. http:
  155. paths:
  156. - path: /
  157. pathType: Prefix
  158. backend:
  159. service:
  160. name: [APP]-svc
  161. port:
  162. number: 8080
  163. ingressClassName: nginx
  164. ---
  165. apiVersion: v1
  166. kind: ConfigMap
  167. metadata:
  168. name: filebeat-config-[APP]
  169. namespace: [ENV]
  170. data:
  171. filebeat.yml: |
  172. filebeat.inputs:
  173. - type: log
  174. enabled: true
  175. #多行合并
  176. multiline.pattern: '^\[[0-9]{4}-[0-9]{2}-[0-9]{2}'
  177. multiline.negate: true
  178. multiline.match: after
  179. multiline.timeout: 30
  180. fields:
  181. log_topic: [APP]
  182. fields_under_root: true
  183. paths:
  184. - "/data/logs/app/*.log"
  185. - "/data/logs/*.log"
  186. output.kafka:
  187. version: 2.0.0
  188. enable: true
  189. hosts: ["kafka-0.kafka-headless.[ENV].svc.cluster.local:9093", "kafka-1.kafka-headless.[ENV].svc.cluster.local:9093", "kafka-2.kafka-headless.[ENV].svc.cluster.local:9093"]
  190. topic: 'offline-process-topic'
  191. required_acks: 1
  192. partition.round_robin:
  193. reachable_only: false
  194. compression: gzip
  195. max_message_bytes: 1000000