加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
deploy.yaml 2.72 KB
一键复制 编辑 原始数据 按行查看 历史
rdc_qa 提交于 2022-03-23 15:30 . deploy.yaml init
#apiVersion: v1
#kind: PersistentVolumeClaim
#metadata:
# namespace: youlai-mall
# name: tmall-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: tmall
name: tmall-deployment
namespace: ${k8s_namespace} #一定要写名称空间
spec:
progressDeadlineSeconds: 600
replicas: 1
selector:
matchLabels:
app: tmall
strategy: # 更新策略
rollingUpdate:
maxSurge: 50%
maxUnavailable: 50%
type: RollingUpdate
template:
metadata:
labels:
app: tmall
spec:
volumes: # 挂载卷
- name: host-time # 挂载主机上的时区
hostPath:
path: /etc/localtime
type: ''
# - name: volume-tmall # 挂载日志
# persistentVolumeClaim:
# claimName: tmall-pvc0
imagePullSecrets:
- name: ${docker_hub_id} #提前在项目下配置访问阿里云或harbor的账号密码
containers:
- image: $remote_tag
imagePullPolicy: Always
name: tmall
ports:
- name: http-8080
containerPort: 8080
protocol: TCP
resources: # 资源限制
limits:
cpu: 250m
memory: 512Mi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- name: host-time
readOnly: true
mountPath: /etc/localtime
# - name: volume-tmall
# mountPath: /logs
dnsPolicy: ClusterFirst
restartPolicy: Always
terminationGracePeriodSeconds: 30
affinity: # 节点亲合性,这下面表达的意思是,尽量散到不同的机器上
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchLabels:
app: tmall
topologyKey: kubernetes.io/hostname
revisionHistoryLimit: 2 #deploy 升级最大记录数由 revisionHistoryLimit 定义,默认值为 10
---
apiVersion: v1
kind: Service
metadata:
labels:
app: tmall
name: tmall-svc
namespace: ${k8s_namespace}
spec:
ports:
- name: http
port: 8080
protocol: TCP
targetPort: 8080
selector:
app: tmall
sessionAffinity: None
type: NodePort
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化