apisix-ingress-controller
apisix-ingress-controller copied to clipboard
request help: error when ingress_publish_service is null
Issue description
I update our ingress controller to 1.5.0-rc1 right now, and met a strange error
{"level":"error","time":"2022-08-31T18:58:37.882741632+08:00","caller":"ingress/status.go:280","message":"failed to get APISIX gateway external IPs","error":"resource name may not be empty"}
I trace the error and found if ingress_publish_service is "" in the config, the code in IngressPublishAddresses
will analyze namespace and name to "", so it will cause "resource name may not be empty"
func IngressPublishAddresses(ingressPublishService string, ingressStatusAddress []string, kubeClient kubernetes.Interface) ([]string, error) {
addrs := []string{}
// if ingressStatusAddress is specified, it will be used first
if len(ingressStatusAddress) > 0 {
addrs = append(addrs, ingressStatusAddress...)
return addrs, nil
}
namespace, name, err := cache.SplitMetaNamespaceKey(ingressPublishService)
if err != nil {
log.Errorf("invalid ingressPublishService %s: %s", ingressPublishService, err)
return nil, err
}
svc, err := kubeClient.CoreV1().Services(namespace).Get(context.TODO(), name, metav1.GetOptions{})
if err != nil {
return nil, err
}
switch svc.Spec.Type {
case apiv1.ServiceTypeLoadBalancer:
if len(svc.Status.LoadBalancer.Ingress) < 1 {
return addrs, fmt.Errorf("%s", _gatewayLBNotReadyMessage)
}
for _, ip := range svc.Status.LoadBalancer.Ingress {
if ip.IP == "" {
// typically AWS load-balancers
addrs = append(addrs, ip.Hostname)
} else {
addrs = append(addrs, ip.IP)
}
}
addrs = append(addrs, svc.Spec.ExternalIPs...)
return addrs, nil
default:
return addrs, nil
}
}
Is this a bug?
Environment
- your apisix-ingress-controller version (output of apisix-ingress-controller version --long): 1.5.0-rc1
- your Kubernetes cluster version (output of kubectl version):
- if you run apisix-ingress-controller in Bare-metal environment, also show your OS version (uname -a):
thanks,it's expected behavior
thanks,it's expected behavior
So that means we MUST set "ingress_publish_service" ?
Is it must set apisix gateway's namespace and svc name? apisix gateway's namespace is not the same to biz's namespace.
thanks,it's expected behavior
So that means we MUST set "ingress_publish_service" ?
Not required. But it is recommended to set.
Some platforms display Ingress status and other information based on this information (e.g. rancher
Is it must set apisix gateway's namespace and svc name?
apisix gateway's namespace is not the same to biz's namespace.
please refer to https://github.com/apache/apisix-ingress-controller/blob/master/conf/config-default.yaml
thanks,it's expected behavior
So that means we MUST set "ingress_publish_service" ?
Not required. But it is recommended to set.
Some platforms display Ingress status and other information based on this information (e.g. rancher
But if we did not set this value, it will continuously output error
So what is the solution when do I need to set it and to what value?
just change this
https://github.com/apache/apisix-ingress-controller/blob/38b12fb4a5a2169eb3585e5b7e2f78c8ce447862/conf/config-default.yaml#L40-L49
If your cluster has LoadBalancer, you can set ingress_publish_service
otherwise, use theingress_status_address
Alright, I set the ingress_status_adress to the IP of my node, but I still can not reach the ingress from my host.
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.
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.