可参看https://blog.csdn.net/weimeibuqieryu/article/details/140798925 搭建ingress

1.创建Ingress对象
ingress-ruoyi.yaml

其中host替换为你对应域名,需要解析域名到服务器, 同时为后端服务添加了二级域名解析 api.

访问http://xxx.xyz/就能访问前端, http://api.xxx.xyz/就能访问后端

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: multi-ingress
  namespace: ruoyi
spec:
  ingressClassName: nginx
  rules:
    - host: xxx.xyz
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: nginx-service
                port:
                  number: 80
    - host: api.xxx.xyz
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: ruoyi-service
                port:
                  number: 8080

2.使用
kubectl apply -f ingress-ruoyi.yaml
3.效果
3.1前端访问

image-20240730160101435

3.2后端访问

image-20240730160504995

Logo

快速构建 Web 应用程序

更多推荐