Files
Deploy-Laboratory/ansible/files/03-02/04-worker-ingressroute.yaml
2026-03-27 16:58:41 +08:00

100 lines
4.1 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: 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 # 后端端口