config

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultEdgeWorkerPoolSize         = 5
	DefaultEdgeWorkerPoolCapacity     = 100
	DefaultEdgeBatchSize              = 500
	DefaultEdgeBatchSizeSmall         = DefaultEdgeBatchSize / 5
	DefaultEdgeBatchSizeClusterImpact = 10

	DefaultVertexBatchSize      = 500
	DefaultVertexBatchSizeSmall = DefaultVertexBatchSize / 5
)
View Source
const (
	CollectorTypeFile   = "file-collector"
	CollectorTypeK8sAPI = "live-k8s-api-collector"
)
View Source
const (
	DefaultK8sAPIPageSize           int64 = 500
	DefaultK8sAPIPageBufferSize     int32 = 10
	DefaultK8sAPIRateLimitPerSecond int   = 100
)
View Source
const (
	DefaultConfigType  = "yaml"
	DefaultClusterName = "unknown"
)
View Source
const (
	DefaultRetry             int           = 10 // number of tries before failing
	DefaultRetryDelay        time.Duration = 10 * time.Second
	DefaultConnectionTimeout time.Duration = 30 * time.Second
)
View Source
const (
	DefaultProfilerPeriod      time.Duration = 60 * time.Second
	DefaultProfilerCPUDuration time.Duration = 15 * time.Second
)
View Source
const (
	DefaultJanusGraphUrl = "ws://localhost:8182/gremlin"
)
View Source
const (
	DefaultMongoUrl = "mongodb://localhost:27017"
)

Variables

View Source
var (
	BuildVersion string // This should be overwritten by the go build -X flags
)

Functions

func IsCI

func IsCI() bool

IsCI determines whether the application is running within a CI action

func SetDefaultValues

func SetDefaultValues(c *viper.Viper)

SetDefaultValues loads the default value from the different modules

func SetEnvOverrides added in v1.2.0

func SetEnvOverrides(c *viper.Viper)

SetEnvOverrides enables environment variable overrides for the config.

Types

type BuilderConfig

type BuilderConfig struct {
	Vertex VertexBuilderConfig `mapstructure:"vertex"` // Vertex builder config
	Edge   EdgeBuilderConfig   `mapstructure:"edge"`   // Edge builder config
}

type CollectorConfig

type CollectorConfig struct {
	Type string                 `mapstructure:"type"` // Collector type
	File *FileCollectorConfig   `mapstructure:"file"` // File collector specific configuration
	Live *K8SAPICollectorConfig `mapstructure:"live"` // File collector specific configuration
}

CollectorConfig configures collector specific parameters.

type DynamicConfig added in v1.2.0

type DynamicConfig struct {
	RunID   *RunID
	Cluster string
	// contains filtered or unexported fields
}

DynamicConfig represent application configuration that can be updated at runtime.

type DynamicOption added in v1.2.0

type DynamicOption func(c *DynamicConfig)

DynamicOption is a functional option for configuring the dynamic config.

func WithClusterName added in v1.2.0

func WithClusterName(cluster string) DynamicOption

WithClusterName is a functional option for configuring the cluster name.

type EdgeBuilderConfig

type EdgeBuilderConfig struct {
	LargeClusterOptimizations bool `mapstructure:"large_cluster_optimizations"`
	WorkerPoolSize            int  `mapstructure:"worker_pool_size"`          // Number of workers for the edge builder worker pool
	WorkerPoolCapacity        int  `mapstructure:"worker_pool_capacity"`      // Work item capacity for the edge builder worker pool
	BatchSize                 int  `mapstructure:"batch_size"`                // Batch size for inserts
	BatchSizeSmall            int  `mapstructure:"batch_size_small"`          // Batch size for expensive inserts
	BatchSizeClusterImpact    int  `mapstructure:"batch_size_cluster_impact"` // Batch size for inserts impacting entire cluster e.g POD_PATCH
}

EdgeBuilderConfig configures edge builder parameters.

type FileCollectorConfig

type FileCollectorConfig struct {
	ClusterName string `mapstructure:"cluster"`   // Target cluster (must be specified in config as not present in JSON files)
	Directory   string `mapstructure:"directory"` // Base directory holding the K8s data JSON files
}

FileCollectorConfig configures the file collector.

type JanusGraphConfig

type JanusGraphConfig struct {
	URL               string        `mapstructure:"url"` // JanusGraph specific configuration
	ConnectionTimeout time.Duration `mapstructure:"connection_timeout"`
}

JanusGraphConfig configures JanusGraph specific parameters.

type K8SAPICollectorConfig

