加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
deploy.yaml 2.33 KB
一键复制 编辑 原始数据 按行查看 历史
dorabmon 提交于 2022-05-17 10:43 . 大三学业论文
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: doraemon
name: doraemon-deployment
namespace: ${k8s_namespace} #一定要写名称空间
spec:
progressDeadlineSeconds: 600
replicas: 1
selector:
matchLabels:
app: doraemon
strategy: # 更新策略
rollingUpdate:
maxSurge: 50%
maxUnavailable: 50%
type: RollingUpdate
template:
metadata:
labels:
app: doraemon
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: doraemon
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: doraemon
topologyKey: kubernetes.io/hostname
revisionHistoryLimit: 2 #deploy 升级最大记录数由 revisionHistoryLimit 定义,默认值为 10
---
apiVersion: v1
kind: Service
metadata:
labels:
app: doraemon
name: doraemon-svc
namespace: ${k8s_namespace}
spec:
ports:
- name: http
port: 8080
protocol: TCP
targetPort: 8080
selector:
app: doraemon
sessionAffinity: None
type: NodePort
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化