Files
youlai-boot/deploy/deploy.yaml

65 lines
2.4 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
namespace: youlai-bootnfckx
labels:
app: youlai-boot
spec: # 资源规约
replicas: 1 # 告知 Deployment 运行 1 个与该模板匹配的 Pod (默认1)
strategy:
type: RollingUpdate # Recreate:停止所有原来启动新的适用开发环境RollingUpdate: 滚动升级,启动新的完成后才停止旧的,保证业务连贯性,如果新的版本发布错误则会保持老的版本
rollingUpdate:
maxSurge: 25% # 100个pod可启动25个新的pod
maxUnavailable: 25% # 100个pod可关闭25旧的个pod
selector: # 圈定Deployment管理的Pod范围
matchLabels:
app: youlai-boot # 必须匹配 spec.template.metadata.labels
template:
metadata:
labels:
app: youlai-boot #必须匹配 spec.selector.matchLabels
spec:
containers:
- name: youlai-boot # 容器名称
image: registry.cn-hangzhou.aliyuncs.com/youlaitech/youlai-boot:latest # 容器镜像地址 (常用镜像仓库aliyun容器镜像服务/Docker Hub/Harbor企业级私有镜像)
imagePullPolicy: Always # 镜像拉取策略Always-总是拉取镜像默认IfNotPresent本地有则不拉取镜像Never只使用本地镜像从不拉取
ports:
- containerPort: 8989
env:
- name: spring.profiles.active
value: prod
- name: TZ
value: Asia/Shanghai
resources: # 资源管理
limits:
cpu: 256m # CPU 1核心 = 1000m
memory: 512Mi # 内存 1G = 1000Mi
volumeMounts: # 容器目录挂载配置
- mountPath: /logs/youlai-boot # 容器要挂载的目录
name: log-volume # 日志数据卷名称,和下文 volumes 配置的名称需一致
volumes: # 数据卷
- name: log-volume # 日志数据卷名称
hostPath:
path: /logs/youlai-boot # 宿主机目录
type: DirectoryOrCreate # 目录不存在则创建
---
apiVersion: v1
kind: Service
metadata:
name: youlai-boot
labels:
app: youlai-boot
namespace: youlai-bootnfckx
spec:
selector:
app: youlai-boot
ports:
- name: http # 端口名称
protocol: TCP # 协议类型
port: 8989
targetPort: 8989
type: ClusterIP # Service类型ClusterIP(默认)/NodePort/LoaderBalancer