Kubernetes ingress provider to search via all endpoints
This commit is contained in:
parent
be81ce244e
commit
5814ba5322
5 changed files with 88 additions and 1 deletions
|
@ -0,0 +1,21 @@
|
|||
apiVersion: v1
|
||||
kind: Endpoints
|
||||
metadata:
|
||||
name: service1
|
||||
namespace: testing
|
||||
subsets:
|
||||
- addresses:
|
||||
- ip: 10.0.0.1
|
||||
nodeName: admin.whoami.service1
|
||||
ports:
|
||||
- name: http-admin
|
||||
port: 8079
|
||||
protocol: TCP
|
||||
- addresses:
|
||||
- ip: 10.0.0.1
|
||||
nodeName: whoami.service1
|
||||
# targetRef:
|
||||
ports:
|
||||
- name: http
|
||||
port: 8080
|
||||
protocol: TCP
|
|
@ -0,0 +1,15 @@
|
|||
kind: Ingress
|
||||
apiVersion: networking.k8s.io/v1beta1
|
||||
metadata:
|
||||
name: ""
|
||||
namespace: testing
|
||||
|
||||
spec:
|
||||
rules:
|
||||
- host: traefik.port
|
||||
http:
|
||||
paths:
|
||||
- path: /port
|
||||
backend:
|
||||
serviceName: service1
|
||||
servicePort: 8080
|
|
@ -0,0 +1,20 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: service1
|
||||
namespace: testing
|
||||
|
||||
spec:
|
||||
ports:
|
||||
- name: http
|
||||
port: 8080
|
||||
protocol: TCP
|
||||
targetPort: http-api
|
||||
- name: http-admin
|
||||
port: 8079
|
||||
protocol: TCP
|
||||
targetPort: http-admin
|
||||
selector:
|
||||
app: foo
|
||||
sessionAffinity: None
|
||||
type: ClusterIP
|
|
@ -539,7 +539,7 @@ func loadService(client Client, namespace string, backend networkingv1beta1.Ingr
|
|||
}
|
||||
|
||||
if port == 0 {
|
||||
return nil, errors.New("cannot define a port")
|
||||
continue
|
||||
}
|
||||
|
||||
protocol := getProtocol(portSpec, portName, svcConfig)
|
||||
|
@ -553,6 +553,10 @@ func loadService(client Client, namespace string, backend networkingv1beta1.Ingr
|
|||
}
|
||||
}
|
||||
|
||||
if len(svc.LoadBalancer.Servers) == 0 {
|
||||
return nil, errors.New("no valid subset found")
|
||||
}
|
||||
|
||||
return svc, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -729,6 +729,33 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "Ingress with port invalid for one service",
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-traefik-port-port": {
|
||||
Rule: "Host(`traefik.port`) && PathPrefix(`/port`)",
|
||||
Service: "testing-service1-8080",
|
||||
},
|
||||
},
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing-service1-8080": {
|
||||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
PassHostHeader: Bool(true),
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.0.0.1:8080",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "Ingress with IPv6 endpoints",
|
||||
expected: &dynamic.Configuration{
|
||||
|
|
Loading…
Reference in a new issue