Files
Deploy-Laboratory/ansible/files/nginx-matrix-tls/03-worker-ingress.yaml
jack be97836e0d chore: 清理调试脚本并收敛到 Ansible 流程
移除已废弃的调试/验证脚本与空目录,统一文档与脚本说明到 ansible-playbook 的部署方式,避免失效引用和误用路径。

Made-with: Cursor
2026-03-23 19:18:55 +08:00

111 lines
4.7 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: M3 工作节点 + Ingress路径 /(根路径),域名 test03.jackadam.top
---
apiVersion: v1 # ConfigMap 使用的 API 版本
kind: ConfigMap # 配置资源类型ConfigMap
metadata: # 资源标识
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 配置:挂载到 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: "03-02-m3" # 矩阵编号标签
spec: # Deployment 期望状态
replicas: 1 # 副本数
selector: # Deployment 选择器:匹配 Pod
matchLabels: # 标签匹配集合
app: nginx-m3 # 选中 app 标签为 nginx-m3 的 Pod
template: # Pod 模板
metadata: # Pod 元信息
labels: # Pod 标签
app: nginx-m3 # 与 selector.matchLabels 对齐
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 # 引用同一个卷
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 # Service 资源
metadata: # Service 标识
name: nginx-m3 # Service 名称
namespace: default # 命名空间
spec: # Service 期望状态
selector: # 通过标签选中后端 Pod
app: nginx-m3 # 选中 app 标签为 nginx-m3 的 Pod
ports: # 端口映射
- port: 80 # Service 暴露端口
targetPort: 80 # 转发到容器端口
---
apiVersion: networking.k8s.io/v1 # Ingress 使用的 API 版本
kind: Ingress # Ingress 资源
metadata: # Ingress 标识
name: nginx-m3 # Ingress 名称
namespace: default # 命名空间
annotations: # Traefik 路由注解
traefik.ingress.kubernetes.io/router.entrypoints: websecure # 使用 HTTPS entrypoint
traefik.ingress.kubernetes.io/router.tls.certresolver: cloudflare # 证书解析器
spec: # Ingress 规则
tls: # TLS 配置
- hosts: # TLS 证书适用的域名列表
- test03.jackadam.top # 域名
rules: # HTTP/HTTPS 路由规则列表
- host: test03.jackadam.top # 匹配域名
http: # HTTP 规则
paths: # 路径匹配列表
- path: / # 根路径
pathType: Prefix # 前缀匹配
backend: # 后端目标
service: # 使用 Service
name: nginx-m3 # 后端 Service 名称
port: # 后端端口
number: 80 # 端口号
---
# 03-02 HTTP-onlyM3 路由(仅 web无 TLS与 nginx-m3 共用 Service
apiVersion: networking.k8s.io/v1 # Ingress 使用的 API 版本
kind: Ingress # Ingress 资源
metadata: # Ingress 标识
name: nginx-m3-http # HTTP-only Ingress 名称
namespace: default # 命名空间
annotations: # Traefik 路由注解
traefik.ingress.kubernetes.io/router.entrypoints: web # 使用 HTTP entrypoint
spec: # Ingress 规则
rules: # 规则列表
- host: test03.jackadam.top # 域名
http: # HTTP 规则
paths: # 路径列表
- path: / # 根路径
pathType: Prefix # 前缀匹配
backend: # 后端目标
service: # 后端 Service
name: nginx-m3 # 后端 Service 名称
port: # 后端端口
number: 80 # 端口号