feat: 按 doc_id 重组 ansible/files 与验证框架
- ansible/files 改为与文档 XX-YY 对齐的目录结构,更新相关 playbook 路径 - 新增 scripts/verify.sh 与 ansible/playbooks/verify/*.yml,移除单体 verify-matrix.yml - 补充 docs/00-02 矩阵状态、00-05 验证框架与流程、00-04 环境与 ylc65 工作机说明 - 增加 k3s 存储准备、Longhorn、local-path 等 playbook 与辅助脚本 Made-with: Cursor
This commit is contained in:
97
ansible/files/02-05-nginx-matrix/03-worker-ingress.yaml
Normal file
97
ansible/files/02-05-nginx-matrix/03-worker-ingress.yaml
Normal file
@@ -0,0 +1,97 @@
|
||||
# 03-03: Nginx + 工作节点 + Ingress(M3)
|
||||
# 路径 /demo-m3,随机一台工作节点(nodeSelector: node-role.kubernetes.io/worker)
|
||||
# ConfigMap:首页 + default.conf,X-Backend: M3 便于区分
|
||||
---
|
||||
apiVersion: v1 # ConfigMap 使用的 API 版本
|
||||
kind: ConfigMap # 配置资源类型:ConfigMap
|
||||
metadata: # 对该 ConfigMap 的标识信息
|
||||
name: nginx-m3-html # ConfigMap 名称
|
||||
namespace: default # 命名空间
|
||||
data: # ConfigMap 数据键值区
|
||||
index.html: | # HTML 内容:会挂载到 nginx 网页目录(内部内容行不改动)
|
||||
<!DOCTYPE html>
|
||||
<html><head><meta charset="utf-8"><title>M3</title></head>
|
||||
<body><h1>M3</h1><p>工作节点 + Ingress</p></body></html>
|
||||
default.conf: | # nginx 配置:通过 subPath 单文件挂载到 conf.d/default.conf(内部内容行不改动)
|
||||
server { listen 80; server_name localhost; root /usr/share/nginx/html; index index.html; location / { add_header X-Backend "M3"; try_files $uri $uri/ /index.html; } }
|
||||
---
|
||||
apiVersion: apps/v1 # Deployment 使用的 API 版本
|
||||
kind: Deployment # 工作负载:Deployment
|
||||
metadata: # Deployment 标识信息
|
||||
name: nginx-m3 # Deployment 名称
|
||||
namespace: default # 部署命名空间
|
||||
labels: # 额外标签(用于筛选/统计)
|
||||
app: nginx-m3 # 应用标签
|
||||
matrix: "02-05-m3" # 矩阵编号标签
|
||||
spec: # Deployment 期望状态
|
||||
replicas: 1 # 副本数:这里为 1
|
||||
selector: # Deployment 用于选择 Pod 的条件
|
||||
matchLabels: # 标签匹配集合(用于选中模板 Pod)
|
||||
app: nginx-m3 # 必须与 template.metadata.labels 对上
|
||||
template: # Pod 模板
|
||||
metadata: # Pod 元信息
|
||||
labels: # Pod 标签
|
||||
app: nginx-m3 # Pod 标签
|
||||
spec: # Pod 规范
|
||||
nodeSelector: # 固定跑到 worker 节点
|
||||
node-role.kubernetes.io/worker: "" # worker 节点 selector
|
||||
volumes: # 卷定义
|
||||
- name: html # 卷名(供 volumeMounts 引用)
|
||||
configMap: # 卷来源:ConfigMap
|
||||
name: nginx-m3-html # 引用的 ConfigMap 名称
|
||||
containers: # 容器列表
|
||||
- name: nginx # 容器名
|
||||
image: nginx:alpine # nginx 镜像
|
||||
ports: # 容器端口声明
|
||||
- containerPort: 80 # nginx HTTP 端口
|
||||
volumeMounts: # 容器内挂载点
|
||||
- name: html # 对应 volumes[].name
|
||||
mountPath: /usr/share/nginx/html/index.html # 挂到网页首页
|
||||
subPath: index.html # 从 ConfigMap 取该 key
|
||||
readOnly: true # 配置只读
|
||||
- name: html # 第二处仍引用同一个卷
|
||||
mountPath: /etc/nginx/conf.d/default.conf # 挂到 nginx 配置文件路径
|
||||
subPath: default.conf # 从 ConfigMap 取该 key
|
||||
readOnly: true # 配置只读
|
||||
---
|
||||
apiVersion: v1 # Service 使用的 API 版本
|
||||
kind: Service # 网络抽象:把 Pod 暴露成稳定访问入口
|
||||
metadata: # Service 标识
|
||||
name: nginx-m3 # Service 名称
|
||||
namespace: default # 命名空间
|
||||
spec: # Service 期望状态
|
||||
selector: # Service 通过标签选中后端 Pod
|
||||
app: nginx-m3 # 选择 app 标签
|
||||
ports: # Service 端口映射列表
|
||||
- port: 80 # Service 暴露端口
|
||||
targetPort: 80 # 转发到 Pod 的容器端口
|
||||
---
|
||||
apiVersion: traefik.io/v1alpha1 # Traefik Middleware API 版本
|
||||
kind: Middleware # 中间件类型:stripPrefix
|
||||
metadata: # Middleware 标识
|
||||
name: stripprefix-m3 # 名称
|
||||
namespace: default # 命名空间
|
||||
spec: # 中间件配置
|
||||
stripPrefix: # 去掉指定路径前缀
|
||||
prefixes: # 前缀列表
|
||||
- /demo-m3 # 本矩阵路径前缀
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1 # Ingress 使用的 API 版本
|
||||
kind: Ingress # 入口资源:把路径转发到 Service
|
||||
metadata: # Ingress 标识
|
||||
name: nginx-m3 # Ingress 名称
|
||||
namespace: default # 命名空间
|
||||
annotations: # Traefik 注解:绑定中间件
|
||||
traefik.ingress.kubernetes.io/router.middlewares: default-stripprefix-m3@kubernetescrd # 绑定 stripprefix-m3 中间件
|
||||
spec: # Ingress 规则
|
||||
rules: # 规则列表
|
||||
- http: # HTTP 规则
|
||||
paths: # 路径匹配列表
|
||||
- path: /demo-m3 # 匹配路径
|
||||
pathType: Prefix # 前缀匹配类型
|
||||
backend: # 后端目标
|
||||
service: # 后端是 Service
|
||||
name: nginx-m3 # Service 名称
|
||||
port: # 后端端口
|
||||
number: 80 # 端口号
|
||||
|
||||
Reference in New Issue
Block a user