Files
Deploy-Laboratory/docs/02-04-nginx-worker-ingressroute.md
2026-03-27 16:58:41 +08:00

68 lines
1.9 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-04 Nginx + 工作节点 + IngressRouteM4
> 场景nginx 指定落在 ylc64`nodeSelector: kubernetes.io/hostname: ylc64`),跨节点 IngressRoute 暴露 `/demo-m4`。整合于 `02-05-nginx-验证矩阵-一键部署.md`。
## TL;DR
- **自动化验收**`./scripts/verify.sh run 02-04`
- **关键前置**:按本文「前置条件」准备环境变量/Secret/入口 IP
- **成功判据**:达到本文「预期」且 playbook 断言通过
- **排障**:见本文「排障」
## 前置条件
- 已完成 `01-02-k3s-工作节点.md`
- Traefik CRD 可用
- 工作节点网络连通
- 按实际工作节点名(如 ylc64修改 `nodeSelector` 中的 hostname
## 操作步骤
1. 部署 nginx DeploymentnodeSelector 指定工作节点 hostname+ Service
2. 创建 Middleware + IngressRoute`PathPrefix(/demo-m4)`
3. 等待资源就绪
示例 YAML 见 `ansible/files/02-05/04-worker-ingressroute.yaml`
## 部署命令
```bash
kubectl apply -f ansible/files/02-05/04-worker-ingressroute.yaml
```
## 验证命令
```bash
kubectl get pod,svc -n default -o wide
kubectl get ingressroute -n default
curl -i --max-time 3 http://<入口节点IP>/demo-m4/
```
## 预期
- 返回 200页面包含 Welcome to nginx!
- Pod 落在指定工作节点
## 删除
```bash
kubectl delete -f ansible/files/02-05/04-worker-ingressroute.yaml
```
## 失败排查
- 优先看 Traefik 日志
- 检查节点间网络转发、firewalld 基线
- 参考 `06-01-k3s-networkpolicy-故障排查.md`
## 下一步
- 返回 `02-05-nginx-验证矩阵-一键部署.md``00-00-构建总览.md`
## 排障
- **先看 playbook 输出**:失败时先定位是 deploy/wait/http_check 哪一步。
- **集群侧总览**`kubectl get nodes -o wide``kubectl -n kube-system get pods -o wide`
- **事件与日志**`kubectl -n <ns> describe ...``kubectl -n <ns> logs ... --tail=200`