apiVersion: apps/v1 kind: Deployment metadata: name: tmpl-api spec: replicas: 1 selector: matchLabels: app.kubernetes.io/name: tmpl-api template: metadata: labels: app.kubernetes.io/name: tmpl-api annotations: # 原生 Prometheus 部署使用以下 annotations。 # 如使用 Prometheus Operator,建议改为 ServiceMonitor CRD 并删除这些 annotations。 # 参考: https://prometheus-operator.dev/docs/api-reference/api/#monitoring.coreos.com/v1.ServiceMonitor prometheus.io/scrape: "true" prometheus.io/port: "9090" prometheus.io/path: "/actuator/prometheus" spec: containers: - name: tmpl-api image: tmpl-api:latest ports: - name: http containerPort: 8080 protocol: TCP - name: management containerPort: 9090 protocol: TCP env: - name: JAVA_OPTS value: "-XX:MaxRAMPercentage=75.0 -XX:+UseG1GC" envFrom: - configMapRef: name: tmpl-api-config - secretRef: name: tmpl-api-secret readinessProbe: httpGet: path: /actuator/health/readiness port: management initialDelaySeconds: 15 periodSeconds: 10 failureThreshold: 3 livenessProbe: httpGet: path: /actuator/health/liveness port: management initialDelaySeconds: 30 periodSeconds: 15 failureThreshold: 3 startupProbe: httpGet: path: /actuator/health/liveness port: management initialDelaySeconds: 10 periodSeconds: 5 failureThreshold: 12 resources: requests: cpu: 200m memory: 384Mi limits: cpu: "1" memory: 768Mi