diff --git a/configuration.go b/configuration.go index 7013455c7..ba69f00b9 100644 --- a/configuration.go +++ b/configuration.go @@ -392,6 +392,9 @@ func NewTraefikDefaultPointersConfiguration() *TraefikConfiguration { defaultMesos.Endpoint = "http://127.0.0.1:5050" defaultMesos.ExposedByDefault = true defaultMesos.Constraints = types.Constraints{} + defaultMesos.RefreshSeconds = 30 + defaultMesos.ZkDetectionTimeout = 30 + defaultMesos.StateTimeoutSecond = 30 //default ECS var defaultECS provider.ECS diff --git a/docs/toml.md b/docs/toml.md index 9980a4b1f..edde70544 100644 --- a/docs/toml.md +++ b/docs/toml.md @@ -1005,12 +1005,14 @@ domain = "mesos.localhost" # Zookeeper timeout (in seconds) # # Optional +# Default: 30 # # ZkDetectionTimeout = 30 # Polling interval (in seconds) # # Optional +# Default: 30 # # RefreshSeconds = 30 @@ -1023,8 +1025,9 @@ domain = "mesos.localhost" # HTTP Timeout (in seconds) # # Optional +# Default: 30 # -# StateTimeoutSecond = "host" +# StateTimeoutSecond = "30" ``` ## Kubernetes Ingress backend diff --git a/provider/k8s/client.go b/provider/k8s/client.go index d4806d870..58187ad57 100644 --- a/provider/k8s/client.go +++ b/provider/k8s/client.go @@ -3,6 +3,7 @@ package k8s import ( "time" + "github.com/containous/traefik/log" "k8s.io/client-go/1.5/kubernetes" "k8s.io/client-go/1.5/pkg/api" "k8s.io/client-go/1.5/pkg/api/v1" @@ -39,31 +40,18 @@ type clientImpl struct { clientset *kubernetes.Clientset } -// NewInClusterClient returns a new Kubernetes client that expect to run inside the cluster -func NewInClusterClient() (Client, error) { +// NewClient returns a new Kubernetes client +func NewClient(endpoint string) (Client, error) { config, err := rest.InClusterConfig() if err != nil { - return nil, err - } - clientset, err := kubernetes.NewForConfig(config) - if err != nil { - return nil, err + log.Warnf("Kubernetes in cluster config error, trying from out of cluster: %s", err) + config = &rest.Config{} } - return &clientImpl{ - clientset: clientset, - }, nil -} - -// NewInClusterClientWithEndpoint is the same as NewInClusterClient but uses the provided endpoint URL -func NewInClusterClientWithEndpoint(endpoint string) (Client, error) { - config, err := rest.InClusterConfig() - if err != nil { - return nil, err + if len(endpoint) > 0 { + config.Host = endpoint } - config.Host = endpoint - clientset, err := kubernetes.NewForConfig(config) if err != nil { return nil, err diff --git a/provider/kubernetes.go b/provider/kubernetes.go index 9747d60e1..942094ebf 100644 --- a/provider/kubernetes.go +++ b/provider/kubernetes.go @@ -29,19 +29,10 @@ type Kubernetes struct { lastConfiguration safe.Safe } -func (provider *Kubernetes) newK8sClient() (k8s.Client, error) { - if provider.Endpoint != "" { - log.Infof("Creating in cluster Kubernetes client with endpoint %v", provider.Endpoint) - return k8s.NewInClusterClientWithEndpoint(provider.Endpoint) - } - log.Info("Creating in cluster Kubernetes client") - return k8s.NewInClusterClient() -} - // Provide allows the provider to provide configurations to traefik // using the given configuration channel. func (provider *Kubernetes) Provide(configurationChan chan<- types.ConfigMessage, pool *safe.Pool, constraints types.Constraints) error { - k8sClient, err := provider.newK8sClient() + k8sClient, err := k8s.NewClient(provider.Endpoint) if err != nil { return err } diff --git a/traefik.go b/traefik.go index 5399b919e..fbe0f9f8d 100644 --- a/traefik.go +++ b/traefik.go @@ -261,7 +261,6 @@ func run(traefikConfiguration *TraefikConfiguration) { } }(t) } - log.Info(t.String()) server.Wait() log.Info("Shutting down") } diff --git a/traefik.sample.toml b/traefik.sample.toml index 2c83caacb..9de58ad7d 100644 --- a/traefik.sample.toml +++ b/traefik.sample.toml @@ -630,12 +630,14 @@ # Zookeeper timeout (in seconds) # # Optional +# Default: 30 # # ZkDetectionTimeout = 30 # Polling interval (in seconds) # # Optional +# Default: 30 # # RefreshSeconds = 30 @@ -648,8 +650,9 @@ # HTTP Timeout (in seconds) # # Optional +# Default: 30 # -# StateTimeoutSecond = "host" +# StateTimeoutSecond = "30" ################################################################ # Kubernetes Ingress configuration backend