Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small fixes #1291

Merged
merged 3 commits into from
Mar 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion docs/toml.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -1023,8 +1025,9 @@ domain = "mesos.localhost"
# HTTP Timeout (in seconds)
#
# Optional
# Default: 30
#
# StateTimeoutSecond = "host"
# StateTimeoutSecond = "30"
```

## Kubernetes Ingress backend
Expand Down
26 changes: 7 additions & 19 deletions provider/k8s/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
log.Warnf("Kubernetes in cluster config error, trying from out of cluster: %s", err)
config = &rest.Config{}
}
clientset, err := kubernetes.NewForConfig(config)
if err != nil {
return nil, err
}

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
Expand Down
11 changes: 1 addition & 10 deletions provider/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 0 additions & 1 deletion traefik.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ func run(traefikConfiguration *TraefikConfiguration) {
}
}(t)
}
log.Info(t.String())
server.Wait()
log.Info("Shutting down")
}
Expand Down
5 changes: 4 additions & 1 deletion traefik.sample.toml
Original file line number Diff line number Diff line change
Expand Up @@ -630,12 +630,14 @@
# Zookeeper timeout (in seconds)
#
# Optional
# Default: 30
#
# ZkDetectionTimeout = 30

# Polling interval (in seconds)
#
# Optional
# Default: 30
#
# RefreshSeconds = 30

Expand All @@ -648,8 +650,9 @@
# HTTP Timeout (in seconds)
#
# Optional
# Default: 30
#
# StateTimeoutSecond = "host"
# StateTimeoutSecond = "30"

################################################################
# Kubernetes Ingress configuration backend
Expand Down