219 lines
4.8 KiB
YAML
219 lines
4.8 KiB
YAML
apiVersion: v1
|
|
kind: Namespace
|
|
metadata:
|
|
name: erp-prod
|
|
labels:
|
|
name: erp-prod
|
|
environment: production
|
|
---
|
|
apiVersion: v1
|
|
kind: ServiceAccount
|
|
metadata:
|
|
name: finance-service
|
|
namespace: erp-prod
|
|
labels:
|
|
app: finance-service
|
|
---
|
|
apiVersion: v1
|
|
kind: Secret
|
|
metadata:
|
|
name: finance-service-secrets
|
|
namespace: erp-prod
|
|
type: Opaque
|
|
stringData:
|
|
DB_PASSWORD: "REPLACE_WITH_DB_PASSWORD"
|
|
REDIS_PASSWORD: "REPLACE_WITH_REDIS_PASSWORD"
|
|
---
|
|
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: finance-service-config
|
|
namespace: erp-prod
|
|
data:
|
|
SPRING_PROFILES_ACTIVE: "prod"
|
|
JAVA_OPTS: "-Xms512m -Xmx1024m -XX:+UseG1GC"
|
|
NACOS_HOST: "nacos"
|
|
NACOS_NAMESPACE: "prod"
|
|
NACOS_PORT: "8848"
|
|
DB_HOST: "mysql"
|
|
DB_PORT: "3306"
|
|
DB_NAME: "erp_java"
|
|
DB_USERNAME: "erp_user"
|
|
REDIS_HOST: "redis"
|
|
REDIS_PORT: "6379"
|
|
SERVER_PORT: "8007"
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: finance-service
|
|
namespace: erp-prod
|
|
labels:
|
|
app: finance-service
|
|
version: v1
|
|
tier: backend
|
|
spec:
|
|
replicas: 2
|
|
revisionHistoryLimit: 10
|
|
selector:
|
|
matchLabels:
|
|
app: finance-service
|
|
strategy:
|
|
type: RollingUpdate
|
|
rollingUpdate:
|
|
maxSurge: 1
|
|
maxUnavailable: 0
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: finance-service
|
|
version: v1
|
|
tier: backend
|
|
annotations:
|
|
prometheus.io/scrape: "true"
|
|
prometheus.io/port: "8007"
|
|
prometheus.io/path: "/actuator/prometheus"
|
|
spec:
|
|
serviceAccountName: finance-service
|
|
securityContext:
|
|
runAsNonRoot: true
|
|
runAsUser: 1001
|
|
fsGroup: 1001
|
|
containers:
|
|
- name: finance-service
|
|
image: registry.erpzbbh.cn/erp/finance-service:1.0.0
|
|
imagePullPolicy: Always
|
|
ports:
|
|
- name: http
|
|
containerPort: 8007
|
|
protocol: TCP
|
|
envFrom:
|
|
- configMapRef:
|
|
name: finance-service-config
|
|
- secretRef:
|
|
name: finance-service-secrets
|
|
resources:
|
|
requests:
|
|
memory: "512Mi"
|
|
cpu: "250m"
|
|
limits:
|
|
memory: "1Gi"
|
|
cpu: "1000m"
|
|
livenessProbe:
|
|
httpGet:
|
|
path: /actuator/health/liveness
|
|
port: http
|
|
initialDelaySeconds: 60
|
|
periodSeconds: 10
|
|
timeoutSeconds: 5
|
|
failureThreshold: 3
|
|
readinessProbe:
|
|
httpGet:
|
|
path: /actuator/health/readiness
|
|
port: http
|
|
initialDelaySeconds: 30
|
|
periodSeconds: 5
|
|
timeoutSeconds: 3
|
|
failureThreshold: 3
|
|
startupProbe:
|
|
httpGet:
|
|
path: /actuator/health/liveness
|
|
port: http
|
|
initialDelaySeconds: 10
|
|
periodSeconds: 5
|
|
failureThreshold: 30
|
|
lifecycle:
|
|
preStop:
|
|
exec:
|
|
command: ["sh", "-c", "sleep 10"]
|
|
volumeMounts:
|
|
- name: app-logs
|
|
mountPath: /app/logs
|
|
volumes:
|
|
- name: app-logs
|
|
emptyDir: {}
|
|
topologySpreadConstraints:
|
|
- maxSkew: 1
|
|
topologyKey: kubernetes.io/hostname
|
|
whenUnsatisfiable: ScheduleAnyway
|
|
labelSelector:
|
|
matchLabels:
|
|
app: finance-service
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: finance-service
|
|
namespace: erp-prod
|
|
spec:
|
|
type: ClusterIP
|
|
ports:
|
|
- name: http
|
|
port: 8007
|
|
targetPort: http
|
|
selector:
|
|
app: finance-service
|
|
---
|
|
apiVersion: networking.k8s.io/v1
|
|
kind: Ingress
|
|
metadata:
|
|
name: finance-service-ingress
|
|
namespace: erp-prod
|
|
annotations:
|
|
nginx.ingress.kubernetes.io/ssl-redirect: "true"
|
|
nginx.ingress.kubernetes.io/proxy-body-size: "20m"
|
|
spec:
|
|
ingressClassName: nginx
|
|
tls:
|
|
- hosts:
|
|
- finance.erpzbbh.cn
|
|
secretName: finance-service-tls
|
|
rules:
|
|
- host: finance.erpzbbh.cn
|
|
http:
|
|
paths:
|
|
- path: /
|
|
pathType: Prefix
|
|
backend:
|
|
service:
|
|
name: finance-service
|
|
port:
|
|
name: http
|
|
---
|
|
apiVersion: autoscaling/v2
|
|
kind: HorizontalPodAutoscaler
|
|
metadata:
|
|
name: finance-service-hpa
|
|
namespace: erp-prod
|
|
spec:
|
|
scaleTargetRef:
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
name: finance-service
|
|
minReplicas: 2
|
|
maxReplicas: 10
|
|
metrics:
|
|
- type: Resource
|
|
resource:
|
|
name: cpu
|
|
target:
|
|
type: Utilization
|
|
averageUtilization: 70
|
|
- type: Resource
|
|
resource:
|
|
name: memory
|
|
target:
|
|
type: Utilization
|
|
averageUtilization: 80
|
|
---
|
|
apiVersion: policy/v1
|
|
kind: PodDisruptionBudget
|
|
metadata:
|
|
name: finance-service-pdb
|
|
namespace: erp-prod
|
|
spec:
|
|
minAvailable: 1
|
|
selector:
|
|
matchLabels:
|
|
app: finance-service
|