1
0
Fork 0

Allow publishing services with type ExternalName

This commit is contained in:
James Callahan 2025-10-09 19:18:04 +11:00 committed by GitHub
parent 13bcdebc89
commit cd028267ef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 97 additions and 0 deletions

View file

@ -0,0 +1,83 @@
---
kind: Node
apiVersion: v1
metadata:
name: node1
status:
addresses:
- type: ExternalIP
address: 1.2.3.4
---
kind: Node
apiVersion: v1
metadata:
name: node2
status:
addresses:
- type: ExternalIP
address: 5.6.7.8
---
kind: Service
apiVersion: v1
metadata:
name: published-service
namespace: default
spec:
type: ExternalName
externalName: example.com
---
kind: Ingress
apiVersion: networking.k8s.io/v1
metadata:
name: foo
namespace: default
spec:
rules:
- host: "*.foo.com"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: service1
port:
number: 80
---
kind: Service
apiVersion: v1
metadata:
name: service1
namespace: default
spec:
ports:
- port: 80
clusterIP: 10.0.0.1
---
kind: EndpointSlice
apiVersion: discovery.k8s.io/v1
metadata:
name: service1-abc
labels:
kubernetes.io/service-name: service1
addressType: IPv4
ports:
- port: 8080
name: ""
endpoints:
- addresses:
- 10.10.0.1
conditions:
ready: true

View file

@ -484,6 +484,11 @@ func (p *Provider) updateIngressStatus(ing *netv1.Ingress, k8sClient Client) err
}
}
case corev1.ServiceTypeExternalName:
ingressStatus = []netv1.IngressLoadBalancerIngress{{
Hostname: service.Spec.ExternalName,
}}
default:
return fmt.Errorf("unsupported service type: %s", service.Spec.Type)
}

View file

@ -2298,6 +2298,14 @@ func TestIngressEndpointPublishedService(t *testing.T) {
},
},
},
{
desc: "Published Service ExternalName",
expected: []netv1.IngressLoadBalancerIngress{
{
Hostname: "example.com",
},
},
},
}
for _, test := range testCases {