Allow publishing services with type ExternalName
This commit is contained in:
parent
13bcdebc89
commit
cd028267ef
4 changed files with 97 additions and 0 deletions
|
|
@ -116,6 +116,7 @@ depending on the service type:
|
|||
- **ClusterIP:** The ExternalIPs of the service will be propagated to the ingress status.
|
||||
- **NodePort:** The ExternalIP addresses of the nodes in the cluster will be propagated to the ingress status.
|
||||
- **LoadBalancer:** The IPs from the service's `loadBalancer.status` field (which contains the endpoints provided by the load balancer) will be propagated to the ingress status.
|
||||
- **ExternalName:** The hostname from the service's `spec.externalName` field will be propagated to the ingress status.
|
||||
|
||||
When using third-party tools such as External-DNS, this option enables the copying of external service IPs to the ingress resources.
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2298,6 +2298,14 @@ func TestIngressEndpointPublishedService(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "Published Service ExternalName",
|
||||
expected: []netv1.IngressLoadBalancerIngress{
|
||||
{
|
||||
Hostname: "example.com",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue