confhelper

package
v0.2.11 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2020 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FlagsForControllerConfig

func FlagsForControllerConfig(name, prefix string, l *log.Config, c *ControllerConfig) *pflag.FlagSet

func FlagsForKubeClient

func FlagsForKubeClient(prefix string, c *KubeClientConfig) *pflag.FlagSet

func FlagsForLeaderElection

func FlagsForLeaderElection(name, prefix string, c *LeaderElectionConfig) *pflag.FlagSet

func FlagsForLeaderElectionLease

func FlagsForLeaderElectionLease(prefix string, c *LeaderElectionLeaseConfig) *pflag.FlagSet

func FlagsForLeaderElectionLock

func FlagsForLeaderElectionLock(name, prefix string, c *LeaderElectionLockConfig) *pflag.FlagSet

func FlagsForMetrics

func FlagsForMetrics(prefix string, c *MetricsConfig) *pflag.FlagSet

func FlagsForPProfConfig

func FlagsForPProfConfig(prefix string, c *PProfConfig) *pflag.FlagSet

func FlagsForTLSConfig

func FlagsForTLSConfig(prefix string, config *TLSConfig) *pflag.FlagSet

func FlagsForTracing

func FlagsForTracing(prefix string, c *TracingConfig) *pflag.FlagSet

Types

type ControllerConfig

type ControllerConfig struct {
	Log            log.ConfigSet        `json:"log" yaml:"log"`
	KubeClient     KubeClientConfig     `json:"kubeClient" yaml:"kubeClient"`
	Metrics        MetricsConfig        `json:"metrics" yaml:"metrics"`
	Tracing        TracingConfig        `json:"tracing" yaml:"tracing"`
	LeaderElection LeaderElectionConfig `json:"leaderElection" yaml:"leaderElection"`
	PProf          PProfConfig          `json:"pprof" yaml:"pprof"`
}

type KubeClientConfig

type KubeClientConfig struct {
	// Fake to create a fake client instead of creating real kubernetes client
	Fake           bool                      `json:"fake" yaml:"fake"`
	KubeconfigPath string                    `json:"kubeconfig" yaml:"kubeconfig"`
	RateLimit      KubeClientRateLimitConfig `json:"rateLimit" yaml:"rateLimit"`
}

func (*KubeClientConfig) NewKubeClient

func (c *KubeClientConfig) NewKubeClient(
	kubeconfig *rest.Config,
	applyRateLimitConfig bool,
) (client kubernetes.Interface, _ *rest.Config, err error)

NewKubeClient creates a kubernetes client with/without existing kubeconfig if nil kubeconfig was provided, then will retrieve kubeconfig from configured path and will fallback to in cluster kubeconfig you can choose whether rate limit config is applied, if not, will use default rate limit config

type KubeClientRateLimitConfig

type KubeClientRateLimitConfig struct {
	Enabled bool    `json:"enabled" yaml:"enabled"`
	QPS     float32 `json:"qps" yaml:"qps"`
	Burst   int     `json:"burst" yaml:"burst"`
}

type LeaderElectionConfig

type LeaderElectionConfig struct {
	Identity string                    `json:"identity" yaml:"identity"`
	Lock     LeaderElectionLockConfig  `json:"lock" yaml:"lock"`
	Lease    LeaderElectionLeaseConfig `json:"lease" yaml:"lease"`
}

func (*LeaderElectionConfig) CreateElector

func (c *LeaderElectionConfig) CreateElector(
	name string,
	kubeClient kubernetes.Interface,
	eventRecorder record.EventRecorder,
	onElected func(context.Context),
	onEjected func(),
	onNewLeader func(identity string),
) (*leaderelection.LeaderElector, error)

type LeaderElectionLeaseConfig

type LeaderElectionLeaseConfig struct {
	Expiration       time.Duration `json:"expiration" yaml:"expiration"`
	RenewDeadline    time.Duration `json:"renewDeadline" yaml:"renewDeadline"`
	RenewInterval    time.Duration `json:"renewInterval" yaml:"renewInterval"`
	ExpiryToleration time.Duration `json:"expiryToleration" yaml:"expiryToleration"`
}

type LeaderElectionLockConfig

