add service mesh controller

add service mesh metrics

remove unused circle yaml

fix travis misconfiguration

fix travis misconfiguration

fix travis misconfiguration
This commit is contained in:
jeff
2019-03-08 18:22:30 +08:00
committed by Jeff
parent 858facd4b2
commit 4ac20ffc2b
1709 changed files with 344390 additions and 60749 deletions

View File

@@ -118,15 +118,30 @@ type Options struct {
// for serving prometheus metrics
MetricsBindAddress string
// Functions to all for a user to customize the values that will be injected.
// NewCache is the function that will create the cache to be used
// by the manager. If not set this will use the default new cache function.
NewCache NewCacheFunc
// NewClient will create the client to be used by the manager.
// If not set this will create the default DelegatingClient that will
// use the cache for reads and the client for writes.
NewClient NewClientFunc
// Dependency injection for testing
newCache func(config *rest.Config, opts cache.Options) (cache.Cache, error)
newClient func(config *rest.Config, options client.Options) (client.Client, error)
newRecorderProvider func(config *rest.Config, scheme *runtime.Scheme, logger logr.Logger) (recorder.Provider, error)
newResourceLock func(config *rest.Config, recorderProvider recorder.Provider, options leaderelection.Options) (resourcelock.Interface, error)
newAdmissionDecoder func(scheme *runtime.Scheme) (types.Decoder, error)
newMetricsListener func(addr string) (net.Listener, error)
}
// NewCacheFunc allows a user to define how to create a cache
type NewCacheFunc func(config *rest.Config, opts cache.Options) (cache.Cache, error)
// NewClientFunc allows a user to define how to create a client
type NewClientFunc func(cache cache.Cache, config *rest.Config, options client.Options) (client.Client, error)
// Runnable allows a component to be started.
type Runnable interface {
// Start starts running the component. The component will stop running when the channel is closed.
@@ -159,14 +174,13 @@ func New(config *rest.Config, options Options) (Manager, error) {
return nil, err
}
// Create the Client for Write operations.
writeObj, err := options.newClient(config, client.Options{Scheme: options.Scheme, Mapper: mapper})
// Create the cache for the cached read client and registering informers
cache, err := options.NewCache(config, cache.Options{Scheme: options.Scheme, Mapper: mapper, Resync: options.SyncPeriod, Namespace: options.Namespace})
if err != nil {
return nil, err
}
// Create the cache for the cached read client and registering informers
cache, err := options.newCache(config, cache.Options{Scheme: options.Scheme, Mapper: mapper, Resync: options.SyncPeriod, Namespace: options.Namespace})
writeObj, err := options.NewClient(cache, config, client.Options{Scheme: options.Scheme, Mapper: mapper})
if err != nil {
return nil, err
}
@@ -209,14 +223,7 @@ func New(config *rest.Config, options Options) (Manager, error) {
errChan: make(chan error),
cache: cache,
fieldIndexes: cache,
client: client.DelegatingClient{
Reader: &client.DelegatingReader{
CacheReader: cache,
ClientReader: writeObj,
},
Writer: writeObj,
StatusClient: writeObj,
},
client: writeObj,
recorderProvider: recorderProvider,
resourceLock: resourceLock,
mapper: mapper,
@@ -226,6 +233,24 @@ func New(config *rest.Config, options Options) (Manager, error) {
}, nil
}
// defaultNewClient creates the default caching client
func defaultNewClient(cache cache.Cache, config *rest.Config, options client.Options) (client.Client, error) {
// Create the Client for Write operations.
c, err := client.New(config, options)
if err != nil {
return nil, err
}
return &client.DelegatingClient{
Reader: &client.DelegatingReader{
CacheReader: cache,
ClientReader: c,
},
Writer: c,
StatusClient: c,
}, nil
}
// setOptionsDefaults set default values for Options fields
func setOptionsDefaults(options Options) Options {
// Use the Kubernetes client-go scheme if none is specified
@@ -238,13 +263,13 @@ func setOptionsDefaults(options Options) Options {
}
// Allow newClient to be mocked
if options.newClient == nil {
options.newClient = client.New
if options.NewClient == nil {
options.NewClient = defaultNewClient
}
// Allow newCache to be mocked
if options.newCache == nil {
options.newCache = cache.New
if options.NewCache == nil {
options.NewCache = cache.New
}
// Allow newRecorderProvider to be mocked