1.将请求转发到单个后端服务上
#cat traefik-ingress.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: traefik-web-ui
namespace: c7n-system
spec:
rules:
- host: traefik.maimailoan.cn
http:
paths:
- path: /
backend:
serviceName: traefik-ingress-service
servicePort: 8080
2.将同一个域名不同的URL请求转发到不同的后端服务上(微服务)
#cat traefik-ingress-server.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: choerodon-xiongxj
namespace: c7n-system
spec:
rules:
- host: choerodon.maimailoan.cn
http:
paths:
- path: /api-gateway
backend:
serviceName: api-gateway
servicePort: 8080
- path: /c7n-slaver
backend:
serviceName: c7n-slaver
servicePort: 80
- path: /chartmuseum-chartmuseum
backend:
serviceName: chartmuseum-chartmuseum
servicePort: 8080
3.将不同的域名域名请求转发到后端不同的服务上
#cat traefik-ingress-test.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: choerodon-xiongxj
namespace: c7n-system
spec:
rules:
- host: choerodon.maimailoan.cn
http:
paths:
- path: /api-gateway
backend:
serviceName: api-gateway
servicePort: 8080
- host: harbor.xxj.cn
http:
paths:
- path: /harbor
backend:
serviceName: harbor-ui
servicePort: 80
原文地址:https://blog.51cto.com/whitehat/2382370
时间: 2024-11-06 07:17:37