type LeaderElectionLockConfig struct {
	Name      string `json:"name" yaml:"name"`
	Namespace string `json:"namespace" yaml:"namespace"`
	Type      string `json:"type" yaml:"type"`
}

type MetricsConfig

type MetricsConfig struct {
	// Enabled metrics collection
	Enabled bool `json:"enabled" yaml:"enabled"`

	// Endpoint address for metrics/tracing collection,
	// for prometheus, it's a listen address (SHOULD NOT be empty or use random port (:0))
	// for otlp, it's the otlp collector address
	Endpoint string `json:"listen" yaml:"listen"`

	// Format of exposed metrics
	Format string `json:"format" yaml:"format"`

	// HTTPPath for metrics collection
	HTTPPath string `json:"httpPath" yaml:"httpPath"`

	// TLS config for client/server
	TLS TLSConfig `json:"tls" yaml:"tls"`
}

func (*MetricsConfig) RegisterIfEnabled

func (c *MetricsConfig) RegisterIfEnabled(ctx context.Context, logger log.Interface) (err error)

type PProfConfig

type PProfConfig struct {
	Enabled              bool   `json:"enabled" yaml:"enabled"`
	Listen               string `json:"listen" yaml:"listen"`
	HTTPPath             string `json:"httpPath" yaml:"httpPath"`
	MutexProfileFraction int    `json:"mutexProfileFraction" yaml:"mutexProfileFraction"`
	BlockProfileRate     int    `json:"blockProfileRate" yaml:"blockProfileRate"`
}

func (*PProfConfig) RunIfEnabled

func (c *PProfConfig) RunIfEnabled() error

type TLSConfig

type TLSConfig struct {
	Enabled bool `json:"enabled" yaml:"enabled"`

	CaCert string `json:"caCert" yaml:"caCert"`
	Cert   string `json:"cert" yaml:"cert"`
	Key    string `json:"key" yaml:"key"`

	CaCertData string `json:"caCertData" yaml:"caCertData"`
	CertData   string `json:"certData" yaml:"certData"`
	KeyData    string `json:"keyData" yaml:"keyData"`

	ServerName         string `json:"serverName" yaml:"serverName"`
	InsecureSkipVerify bool   `json:"insecureSkipVerify" yaml:"insecureSkipVerify"`
	// write tls session shared key to this file
	KeyLogFile   string   `json:"keyLogFile" yaml:"keyLogFile"`
	CipherSuites []string `json:"cipherSuites" yaml:"cipherSuites"`

	// options for dtls
	AllowInsecureHashes bool `json:"allowInsecureHashes" yaml:"allowInsecureHashes"`

	PreSharedKey TLSPreSharedKeyConfig `json:"preSharedKey" yaml:"preSharedKey"`
}

nolint:maligned

func (TLSConfig) GetTLSConfig

func (c TLSConfig) GetTLSConfig(server bool) (_ *tls.Config, err error)

type TLSPreSharedKeyConfig

type TLSPreSharedKeyConfig struct {
	// map server hint(s) to pre shared key(s)
	// column separated base64 encoded key value pairs
	ServerHintMapping []string `json:"serverHintMapping" yaml:"serverHintMapping"`
	// the client hint provided to server, base64 encoded value
	IdentityHint string `json:"identityHint" yaml:"identityHint"`
}

type TracingConfig

type TracingConfig struct {
	// Enabled tracing stats
	Enabled bool `json:"enabled" yaml:"enabled"`

	// Format of exposed tracing stats
	Format string `json:"format" yaml:"format"`

	// EndpointType the type of collector (used for jaeger), can be one of [agent, collector]
	EndpointType string `json:"endpointType" yaml:"endpointType"`

	// Endpoint to report tracing stats
	Endpoint string `json:"endpoint" yaml:"endpoint"`

	// SampleRate
	SampleRate float64 `json:"sampleRate" yaml:"sampleRate"`

	// ReportedServiceName used when reporting tracing stats
	ReportedServiceName string `json:"serviceName" yaml:"serviceName"`

	// TLS config for client/server
	TLS TLSConfig `json:"tls" yaml:"tls"`
}

func (*TracingConfig) RegisterIfEnabled

func (c *TracingConfig) RegisterIfEnabled(ctx context.Context, logger log.Interface) (err error)

Jump to

Keyboard shortcuts

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