apisix-ingress-controller icon indicating copy to clipboard operation
apisix-ingress-controller copied to clipboard

request help: how to forward traffic to custom nodes with static ip

Open cataglyphis opened this issue 10 months ago • 6 comments

Issue description

  • deploy service in ECS nodes out of K8s
  • deploy apisix and apisix route in k8s
  • forward traffic to service
apiVersion: apisix.apache.org/v2
kind: ApisixUpstream
metadata:
  name: automq
  namespace: automq
spec:
  scheme: http
  loadbalancer:
    type: roundrobin
  timeout:
    connect: 6s
    read: 6s
    send: 6s
  passHost: node
  nodes:
    - host: 10.110.0.3
      port: 8080
      weight: 1
---
apiVersion: apisix.apache.org/v2
kind: ApisixRoute
metadata:
  name: automq
  namespace: automq
spec:
  http:
    - name: automq-http
      match:
        hosts:
          - xxx.org
        paths:
          - /*
      websocket: false
      upstreams:
        - name: automq
          weight: 100

Environment

  • your apisix-ingress-controller version (output of apisix-ingress-controller version --long): 1.8.3
  • your Kubernetes cluster version (output of kubectl version): 1.26
  • if you run apisix-ingress-controller in Bare-metal environment, also show your OS version (uname -a):

cataglyphis avatar Mar 03 '25 07:03 cataglyphis

any comment?

cataglyphis avatar Mar 21 '25 02:03 cataglyphis

any comment?

cataglyphis avatar Apr 02 '25 04:04 cataglyphis

你可以自己创建 svc和endpoint

wgqkirk avatar Apr 03 '25 04:04 wgqkirk

你可以自己创建 svc和endpoint

通过 dashboard 可以直接配置将流量转发到某个 IP,但是通过 apisix router 没看到官方的 demo,试了几个方案都不可行

cataglyphis avatar Apr 24 '25 08:04 cataglyphis

How to defined upstream likes below with CRD?


curl http://127.0.0.1:9180/apisix/admin/routes/1
-H "X-API-KEY: $admin_key" -X PUT -d ' { "uri": "/hash_on_cookie", "upstream": { "key": "sid", "type": "chash", "hash_on": "cookie", "nodes": { "127.0.0.1:1980": 1, "127.0.0.1:1981": 1 } } }'

cataglyphis avatar Apr 24 '25 08:04 cataglyphis

你可以自己创建 svc和endpoint

通过 dashboard 可以直接配置将流量转发到某个 IP,但是通过 apisix router 没看到官方的 demo,试了几个方案都不可行


#创建没有标签选择器的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

wgqkirk avatar Apr 24 '25 09:04 wgqkirk

This issue has been marked as stale due to 90 days of inactivity. It will be closed in 30 days if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the [email protected] list. Thank you for your contributions.

github-actions[bot] avatar Jul 24 '25 01:07 github-actions[bot]

Hi @cataglyphis, is this issue resolved?

Baoyuantop avatar Aug 08 '25 06:08 Baoyuantop

If there is still a problem, please open it again.

Baoyuantop avatar Aug 19 '25 08:08 Baoyuantop