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

feat: As a user, I want to configure External services using Kubernetes Ingress without CRD's

Open felpasl opened this issue 1 year ago • 3 comments

Description

Be able to do this:

kind: Service
apiVersion: v1
metadata:
  name: external-service
spec:
  type: ExternalName
  externalName: httpbin.org
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: external-ingress
spec:
  ingressClassName: apisix
  rules:
    - http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: external-service
                port:
                  number: 80

for now we got errors on APISix igress controller about

ingress-controller 2024-02-23T01:27:24+08:00    error    translation/translator.go:173    failed to translate ingress backend to upstream    {"error": "endpoints: endpoints \"external-service\" not found", "ingress": "&Ingress{ObjectMeta:{external-ingress  default  8d82feba-b762-4a2a-81f8-0df3d355e497 8453 1 2024-02-23 01:27:19 +0800 HKT <nil> <nil> map] map[kubectl.kubernetes.io/last-applied-configuration:{\"apiVersion\":\"networking.k8s.io/v1\",\"kind\":\"Ingress\",\"metadata\":{\"annotations\":{},\"name\":\"external-ingress\",\"namespace\":\"default\"},\"spec\":{\"ingressClassName\":\"apisix\",\"rules\":[{\"http\":{\"paths\":[{\"backend\":{\"service\":{\"name\":\"external-service\",\"port\":{\"number\":80}}},\"path\":\"/\",\"pathType\":\"Prefix\"}]}}]}}\n] ] ] [{kubectl-client-side-apply Update networking.k8s.io/v1 2024-02-23 01:27:19 +0800 HKT FieldsV1 {\"f:metadata\":{\"f:annotations\":{\".\":{},\"f:kubectl.kubernetes.io/last-applied-configuration\":{}}},\"f:spec\":{\"f:ingressClassName\":{},\"f:rules\":{}}} }]},Spec:IngressSpec{DefaultBackend:nil,TLS:]IngressTLS{},Rules:]IngressRule{IngressRule{Host:,IngressRuleValue:IngressRuleValue{HTTP:&HTTPIngressRuleValue{Paths:]HTTPIngressPath{HTTPIngressPath{Path:/,Backend:IngressBackend{Resource:nil,Service:&IngressServiceBackend{Name:external-service,Port:ServiceBackendPort{Name:,Number:80,},},},PathType:*Prefix,},},},},},},IngressClassName:*apisix,},Status:IngressStatus{LoadBalancer:IngressLoadBalancerStatus{Ingress:]IngressLoadBalancerIngress{},},},}"}
ingress-controller 2024-02-23T01:27:24+08:00    error    ingress/ingress.go:178    failed to translate ingress    {"error": "endpoints: endpoints \"external-service\" not found", "ingress": {"Object":{"metadata":{"name":"external-ingress","namespace":"default","uid":"8d82feba-b762-4a2a-81f8-0df3d355e497","resourceVersion":"8453","generation":1,"creationTimestamp":"2024-02-22T17:27:19Z","annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"networking.k8s.io/v1\",\"kind\":\"Ingress\",\"metadata\":{\"annotations\":{},\"name\":\"external-ingress\",\"namespace\":\"default\"},\"spec\":{\"ingressClassName\":\"apisix\",\"rules\":[{\"http\":{\"paths\":[{\"backend\":{\"service\":{\"name\":\"external-service\",\"port\":{\"number\":80}}},\"path\":\"/\",\"pathType\":\"Prefix\"}]}}]}}\n"},"managedFields":[{"manager":"kubectl-client-side-apply","operation":"Update","apiVersion":"networking.k8s.io/v1","time":"2024-02-22T17:27:19Z","fieldsType":"FieldsV1","fieldsV1":{"f:metadata":{"f:annotations":{".":{},"f:kubectl.kubernetes.io/last-applied-configuration":{}}},"f:spec":{"f:ingressClassName":{},"f:rules":{}}}}]},"spec":{"ingressClassName":"apisix","rules":[{"http":{"paths":[{"path":"/","pathType":"Prefix","backend":{"service":{"name":"external-service","port":{"number":80}}}}]}}]},"status":{"loadBalancer":{}}}}}
ingress-controller 2024-02-23T01:27:24+08:00    warn    ingress/ingress.go:255    sync ingress failed, will retry    {"object": {"Type":1,"Object":{"Key":"default/external-ingress","GroupVersion":"networking/v1","OldObject":null},"OldObject":null,"Tombstone":null}, "error": "endpoints: endpoints \"external-service\" not found"}
ingress-controller 2024-02-23T01:27:24+08:00    error    ingress/ingress.go:502    failed to get APISIX gateway external IPs    {"error": "service \"\" not found"}
Stream closed EOF for ingress-apisix/apisix-ingress-controller-59f456c5c5-rlcfn (wait-apisix-admin)

felpasl avatar Feb 22 '24 17:02 felpasl

Yes, apisix-ingress-controller does not support ingress with external service。But you can use apisixroute and apisixupstream to implement this. Example as follows:

apiVersion: apisix.apache.org/v2
kind: ApisixUpstream
metadata:
  name: external-service
spec:
  externalNodes:
  - type: Domain
    name: httpbin.org
---
apiVersion: apisix.apache.org/v2
kind: ApisixRoute
metadata:
  name: external-ingress
spec:
  http:
  - name: rule1
    match:
      hosts:
      - local.httpbin.org
      paths:
      - /*
    upstreams:
    - name: external-service

bigfish02 avatar Feb 26 '24 12:02 bigfish02

We are not allowed to use CRDs due to company policy for inbound traffic; only Ingress is available

felpasl avatar Mar 06 '24 12:03 felpasl

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 Jun 05 '24 01:06 github-actions[bot]

This issue has been closed due to lack of activity. If you think that is incorrect, or the issue requires additional review, you can revive the issue at any time.

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