youlai-mall/devops/deploy.yaml
2022-03-16 15:21:53 +08:00

106 lines
3.1 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: v1
#kind: PersistentVolumeClaim
#metadata:
# namespace: youlai-mall
# name: ${module_name_suffix}-pvc0
# labels: {}
#spec:
# accessModes:
# - ReadWriteOnce
# resources:
# requests:
# storage: 1Gi # k8s限制只能扩容对于pvc只能扩容不能缩容且配置sc.yaml时需要指定allowVolumeExpansion: true #增加该字段表示允许动态扩容
# storageClassName: nfs-storage
#
#---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: ${module_name_suffix}
name: ${module_name_suffix}-deployment
namespace: ${k8s_namespace} #一定要写名称空间
spec:
progressDeadlineSeconds: 600
replicas: 1
selector:
matchLabels:
app: ${module_name_suffix}
strategy: # 更新策略
rollingUpdate:
maxSurge: 50%
maxUnavailable: 50%
type: RollingUpdate
template:
metadata:
labels:
app: ${module_name_suffix}
spec:
volumes: # 挂载卷
- name: host-time # 挂载主机上的时区
hostPath:
path: /etc/localtime
type: ''
# - name: volume-${module_name_suffix} # 挂载日志
# persistentVolumeClaim:
# claimName: ${module_name_suffix}-pvc0
imagePullSecrets:
- name: ${docker_hub_id} #提前在项目下配置访问阿里云或harbor的账号密码
containers:
- image: $remote_tag
imagePullPolicy: Always
name: ${module_name_suffix}
ports:
- name: http-${service_port}
containerPort: ${service_port}
protocol: TCP
env:
- name: SPRING_PROFILES_ACTIVE
value: k8s
resources: # 资源限制
limits:
cpu: 250m
memory: 512Mi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- name: host-time
readOnly: true
mountPath: /etc/localtime
# - name: volume-${module_name_suffix}
# mountPath: /logs
dnsPolicy: ClusterFirst
restartPolicy: Always
terminationGracePeriodSeconds: 30
affinity: # 节点亲合性,这下面表达的意思是,尽量散到不同的机器上
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchLabels:
app: ${module_name_suffix}
topologyKey: kubernetes.io/hostname
revisionHistoryLimit: 2 #deploy 升级最大记录数由 revisionHistoryLimit 定义,默认值为 10
---
apiVersion: v1
kind: Service
metadata:
labels:
app: ${module_name_suffix}
name: ${module_name_suffix}-svc
namespace: ${k8s_namespace}
spec:
ports:
- name: http
port: ${service_port}
protocol: TCP
targetPort: ${service_port}
nodePort: ${service_nodeport}
selector:
app: ${module_name_suffix}
sessionAffinity: None
type: NodePort