Files
youlai-boot/deploy/prod/deploy.yaml
2023-01-13 16:56:04 +08:00

65 lines
2.0 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
# 定义工作负载
apiVersion: apps/v1
kind: Deployment # 无状态部署
metadata: # 资源元数据
name: youlai-boot-deployment # Deployment名称必须
namespace: youlai
labels: # 资源标签 k8s核心分组机制通过label selector 能够识别一组有共同特征或属性的资源对象, kubectl get pod -l app=youlai-boot --show-labels 过滤出所有
app: youlai-boot
spec: # Deployment 规格说明
replicas: 1 # 副本数量
strategy: # 更新策略
type: RollingUpdate # Recreate:停止所有原来启动新的适用开发环境RollingUpdate: 滚动升级,启动新的完成后才停止旧的,保证业务连贯性,如果新的版本发布错误则会保持老的版本
rollingUpdate:
maxSurge: 25% # 100个pod可启动25个新的pod
maxUnavailable: 25% # 100个pod可关闭25旧的个pod
selector:
matchLabels:
app: youlai-boot
template: # pod基本信息
metadata: # pod元数据
labels: # 至少需要定义一个label用于service识别转发pod
app: youlai-boot # 完全匹配spec.selector.matchLabels
spec: # pod规格
containers:
- name: youlai-boot # 必须
image: youlaitech/youlai-boot:latest # 必须
imagePullPolicy: Always
ports:
- containerPort: 8989
protocol: TCP
env:
- name: spring.profiles.active # 容器端口
value: prod
- name: TZ
value: Asia/Shanghai
volumeMounts:
- mountPath: /logs/youlai-boot
name: log-path
resources: # 资源限制
limits:
cpu: 256m
memory: 512Mi
dnsPolicy: ClusterFirst
restartPolicy: Always
---
# 定义服务
apiVersion: v1
kind: Service
metadata:
labels:
app: youlai-boot
name: youlai-boot-deployment
namespace: youlai
spec:
ports:
- name: http
port: 8989
protocol: TCP
targetPort: 8989
selector:
app: youlai-boot
sessionAffinity: None
type: NodePort