mirror of
https://github.com/eliasstepanik/caddy-ingess.git
synced 2026-01-10 20:18:28 +00:00
Take into account that the ClusterIP can be "None" (#114)
This commit is contained in:
parent
9415b5cb00
commit
3b5306d578
@ -58,18 +58,18 @@ func GetAddressFromService(service *apiv1.Service) string {
|
||||
switch service.Spec.Type {
|
||||
case apiv1.ServiceTypeNodePort:
|
||||
case apiv1.ServiceTypeClusterIP:
|
||||
return service.Spec.ClusterIP
|
||||
if service.Spec.ClusterIP != apiv1.ClusterIPNone {
|
||||
return service.Spec.ClusterIP
|
||||
}
|
||||
case apiv1.ServiceTypeExternalName:
|
||||
return service.Spec.ExternalName
|
||||
case apiv1.ServiceTypeLoadBalancer:
|
||||
{
|
||||
if len(service.Status.LoadBalancer.Ingress) > 0 {
|
||||
ingress := service.Status.LoadBalancer.Ingress[0]
|
||||
if ingress.Hostname != "" {
|
||||
return ingress.Hostname
|
||||
}
|
||||
return ingress.IP
|
||||
if len(service.Status.LoadBalancer.Ingress) > 0 {
|
||||
ingress := service.Status.LoadBalancer.Ingress[0]
|
||||
if ingress.Hostname != "" {
|
||||
return ingress.Hostname
|
||||
}
|
||||
return ingress.IP
|
||||
}
|
||||
}
|
||||
return ""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user