Files
Deploy-Laboratory/ansible/files/03-02-nginx-matrix-tls/01-control-ingress.yaml
jack 8c43761962 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
2026-03-26 07:01:14 +08:00

117 lines
4.8 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.
# 03-02 TLS: M1 控制节点 + Ingress路径 /(根路径),域名 test01.jackadam.top
# ConfigMap首页 + default.conf单文件 subPath 挂载,与 M2M4 一致)
---
apiVersion: v1 # ConfigMap 使用的 API 版本
kind: ConfigMap # 配置资源类型ConfigMap
metadata: # ConfigMap 标识信息
name: nginx-m1-html # ConfigMap 名称
namespace: default # 命名空间
data: # ConfigMap 数据区
index.html: | # HTML 内容:挂载到 nginx 网页目录(内部内容行不改动)
<!DOCTYPE html>
<html><head><meta charset="utf-8"><title>M1</title></head>
<body><h1>M1</h1><p>控制节点 + Ingress</p><p><strong>Backend: M1</strong></p></body></html>
default.conf: | # nginx 配置:通过 subPath 单文件挂载到 conf.d/default.conf内部内容行不改动
server { listen 80 default_server; server_name _; root /usr/share/nginx/html; index index.html; location / { add_header X-Backend "M1"; try_files $uri $uri/ /index.html; } }
---
apiVersion: apps/v1 # Deployment 使用的 API 版本
kind: Deployment # 工作负载Deployment
metadata: # Deployment 标识信息
name: nginx-m1 # Deployment 名称
namespace: default # 部署命名空间
labels: # 标签
app: nginx-m1 # 应用标签
matrix: "03-02-m1" # 矩阵编号标签
spec: # Deployment 期望状态
replicas: 1 # 副本数:单副本
selector: # 选择器
matchLabels: # 标签匹配集合(用于选中模板 Pod
app: nginx-m1 # 与 template.labels 对齐
template: # Pod 模板
metadata: # Pod 元信息
labels: # Pod 标签
app: nginx-m1 # Pod 标签
spec: # Pod 规范
nodeSelector: # 固定到 control-plane 节点
node-role.kubernetes.io/control-plane: "" # 控制节点 selector
tolerations: # 容忍 NoSchedule 污点
- key: node-role.kubernetes.io/control-plane # 污点 key
operator: Exists # 匹配存在
effect: NoSchedule # 影响效果
volumes: # 卷定义
- name: html # 卷名
configMap: # 来自 ConfigMap
name: nginx-m1-html # ConfigMap 名称
containers: # 容器列表
- name: nginx # 容器名
image: nginx:alpine # 镜像
ports: # 容器端口
- containerPort: 80 # nginx HTTP 端口
volumeMounts: # 挂载点
- name: html # 引用卷
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-m1 # Service 名称
namespace: default # 命名空间
spec: # Service 期望状态
selector: # Service 选择器
app: nginx-m1 # 选中后端 Pod
ports: # 端口映射
- port: 80 # Service 端口
targetPort: 80 # 转发目标端口
---
apiVersion: networking.k8s.io/v1 # Ingress 使用的 API 版本
kind: Ingress # 入口资源
metadata: # Ingress 标识
name: nginx-m1 # 名称
namespace: default # 命名空间
annotations: # Traefik 注解
traefik.ingress.kubernetes.io/router.entrypoints: websecure # 使用 HTTPS entrypoint
traefik.ingress.kubernetes.io/router.tls.certresolver: cloudflare # ACME certresolver
spec: # Ingress 规则
tls: # TLS 配置
- hosts: # TLS hosts
- test01.jackadam.top # 域名
rules: # HTTP 路由规则
- host: test01.jackadam.top # 域名匹配
http: # HTTP 路由
paths: # 路径列表
- path: / # 匹配根路径
pathType: Prefix # 前缀匹配
backend: # 后端目标
service: # 后端是 Service
name: nginx-m1 # Service 名称
port: # 后端端口
number: 80 # 端口号
---
# 03-02 HTTP-onlyM1 路由(仅 web无 TLS与 nginx-m1 共用 Service
apiVersion: networking.k8s.io/v1 # Ingress API 版本
kind: Ingress # Ingress 资源
metadata: # Ingress 标识
name: nginx-m1-http # HTTP-only Ingress 名称
namespace: default # 命名空间
annotations: # Traefik 注解
traefik.ingress.kubernetes.io/router.entrypoints: web # 使用 HTTP entrypoint
spec: # Ingress 规则
rules: # 规则列表
- host: test01.jackadam.top # 域名
http: # HTTP 路由
paths: # 路径列表
- path: / # 根路径
pathType: Prefix # 前缀匹配
backend: # 后端目标
service: # 后端是 Service
name: nginx-m1 # 共用 Service
port: # 后端端口
number: 80 # 端口号