sharedmain

package
v0.0.0-...-87426b5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2020 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckK8sClientMinimumVersionOrDie

func CheckK8sClientMinimumVersionOrDie(ctx context.Context, logger *zap.SugaredLogger)

CheckK8sClientMinimumVersionOrDie checks that the hosting Kubernetes cluster is at least the minimum allowable version or dies by calling log.Fatalf.

func ControllersAndWebhooksFromCtors

func ControllersAndWebhooksFromCtors(ctx context.Context,
	cmw *configmap.InformedWatcher,
	ctors ...injection.ControllerConstructor) ([]*controller.Impl, []interface{})

ControllersAndWebhooksFromCtors returns a list of the controllers and a list of the webhooks created from the given constructors.

func GetConfig

func GetConfig(masterURL, kubeconfig string) (*rest.Config, error)

GetConfig returns a rest.Config to be used for kubernetes client creation. It does so in the following order:

  1. Use the passed kubeconfig/masterURL.
  2. Fallback to the KUBECONFIG environment variable.
  3. Fallback to in-cluster config.
  4. Fallback to the ~/.kube/config.

func GetLeaderElectionConfig

func GetLeaderElectionConfig(ctx context.Context) (*kle.Config, error)

GetLeaderElectionConfig gets the leader election config.

func GetLoggingConfig

func GetLoggingConfig(ctx context.Context) (*logging.Config, error)

GetLoggingConfig gets the logging config from either the file system if present or via reading a configMap from the API. The context is expected to be initialized with injection.

func Main

func Main(component string, ctors ...injection.ControllerConstructor)

Main runs the generic main flow for non-webhook controllers with a new context. Use WebhookMainWith* if you need to serve webhooks.

func MainWithConfig

func MainWithConfig(ctx context.Context, component string, cfg *rest.Config, ctors ...injection.ControllerConstructor)

MainWithConfig runs the generic main flow for non-webhook controllers. Use WebhookMainWithConfig if you need to serve webhooks.

func MainWithContext

func MainWithContext(ctx context.Context, component string, ctors ...injection.ControllerConstructor)

MainWithContext runs the generic main flow for non-webhook controllers. Use WebhookMainWithContext if you need to serve webhooks.

func MemStatsOrDie

func MemStatsOrDie(ctx context.Context)

MemStatsOrDie sets up reporting on Go memory usage every 30 seconds or dies by calling log.Fatalf.

func ParseAndGetConfigOrDie

func ParseAndGetConfigOrDie() *rest.Config

ParseAndGetConfigOrDie parses the rest config flags and creates a client or dies by calling log.Fatalf.

func RunLeaderElected

func RunLeaderElected(ctx context.Context, logger *zap.SugaredLogger, run func(context.Context), component string, leConfig kle.ComponentConfig)

RunLeaderElected runs the given function in leader elected mode. The function will be run only once the leader election lock is obtained.

func SetupConfigMapWatchOrDie

func SetupConfigMapWatchOrDie(ctx context.Context, logger *zap.SugaredLogger) *configmap.InformedWatcher

SetupConfigMapWatchOrDie establishes a watch of the configmaps in the system namespace that are labeled to be watched or dies by calling log.Fatalf.

func SetupLoggerOrDie

func SetupLoggerOrDie(ctx context.Context, component string) (*zap.SugaredLogger, zap.AtomicLevel)

SetupLoggerOrDie sets up the logger using the config from the given context and returns a logger and atomic level, or dies by calling log.Fatalf.

func WatchLoggingConfigOrDie

func WatchLoggingConfigOrDie(ctx context.Context, cmw *configmap.InformedWatcher, logger *zap.SugaredLogger, atomicLevel zap.AtomicLevel, component string)

WatchLoggingConfigOrDie establishes a watch of the logging config or dies by calling log.Fatalf. Note, if the config does not exist, it will be defaulted and this method will not die.

func WatchObservabilityConfigOrDie

func WatchObservabilityConfigOrDie(ctx context.Context, cmw *configmap.InformedWatcher, profilingHandler *profiling.Handler, logger *zap.SugaredLogger, component string)

WatchObservabilityConfigOrDie establishes a watch of the logging config or dies by calling log.Fatalf. Note, if the config does not exist, it will be defaulted and this method will not die.

func WebhookMainWithConfig

func WebhookMainWithConfig(ctx context.Context, component string, cfg *rest.Config, ctors ...injection.ControllerConstructor)

WebhookMainWithConfig runs the generic main flow for controllers and webhooks with the given config. Use MainWithConfig if you do not need to serve webhooks.

func WebhookMainWithContext

func WebhookMainWithContext(ctx context.Context, component string, ctors ...injection.ControllerConstructor)

WebhookMainWithContext runs the generic main flow for controllers and webhooks. Use MainWithContext if you do not need to serve webhooks.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL