From f606af36486dd9ed10b6a3685fb2af9408fbc5d4 Mon Sep 17 00:00:00 2001 From: handsomewu <562390063@qq.com> Date: Thu, 14 Nov 2024 14:16:49 +0800 Subject: [PATCH] add defalut yaml file --- src/views/deploy/app.vue | 38 +++++++++++++++++++++++++++++++++++- src/views/deploy/service.vue | 16 ++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/src/views/deploy/app.vue b/src/views/deploy/app.vue index 00f6dc07..c2bfc7a9 100644 --- a/src/views/deploy/app.vue +++ b/src/views/deploy/app.vue @@ -33,7 +33,43 @@ export default { return { tableData: [], // 初始为空数组,将在 mounted 时获取数据 yamlEditorVisible: false, // 控制 YAML 编辑器弹框的显示 - yamlContent: '', // YAML 编辑器中的内容 + yamlContent: `apiVersion: apps/v1 +kind: Deployment +metadata: + name: web + namespace: default + annotations: # 记录回滚参数 + kubernetes.io/change-cause: "web.v1-nginx-1.19" #记录到revision中的内容,记录版本号 +spec: + replicas: 3 # Pod副本预期数量 + revisionHistoryLimit: 10 # RS历史版本保存数量 + selector: + matchLabels: + app: web + strategy: + rollingUpdate: + maxSurge: 25% # 滚动更新过程最大pod副本数 + maxUnavailable: 25% # 滚动更新过程中最大不可用pod副本数, + type: RollingUpdate + template: + metadata: + labels: + app: web # Pod副本的标签 + spec: + containers: + - name: web + image: nginx:1.16 + readinessProbe: # 存活检查,如果失败,将杀死容器,来重启 + httpGet: + port: 80 + path: /index.html + initialDelaySeconds: 10 # 启动容器后多少秒健康检查 + periodSeconds: 10 # 以后间隔多少秒检查一次 + + livenessProbe: # 就绪检查,失败就会剔除 service + httpGet: + port: 80 + path: /index.html`, // YAML 默认内容 loading: false } }, diff --git a/src/views/deploy/service.vue b/src/views/deploy/service.vue index c0602111..f930248f 100644 --- a/src/views/deploy/service.vue +++ b/src/views/deploy/service.vue @@ -40,7 +40,21 @@ export default { return { tableData: [], // 初始为空数组,将在 mounted 时获取数据 yamlEditorVisible: false, // 控制 YAML 编辑器弹框的显示 - yamlContent: '', // YAML 编辑器中的内容 + yamlContent: `apiVersion: v1 +kind: Service +metadata: + labels: + app: web + name: web +spec: + type: NodePort # 服务类型 + ports: + - port: 80 # Service端口 + protocol: TCP # 协议 + targetPort: 80 # 容器端口 + nodePort: 30009 # 对外暴露的端口,可以指定 + selector: + app: web # 指定关联Pod的标签`, // YAML 编辑器中的内容 loading: false, value: '' }