type K8SAPICollectorConfig struct {
	PageSize           int64 `mapstructure:"page_size"`             // Number of entry being retrieving by each call on the API (same for all Kubernetes entry types)
	PageBufferSize     int32 `mapstructure:"page_buffer_size"`      // Number of pages to buffer
	RateLimitPerSecond int   `mapstructure:"rate_limit_per_second"` // Rate limiting per second across all calls (same for all kubernetes entry types) against the Kubernetes API
}

K8SAPICollectorConfig configures the K8sAPI collector.

type KubehoundConfig

type KubehoundConfig struct {
	Collector  CollectorConfig  `mapstructure:"collector"`  // Collector configuration
	MongoDB    MongoDBConfig    `mapstructure:"mongodb"`    // MongoDB configuration
	JanusGraph JanusGraphConfig `mapstructure:"janusgraph"` // JanusGraph configuration
	Storage    StorageConfig    `mapstructure:"storage"`    // Global param for all storage provider
	Telemetry  TelemetryConfig  `mapstructure:"telemetry"`  // telemetry configuration, contains statsd and other sub structures
	Builder    BuilderConfig    `mapstructure:"builder"`    // Graph builder  configuration
	Dynamic    DynamicConfig    // Dynamic (i.e runtime generated) configuration
}

KubehoundConfig defines the top-level application configuration for KubeHound.

func MustLoadConfig

func MustLoadConfig(configPath string) *KubehoundConfig

MustLoadConfig loads the application configuration from the provided path, treating all errors as fatal.

func MustLoadEmbedConfig

func MustLoadEmbedConfig() *KubehoundConfig

MustLoadEmbedConfig loads the embedded default application configuration, treating all errors as fatal.

func NewConfig

func NewConfig(configPath string) (*KubehoundConfig, error)

NewConfig creates a new config instance from the provided file using viper.

func NewEmbedConfig

func NewEmbedConfig(configPath string) (*KubehoundConfig, error)

NewEmbedConfig creates a new config instance from an embedded config file using viper.

func (*KubehoundConfig) ComputeDynamic added in v1.2.0

func (kc *KubehoundConfig) ComputeDynamic(opts ...DynamicOption)

ComputeDynamic sets the dynamic components of the config from the provided options.

type MongoDBConfig

type MongoDBConfig struct {
	URL               string        `mapstructure:"url"` // Mongodb specific configuration
	ConnectionTimeout time.Duration `mapstructure:"connection_timeout"`
}

MongoDBConfig configures mongodb specific parameters.

type ProfilerConfig

type ProfilerConfig struct {
	Period      time.Duration `mapstructure:"period"`
	CPUDuration time.Duration `mapstructure:"cpu_duration"`
}

ProfilerConfig configures profiler specific parameters.

type RunID added in v1.2.0

type RunID struct {
	// contains filtered or unexported fields
}

RunID represents a unique ID for each KubeHound run.

func NewRunID added in v1.2.0

func NewRunID() *RunID

NewRunID creates a new RunID instance.

func (RunID) String added in v1.2.0

func (r RunID) String() string

String returns the string representation of the run id. NOTE: this is lowercased to ensure consistency with Datadog (where tags are automatically lower cased)

func (RunID) Timestamp added in v1.2.0

func (r RunID) Timestamp() time.Time

Timestamp returns the timestamp embedded within the run id.

type StatsdConfig

type StatsdConfig struct {
	URL string `mapstructure:"url"` // Statsd endpoint URL
}

StatsdConfig configures statsd specific parameters.

type StorageConfig

type StorageConfig struct {
	Retry      int           `mapstructure:"retry"`
	RetryDelay time.Duration `mapstructure:"retry_delay"`
	Wipe       bool          `mapstructure:"wipe"`
}

type TelemetryConfig

type TelemetryConfig struct {
	Enabled  bool              `mapstructure:"enabled"`  // Whether or not to enable Datadog telemetry
	Tags     map[string]string `mapstructure:"tags"`     // Free form tags to be added to all telemetry
	Statsd   StatsdConfig      `mapstructure:"statsd"`   // Statsd configuration (for metrics)
	Tracer   TracerConfig      `mapstructure:"tracer"`   // Tracer configuration (for APM)
	Profiler ProfilerConfig    `mapstructure:"profiler"` // Profiler configuration
}

type TracerConfig

type TracerConfig struct {
	URL string `mapstructure:"url"` // Tracer endpoint URL
}

TracerConfig configures tracer specific parameters.

type VertexBuilderConfig

type VertexBuilderConfig struct {
	BatchSize      int `mapstructure:"batch_size"`       // Batch size for inserts
	BatchSizeSmall int `mapstructure:"batch_size_small"` // Batch size for expensive inserts

}

VertexBuilderConfig configures vertex builder parameters.

Jump to

Keyboard shortcuts

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