可参看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