quocthinhle opened a new issue, #2198:
URL: https://github.com/apache/apisix-ingress-controller/issues/2198

   ### Issue description
   
   Hi team, 
   I followed this documentation to add the "custom-response" plugin to APISIX: 
https://apisix.apache.org/docs/ingress-controller/next/tutorials/using-custom-plugins.
   
   - Span a httpbin service
   ```
   kubectl run httpbin --image kennethreitz/httpbin --port 80
   kubectl expose pod httpbin --port 80
   ```
   
   - The plugin I use is custom-response.lua in the tutourial.
   
   ```values.yaml
     customPlugins:
       enabled: true
       luaPath: "/opt/?.lua"
       plugins:
         - name: "custom-response"
           attrs: {}
           configMap:
             name: "custom-response-config"
             mounts:
               - key: "custom-response.lua"
                 path: "/opt/apisix/plugins/custom-response.lua"
               - key: "custom-response.lua"
                 path: "/usr/local/apisix/apisix/plugins/custom-response.lua"
               
    plugins:
       - custom_response
   ```
   
   ```route.yaml
   apiVersion: apisix.apache.org/v2
   kind: ApisixRoute
   metadata:
     name: api-route
   spec:
     http:
       - name: route
         match:
           hosts:
             - local.navendu.me
           paths:
             - /api
         backends:
           - serviceName: bare-minimum-api
             servicePort: 8080
         plugins:
           - name: custom-response
             enable: true
             config:
               body: "Hello from your custom Plugin!"
   ```
   
   -- Install 
   ```
   helm install apisix apisix/apisix -n ingress-apisix --values 
./apisix/values.yaml
   ```
   
   The trace log of apisix-ingress:
   ```
   12:24+08:00       error   apisix/apisix_route.go:379      failed to sync 
ApisixRoute to apisix    {"error": "1 error occurred:\n\t* unexpected status 
code 400; error message: {\"error_msg\":\"unknown plugin 
[custom-response]\"}\n\n\n"}
   2024-03-31T21:12:24+08:00       warn    apisix/apisix_route.go:481      sync 
ApisixRoute failed, will retry     {"object": 
{"Type":1,"Object":{"Key":"default/api-route","OldObject":null,"GroupVersion":"apisix.apache.org/v2"},"OldObject":null,"Tombstone":null},
 "error": "1 error occurred:\n\t* unexpected status code 400; error message: 
{\"error_msg\":\"unknown plugin [custom-response]\"}\n\n\n"}
   2024-03-31T21:13:24+08:00       error   translation/translator.go:173   
failed to translate ingress backend to upstream {"error": "service.spec.ports: 
port not defined", "ingress": "&Ingress{ObjectMeta:{api-routes  default  
84f4ef01-9ccb-48d0-acda-c7ea1acd4550 68408 1 2024-03-29 00:12:16 +0800 HKT 
<nil> <nil> map[] 
map[kubectl.kubernetes.io/last-applied-configuration:{\"apiVersion\":\"networking.k8s.io/v1\",\"kind\":\"Ingress\",\"metadata\":{\"annotations\":{},\"name\":\"api-routes\",\"namespace\":\"default\"},\"spec\":{\"ingressClassName\":\"apisix\",\"rules\":[{\"host\":\"lqt12.wiki\",\"http\":{\"paths\":[{\"backend\":{\"service\":{\"name\":\"order-service\",\"port\":{\"number\":80}}},\"path\":\"/order\",\"pathType\":\"Exact\"},{\"backend\":{\"service\":{\"name\":\"ship-service\",\"port\":{\"number\":81}}},\"path\":\"/ship\",\"pathType\":\"Exact\"}]}}]}}\n]
 [] [] [{kubectl-client-side-apply Update networking.k8s.io/v1 2024-03-29 
00:12:16 +0800 HKT FieldsV1 {\"f:metadata\":{\"f:a
 
nnotations\":{\".\":{},\"f:kubectl.kubernetes.io/last-applied-configuration\":{}}},\"f:spec\":{\"f:ingressClassName\":{},\"f:rules\":{}}}
 
}]},Spec:IngressSpec{DefaultBackend:nil,TLS:[]IngressTLS{},Rules:[]IngressRule{IngressRule{Host:lqt12.wiki,IngressRuleValue:IngressRuleValue{HTTP:&HTTPIngressRuleValue{Paths:[]HTTPIngressPath{HTTPIngressPath{Path:/order,Backend:IngressBackend{Resource:nil,Service:&IngressServiceBackend{Name:order-service,Port:ServiceBackendPort{Name:,Number:80,},},},PathType:*Exact,},HTTPIngressPath{Path:/ship,Backend:IngressBackend{Resource:nil,Service:&IngressServiceBackend{Name:ship-service,Port:ServiceBackendPort{Name:,Number:81,},},},PathType:*Exact,},},},},},},IngressClassName:*apisix,},Status:IngressStatus{LoadBalancer:IngressLoadBalancerStatus{Ingress:[]IngressLoadBalancerIngress{},},},}"}
   2024-03-31T21:13:24+08:00       error   ingress/ingress.go:178  failed to 
translate ingress     {"error": "service.spec.ports: port not defined", 
"ingress": 
{"Object":{"metadata":{"name":"api-routes","namespace":"default","uid":"84f4ef01-9ccb-48d0-acda-c7ea1acd4550","resourceVersion":"68408","generation":1,"creationTimestamp":"2024-03-28T16:12:16Z","annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"networking.k8s.io/v1\",\"kind\":\"Ingress\",\"metadata\":{\"annotations\":{},\"name\":\"api-routes\",\"namespace\":\"default\"},\"spec\":{\"ingressClassName\":\"apisix\",\"rules\":[{\"host\":\"lqt12.wiki\",\"http\":{\"paths\":[{\"backend\":{\"service\":{\"name\":\"order-service\",\"port\":{\"number\":80}}},\"path\":\"/order\",\"pathType\":\"Exact\"},{\"backend\":{\"service\":{\"name\":\"ship-service\",\"port\":{\"number\":81}}},\"path\":\"/ship\",\"pathType\":\"Exact\"}]}}]}}\n"},"managedFields":[{"manager":"kubectl-client-side-apply","operation":"Updat
 
e","apiVersion":"networking.k8s.io/v1","time":"2024-03-28T16:12:16Z","fieldsType":"FieldsV1","fieldsV1":{"f:metadata":{"f:annotations":{".":{},"f:kubectl.kubernetes.io/last-applied-configuration":{}}},"f:spec":{"f:ingressClassName":{},"f:rules":{}}}}]},"spec":{"ingressClassName":"apisix","rules":[{"host":"lqt12.wiki","http":{"paths":[{"path":"/order","pathType":"Exact","backend":{"service":{"name":"order-service","port":{"number":80}}}},{"path":"/ship","pathType":"Exact","backend":{"service":{"name":"ship-service","port":{"number":81}}}}]}}]},"status":{"loadBalancer":{}}}}}
   2024-03-31T21:13:24+08:00       warn    ingress/ingress.go:255  sync ingress 
failed, will retry {"object": 
{"Type":1,"Object":{"Key":"default/api-routes","GroupVersion":"networking/v1","OldObject":null},"OldObject":null,"Tombstone":null},
 "error": "service.spec.ports: port not defined"}
   2024-03-31T21:13:24+08:00       error   ingress/ingress.go:502  failed to 
get APISIX gateway external IPs       {"error": "service \"\" not found"}
   2024-03-31T21:13:24+08:00       error   apisix/route.go:138     failed to 
create route: unexpected status code 400; error message: {"error_msg":"unknown 
plugin [custom-response]"}
   
   2024-03-31T21:13:24+08:00       error   apisix/apisix_route.go:379      
failed to sync ApisixRoute to apisix    {"error": "1 error occurred:\n\t* 
unexpected status code 400; error message: {\"error_msg\":\"unknown plugin 
[custom-response]\"}\n\n\n"}
   2024-03-31T21:13:24+08:00       warn    apisix/apisix_route.go:481      sync 
ApisixRoute failed, will retry     {"object": 
{"Type":1,"Object":{"Key":"default/api-route","OldObject":null,"GroupVersion":"apisix.apache.org/v2"},"OldObject":null,"Tombstone":null},
 "error": "1 error occurred:\n\t* unexpected status code 400; error message: 
{\"error_msg\":\"unknown plugin [custom-response]\"}\n\n\n"}
   ```
   
   ### Environment
   
   - APISIX: 3.2.0-debian
   - Minikube v1.32.0
   - Helm: version.BuildInfo{Version:"v3.14.3", 
GitCommit:"f03cc04caaa8f6d7c3e67cf918929150cf6f3f12", GitTreeState:"clean", 
GoVersion:"go1.22.1"}
   - Kubectl: Server Version: v1.28.3
   


-- 
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]

Reply via email to