Fix Kubernetes schema
Signed-off-by: Emile Vauge <emile@vauge.com>
This commit is contained in:
parent
4ff4e4e626
commit
87caf458df
4 changed files with 14 additions and 21 deletions
|
@ -12,7 +12,7 @@ spec:
|
||||||
nodePort: 30283
|
nodePort: 30283
|
||||||
targetPort: 80
|
targetPort: 80
|
||||||
protocol: TCP
|
protocol: TCP
|
||||||
name: http
|
name: https
|
||||||
selector:
|
selector:
|
||||||
app: whoami
|
app: whoami
|
||||||
---
|
---
|
||||||
|
|
|
@ -235,15 +235,6 @@ func (c *clientImpl) watch(url string, stopCh <-chan bool) (chan interface{}, ch
|
||||||
url = url + "?watch&resourceVersion=" + resourceVersion
|
url = url + "?watch&resourceVersion=" + resourceVersion
|
||||||
// Make request to Kubernetes API
|
// Make request to Kubernetes API
|
||||||
request := c.request(url)
|
request := c.request(url)
|
||||||
// request.Transport.Dial = func(network, addr string) (net.Conn, error) {
|
|
||||||
// conn, err := net.Dial(network, addr)
|
|
||||||
// if err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
// // No timeout for long-polling request
|
|
||||||
// conn.SetDeadline(time.Now())
|
|
||||||
// return conn, nil
|
|
||||||
// }
|
|
||||||
req, err := request.MakeRequest()
|
req, err := request.MakeRequest()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return watchCh, errCh, fmt.Errorf("failed to make watch request: GET %q : %v", url, err)
|
return watchCh, errCh, fmt.Errorf("failed to make watch request: GET %q : %v", url, err)
|
||||||
|
|
|
@ -170,10 +170,12 @@ func (provider *Kubernetes) loadIngresses(k8sClient k8s.Client) (*types.Configur
|
||||||
log.Errorf("Error retrieving services %s", pa.Backend.ServiceName)
|
log.Errorf("Error retrieving services %s", pa.Backend.ServiceName)
|
||||||
}
|
}
|
||||||
for _, service := range services {
|
for _, service := range services {
|
||||||
var protocol string
|
protocol := "http"
|
||||||
for _, port := range service.Spec.Ports {
|
for _, port := range service.Spec.Ports {
|
||||||
if port.Port == pa.Backend.ServicePort.IntValue() {
|
if port.Port == pa.Backend.ServicePort.IntValue() {
|
||||||
protocol = port.Name
|
if port.Port == 443 {
|
||||||
|
protocol = "https"
|
||||||
|
}
|
||||||
templateObjects.Backends[r.Host+pa.Path].Servers[string(service.UID)] = types.Server{
|
templateObjects.Backends[r.Host+pa.Path].Servers[string(service.UID)] = types.Server{
|
||||||
URL: protocol + "://" + service.Spec.ClusterIP + ":" + pa.Backend.ServicePort.String(),
|
URL: protocol + "://" + service.Spec.ClusterIP + ":" + pa.Backend.ServicePort.String(),
|
||||||
Weight: 1,
|
Weight: 1,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package provider
|
package provider
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"github.com/containous/traefik/provider/k8s"
|
"github.com/containous/traefik/provider/k8s"
|
||||||
"github.com/containous/traefik/types"
|
"github.com/containous/traefik/types"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
@ -35,7 +36,7 @@ func TestLoadIngresses(t *testing.T) {
|
||||||
{
|
{
|
||||||
Backend: k8s.IngressBackend{
|
Backend: k8s.IngressBackend{
|
||||||
ServiceName: "service3",
|
ServiceName: "service3",
|
||||||
ServicePort: k8s.FromInt(803),
|
ServicePort: k8s.FromInt(443),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -76,7 +77,6 @@ func TestLoadIngresses(t *testing.T) {
|
||||||
ClusterIP: "10.0.0.2",
|
ClusterIP: "10.0.0.2",
|
||||||
Ports: []k8s.ServicePort{
|
Ports: []k8s.ServicePort{
|
||||||
{
|
{
|
||||||
Name: "http",
|
|
||||||
Port: 802,
|
Port: 802,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -92,7 +92,7 @@ func TestLoadIngresses(t *testing.T) {
|
||||||
Ports: []k8s.ServicePort{
|
Ports: []k8s.ServicePort{
|
||||||
{
|
{
|
||||||
Name: "http",
|
Name: "http",
|
||||||
Port: 803,
|
Port: 443,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -129,7 +129,7 @@ func TestLoadIngresses(t *testing.T) {
|
||||||
Weight: 1,
|
Weight: 1,
|
||||||
},
|
},
|
||||||
"3": {
|
"3": {
|
||||||
URL: "http://10.0.0.3:803",
|
URL: "https://10.0.0.3:443",
|
||||||
Weight: 1,
|
Weight: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -159,11 +159,11 @@ func TestLoadIngresses(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(actual.Backends, expected.Backends) {
|
actualJSON, _ := json.Marshal(actual)
|
||||||
t.Fatalf("expected %+v, got %+v", expected.Backends, actual.Backends)
|
expectedJSON, _ := json.Marshal(expected)
|
||||||
}
|
|
||||||
if !reflect.DeepEqual(actual.Frontends, expected.Frontends) {
|
if !reflect.DeepEqual(actual, expected) {
|
||||||
t.Fatalf("expected %+v, got %+v", expected.Frontends, actual.Frontends)
|
t.Fatalf("expected %+v, got %+v", string(expectedJSON), string(actualJSON))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue