对齐文件规范

This commit is contained in:
2026-03-27 16:58:41 +08:00
parent 231b6713c4
commit 31709425e2
235 changed files with 5433 additions and 2850 deletions

View File

@@ -0,0 +1,116 @@
# 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 # 端口号

View File

@@ -0,0 +1,99 @@
# 03-02 TLS: M2 控制节点 + IngressRoute路径 /(根路径),域名 test02.jackadam.top
---
apiVersion: v1 # ConfigMap 使用的 API 版本
kind: ConfigMap # 配置资源类型ConfigMap
metadata: # ConfigMap 标识信息
name: nginx-m2-html # ConfigMap 名称
namespace: default # 命名空间
data: # ConfigMap 数据区
index.html: | # HTML 内容:挂载到 nginx 网页目录(内部内容行不改动)
<!DOCTYPE html>
<html><head><meta charset="utf-8"><title>M2</title></head>
<body><h1>M2</h1><p>控制节点 + IngressRoute</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 "M2"; try_files $uri $uri/ /index.html; } }
---
apiVersion: apps/v1 # Deployment 使用的 API 版本
kind: Deployment # 工作负载Deployment
metadata: # Deployment 标识信息
name: nginx-m2 # Deployment 名称
namespace: default # 部署命名空间
labels: # 标签
app: nginx-m2 # 应用标签
matrix: "03-02-m2" # 矩阵编号标签
spec: # Deployment 期望状态
replicas: 1 # 副本数
selector: # 选择器
matchLabels: # 标签匹配集合(用于选中模板 Pod
app: nginx-m2 # 必须与 template.labels 对齐
template: # Pod 模板
metadata: # Pod 元信息
labels: # Pod 标签
app: nginx-m2 # Pod 标签
spec: # Pod 规范
nodeSelector: # 固定到指定主机
kubernetes.io/hostname: ylc61 # 控制节点主机名
volumes: # 卷定义
- name: html # 卷名
configMap: # 卷来源
name: nginx-m2-html # ConfigMap 名称
containers: # 容器列表
- name: nginx # 容器名
image: nginx:alpine # nginx 镜像
ports: # 容器端口
- containerPort: 80 # 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-m2 # Service 名称
namespace: default # 命名空间
spec: # Service 期望状态
selector: # Service 选择器
app: nginx-m2 # 选中后端 Pod
ports: # Service 端口
- port: 80 # Service 端口
targetPort: 80 # 转发端口
---
apiVersion: traefik.io/v1alpha1 # IngressRoute API 版本
kind: IngressRoute # Traefik 路由 CRD
metadata: # IngressRoute 标识
name: nginx-m2 # 资源名称
namespace: default # 命名空间
spec: # 规则
entryPoints: # 入口点
- websecure # 使用 HTTPS entrypoint
routes: # 路由列表
- match: Host(`test02.jackadam.top`) # 域名匹配
kind: Rule # 规则类型
services: # 后端服务
- name: nginx-m2 # 后端 Service
port: 80 # 后端端口
tls: # TLS 配置
certResolver: cloudflare # 使用 cloudflare certResolver
---
# 03-02 HTTP-onlyM2 路由(仅 web无 TLS与 nginx-m2 共用 Service
apiVersion: traefik.io/v1alpha1 # IngressRoute API 版本
kind: IngressRoute # Traefik 路由资源
metadata: # 标识
name: nginx-m2-http # 名称
namespace: default # 命名空间
spec: # 规则
entryPoints: # 入口点列表
- web # 使用 HTTP entrypoint
routes: # 路由列表
- match: Host(`test02.jackadam.top`) # 域名匹配
kind: Rule # 规则类型
services: # 后端服务
- name: nginx-m2 # 后端 Service
port: 80 # 端口

View File

@@ -0,0 +1,111 @@
# 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 # 端口号

View File

