wgqkirk commented on issue #2362:
URL:
https://github.com/apache/apisix-ingress-controller/issues/2362#issuecomment-2826913730
> > 你可以自己创建 svc和endpoint
>
> 通过 dashboard 可以直接配置将流量转发到某个 IP,但是通过 apisix router 没看到官方的 demo,试了几个方案都不可行
```python
#创建没有标签选择器的service
apiVersion: v1
kind: Service
metadata:
name: prod-mars-service
namespace: solar-pp
spec:
ports:
- name: http
port: 3667
protocol: TCP
#targetPort: 3667 #目标端口可以不定义,因为我们代理的不是pod,不定义targetPort,其默认等于port
sessionAffinity: None
type: ClusterIP
#创建 endpoint
apiVersion: v1
kind: Endpoints
metadata:
name: prod-mars-service
namespace: solar-pp
subsets:
- addresses:
- ip: 10.13.50.161 #定义外部服务地址
- ip: 10.13.50.158 #定义外部服务地址
ports:
- name: http #端口的name,这个名称一定要与service端口的名称
port: 3667 #外部服务的端口
protocol: TCP
#查看 状态,endpoints 已经绑定上了
#kubectl -n solar-pp describe svc prod-mars-service
Name: prod-mars-service
Namespace: solar-pp
Labels: <none>
Annotations: <none>
Selector: <none>
Type: ClusterIP
IP Families: <none>
IP: 172.31.116.172
IPs: 172.31.116.172
Port: http 3667/TCP
TargetPort: 3667/TCP
Endpoints: 10.13.50.161:3667,10.13.50.158:3667
Session Affinity: None
Events: <none>
#创建 apisix route 绑定到上面的svc
apiVersion: apisix.apache.org/v2
kind: ApisixRoute
metadata:
name: prod-mars-service
namespace: solar-pp
spec:
http:
- backends:
- serviceName: prod-mars-service
servicePort: 3667
match:
paths:
- /mars/*
name: xxxxxxx
priority: 1
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]