Files
Deploy-Laboratory/docs/02-02-nginx-control-ingressroute.md
2026-03-21 04:36:06 +08:00

52 lines
1.3 KiB
Markdown
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.
# 02-02 Nginx + 控制节点 + IngressRouteM2
> 场景nginx 指定一台控制节点(`nodeSelector: kubernetes.io/hostname: ylc61`),路由使用 Traefik CRD `IngressRoute`,暴露 `/demo-m2`。整合于 `02-05-nginx-验证矩阵-一键部署.md`。
## 前置条件
- 已完成 `01-02-k3s-工作节点.md`
- Traefik CRD 可用
- 按实际控制节点名(如 ylc61修改 `nodeSelector` 中的 hostname
## 操作步骤
1. 部署 nginx DeploymentnodeSelector 指定控制节点 hostname+ Service
2. 创建 Middleware + IngressRoute`PathPrefix(/demo-m2)`
3. 等待资源就绪
示例 YAML 见 `ansible/files/nginx-matrix/02-control-ingressroute.yaml`
## 部署命令
```bash
kubectl apply -f ansible/files/nginx-matrix/02-control-ingressroute.yaml
```
## 验证命令
```bash
kubectl get pod,svc -n default -o wide
kubectl get ingressroute -n default
curl -i --max-time 3 http://<入口节点IP>/demo-m2/
```
## 预期
- 返回 200页面包含 Welcome to nginx!
- Pod 落在指定控制节点
## 删除
```bash
kubectl delete -f ansible/files/nginx-matrix/02-control-ingressroute.yaml
```
## 失败排查
- 确认 CRD 已存在、Traefik 日志无路由错误
- 参考 `06-01-k3s-networkpolicy-故障排查.md`
## 下一步
- 返回 `02-05-nginx-验证矩阵-一键部署.md``00-00-构建总览.md`