@@ -0,0 +1,99 @@
# 03-02 TLS: M4 工作节点 + IngressRoute路径 /(根路径),域名 test04.jackadam.top
---
apiVersion: v1 # ConfigMap 使用的 API 版本
kind: ConfigMap # 配置资源类型ConfigMap
metadata: # 标识信息
name: nginx-m4-html # ConfigMap 名称
namespace: default # 命名空间
data: # ConfigMap 数据区
index.html: | # HTML 内容:挂载到 nginx 网页目录(内部内容行不改动)
<!DOCTYPE html>
<html><head><meta charset="utf-8"><title>M4</title></head>
<body><h1>M4</h1><p>工作节点 + IngressRoute</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 "M4"; try_files $uri $uri/ /index.html; } }
---
apiVersion: apps/v1 # Deployment 使用的 API 版本
kind: Deployment # 工作负载Deployment
metadata: # Deployment 标识信息
name: nginx-m4 # Deployment 名称
namespace: default # 部署命名空间
labels: # 额外标签
app: nginx-m4 # 应用标签
matrix: "03-02-m4" # 矩阵编号标签
spec: # Deployment 期望状态
replicas: 1 # 副本数
selector: # Deployment 选择器
matchLabels: # 必须与 template.metadata.labels 对齐
app: nginx-m4 # 选中 app 标签为 nginx-m4 的 Pod
template: # Pod 模板
metadata: # Pod 元信息
labels: # Pod 标签
app: nginx-m4 # Pod 标签
spec: # Pod 规范
nodeSelector: # 固定跑到指定工作节点(按实际 ylc64/主机名)
kubernetes.io/hostname: ylc64 # 目标节点主机名
volumes: # 卷定义
- name: html # 卷名(给 volumeMounts 引用)
configMap: # 卷来源为 ConfigMap
name: nginx-m4-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-m4 # Service 名称
namespace: default # 命名空间
spec: # Service 期望状态
selector: # Service 选择器
app: nginx-m4 # 选中 app 标签为 nginx-m4 的 Pod
ports: # 端口映射列表
- port: 80 # Service 暴露端口
targetPort: 80 # 转发到 Pod 容器端口
---
apiVersion: traefik.io/v1alpha1 # IngressRoute API 版本
kind: IngressRoute # Traefik 路由资源类型
metadata: # 标识信息
name: nginx-m4 # IngressRoute 名称
namespace: default # 命名空间
spec: # 规则与 TLS
entryPoints: # Traefik entrypoints
- websecure # HTTPS entrypoint
routes: # 路由列表
- match: Host(`test04.jackadam.top`) # 域名匹配
kind: Rule # 规则类型
services: # 后端服务列表
- name: nginx-m4 # 后端 Service 名称
port: 80 # 后端端口
tls: # TLS 配置
certResolver: cloudflare # 使用 cloudflare 证书解析器
---
# 03-02 HTTP-onlyM4 路由(仅 web无 TLS与 nginx-m4 共用 Service
apiVersion: traefik.io/v1alpha1 # IngressRoute API 版本
kind: IngressRoute # Traefik 路由资源类型
metadata: # 标识信息
name: nginx-m4-http # HTTP-only 路由名
namespace: default # 命名空间
spec: # 规则
entryPoints: # HTTP entrypoint
- web # webHTTP
routes: # 路由列表
- match: Host(`test04.jackadam.top`) # 域名匹配
kind: Rule # 规则类型
services: # 后端服务
- name: nginx-m4 # 后端 Service 名称
port: 80 # 后端端口

View File

@@ -0,0 +1,41 @@
# 03-02 Traefik ACME 配置HelmChartConfig
# 含ACMECloudflare DNS-01、ping 健康检查websecure、PROXY protocol trustedIPs
# 使用前:替换 <YOUR_REAL_EMAIL>,创建 cloudflare-api-token Secret按实际修改 nodeSelector/trustedIPs
# 部署kubectl apply -f traefik-acme.yaml或复制到 K3s manifests 目录)
#
# 推荐Dashboard + ACME + local-path 一份清单):见 ../traefik-dashboard-acme/traefik-dashboard-acme.yaml
---
apiVersion: helm.cattle.io/v1 # HelmChartConfig 所在的 API 版本
kind: HelmChartConfig # HelmChartConfig给 K3s 自带 Helm chart 注入 values 的资源
metadata: # 该对象的标识信息
name: traefik # chart 对应的对象名称(通常与 Traefik chart name 一致)
namespace: kube-system # HelmChartConfig 的命名空间Traefik 默认在 kube-system
spec: # chart 注入配置的具体内容
valuesContent: |- # 以“字符串形式的 YAML”注入到 Helm chart values由 chart 解析)
additionalArguments: # 追加给 Traefik 的额外启动参数列表
- "--log.level=INFO" # 日志级别INFO
- "--certificatesresolvers.cloudflare.acme.dnschallenge.resolvers=1.1.1.1:53,1.0.0.1:53" # DNS resolver 列表
- "--certificatesresolvers.cloudflare.acme.email=<YOUR_REAL_EMAIL>" # ACME 注册邮箱
- "--certificatesresolvers.cloudflare.acme.storage=/data/acme.json" # ACME 存储(容器内路径)
# - "--certificatesresolvers.cloudflare.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory" # 测试用,上线前删除
- "--certificatesresolvers.cloudflare.acme.dnschallenge.provider=cloudflare" # 使用 Cloudflare 作为 DNS-01 provider
- "--certificatesresolvers.cloudflare.acme.dnschallenge.propagation.delayBeforeChecks=600" # DNS propagation 等待时间(秒)
# 健康检查GET /ping 在 443(HTTPS) 返回 200供 HAProxy 对 443 做 option httpchk + ssl
- "--ping=true" # 开启 ping healthcheck
- "--ping.entryPoint=websecure" # ping 走 websecure(HTTPS) entrypoint
# PROXY protocoltrustedIPs 需包含 HAProxy 所在 IP/网段
- "--entrypoints.web.proxyProtocol.trustedIPs=192.168.2.0/24" # HTTP entrypoint 信任的代理网段
- "--entrypoints.websecure.proxyProtocol.trustedIPs=192.168.2.0/24" # HTTPS entrypoint 信任的代理网段
env: # 环境变量注入(给 Traefik chart
- name: CF_DNS_API_TOKEN # Cloudflare API Token 环境变量名
valueFrom: # 从 Secret 中读取环境变量值
secretKeyRef: # Secret 引用方式:按 key 取值
name: cloudflare-api-token # Secret 名称(你创建的 Cloudflare Token Secret
key: api-token # Secret 内对应的 key 名
nodeSelector: # 把 Traefik Pod 固定到指定节点(配合 RWO 本地存储更安全)
kubernetes.io/hostname: ylc61 # 固定节点主机名(按你的实际节点修改)