Documentation ¶
Index ¶
- Constants
- Variables
- func GetClusterName(ctx context.Context) (string, error)
- func IsCI() bool
- func SetDefaultValues(ctx context.Context, v *viper.Viper)
- func SetEnvOverrides(ctx context.Context, c *viper.Viper)
- func SetLocalConfig(ctx context.Context, v *viper.Viper)
- type BlobConfig
- type BuilderConfig
- type ClusterInfo
- type CollectorConfig
- type DynamicConfig
- type DynamicOption
- type EdgeBuilderConfig
- type FileArchiveConfig
- type FileCollectorConfig
- type IngestorAPIConfig
- type IngestorConfig
- type JanusGraphConfig
- type K8SAPICollectorConfig
- type KubehoundConfig
- func MustLoadConfig(ctx context.Context, configPath string) *KubehoundConfig
- func MustLoadEmbedConfig(ctx context.Context) *KubehoundConfig
- func MustLoadInlineConfig(ctx context.Context) *KubehoundConfig
- func NewConfig(ctx context.Context, v *viper.Viper, configPath string) (*KubehoundConfig, error)
- func NewEmbedConfig(ctx context.Context, v *viper.Viper, configPath string) (*KubehoundConfig, error)
- func NewInlineConfig(ctx context.Context, v *viper.Viper) (*KubehoundConfig, error)
- func NewKubehoundConfig(ctx context.Context, configPath string, inLine bool) *KubehoundConfig
- type MongoDBConfig
- type ProfilerConfig
- type RunID
- type StatsdConfig
- type StorageConfig
- type TelemetryConfig
- type TracerConfig
- type VertexBuilderConfig
Constants ¶
const ( DefaultEdgeWorkerPoolSize = 5 DefaultEdgeWorkerPoolCapacity = 100 DefaultEdgeBatchSize = 250 DefaultEdgeBatchSizeSmall = DefaultEdgeBatchSize / 5 DefaultEdgeBatchSizeClusterImpact = 10 DefaultVertexBatchSize = 250 DefaultVertexBatchSizeSmall = DefaultVertexBatchSize / 5 DefaultStopOnError = false DefaultLargeClusterOptimizations = true )
const ( CollectorTypeFile = "file-collector" CollectorTypeK8sAPI = "live-k8s-api-collector" )
const ( DefaultK8sAPIPageSize int64 = 500 DefaultK8sAPIPageBufferSize int32 = 10 DefaultK8sAPIRateLimitPerSecond int = 100 DefaultK8sAPINonInteractive bool = false DefaultArchiveNoCompress bool = false CollectorLiveRate = "collector.live.rate_limit_per_second" CollectorLivePageSize = "collector.live.page_size" CollectorLivePageBufferSize = "collector.live.page_buffer_size" CollectorNonInteractive = "collector.non_interactive" CollectorFileArchiveNoCompress = "collector.file.archive.no_compress" CollectorFileDirectory = "collector.file.directory" )
const ( DefaultConfigType = "yaml" DefaultClusterName = "unknown" DefaultConfigName = "kubehound" GlobalDebug = "debug" )
const ( DynamicRunID = "dynamic.run_id" DynamicClusterName = "dynamic.cluster_name" )
const ( DefaultIngestorAPIEndpoint = "" DefaultIngestorAPIInsecure = false DefaultBucketName = "" // we want to let it empty because we can easily abort if it's not configured DefaultTempDir = "/tmp/kubehound" DefaultArchiveName = "archive.tar.gz" DefaultMaxArchiveSize = int64(2 << 30) // 2GB IngestorAPIEndpoint = "ingestor.api.endpoint" IngestorAPIInsecure = "ingestor.api.insecure" IngestorMaxArchiveSize = "ingestor.max_archive_size" IngestorTempDir = "ingestor.temp_dir" IngestorArchiveName = "ingestor.archive_name" IngestorBlobBucketURL = "ingestor.blob.bucket_url" IngestorBlobRegion = "ingestor.blob.region" )
const ( DefaultJanusGraphUrl = "ws://localhost:8182/gremlin" JanusGraphUrl = "janusgraph.url" JanusGrapTimeout = "janusgraph.connection_timeout" JanusGraphWriterTimeout = "janusgraph.writer_timeout" JanusGraphWriterMaxRetry = "janusgraph.writer_max_retry" JanusGraphWriterWorkerCount = "janusgraph.writer_worker_count" )
const ( DefaultMongoUrl = "mongodb://localhost:27017" MongoUrl = "mongodb.url" MongoConnectionTimeout = "mongodb.connection_timeout" )
const ( DefaultRetry int = 10 // number of tries before failing DefaultRetryDelay time.Duration = 10 * time.Second DefaultConnectionTimeout time.Duration = 30 * time.Second )
const ( DefaultProfilerPeriod time.Duration = 60 * time.Second DefaultProfilerCPUDuration time.Duration = 15 * time.Second DefaultTelemetryStatsdUrl = "" // 127.0.0.1:8225 DefaultTelemetryProfilerUrl = "" // 127.0.0.1:8226 TelemetryStatsdUrl = "telemetry.statsd.url" TelemetryTracerUrl = "telemetry.tracer.url" TelemetryEnabled = "telemetry.enabled" TelemetryProfilerCPUDuration = "telemetry.profiler.cpu_duration" TelemetryProfilerPeriod = "telemetry.profiler.period" )
Variables ¶
var ( BuildVersion string // This should be overwritten by the go build -X flags BuildBranch string // This should be overwritten by the go build -X flags BuildArch string // This should be overwritten by the go build -X flags BuildOs string // This should be overwritten by the go build -X flags )
Functions ¶
func SetDefaultValues ¶
SetDefaultValues loads the default value from the different modules
func SetEnvOverrides ¶ added in v1.2.0
SetEnvOverrides enables environment variable overrides for the config.
Types ¶
type BlobConfig ¶ added in v1.3.1
type BuilderConfig ¶
type BuilderConfig struct { Vertex VertexBuilderConfig `mapstructure:"vertex"` // Vertex builder config Edge EdgeBuilderConfig `mapstructure:"edge"` // Edge builder config StopOnError bool `mapstructure:"stop_on_error"` // Stop the building of the graph on error }
type ClusterInfo ¶ added in v1.3.1
type ClusterInfo struct {
Name string
}
ClusterInfo encapsulates the target cluster information for the current run.
func NewClusterInfo ¶ added in v1.3.1
func NewClusterInfo(ctx context.Context) (*ClusterInfo, error)
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 NonInteractive bool `mapstructure:"non_interactive"` // Skip confirmation }
CollectorConfig configures collector specific parameters.
type DynamicConfig ¶ added in v1.2.0
type DynamicConfig struct { RunID *RunID `mapstructure:"run_id"` ClusterName string `mapstructure:"cluster_name"` Service string `mapstructure:"service"` // contains filtered or unexported fields }
DynamicConfig represent application configuration that can be updated at runtime.
func (*DynamicConfig) HealthCheck ¶ added in v1.5.0
func (d *DynamicConfig) HealthCheck() error
type DynamicOption ¶ added in v1.2.0
type DynamicOption func() (func(*DynamicConfig), error)
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.
func WithRunID ¶ added in v1.3.1
func WithRunID(runID string) DynamicOption
WithRunID is a functional option for configuring the runID (using in KHaaS).
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 FileArchiveConfig ¶ added in v1.3.1
type FileCollectorConfig ¶
type FileCollectorConfig struct { Directory string `mapstructure:"directory"` // Base directory holding the K8s data JSON files Archive *FileArchiveConfig `mapstructure:"archive"` // Archive configuration }
FileCollectorConfig configures the file collector.
type IngestorAPIConfig ¶ added in v1.3.1
type IngestorConfig ¶ added in v1.3.1
type IngestorConfig struct { API IngestorAPIConfig `mapstructure:"api"` Blob *BlobConfig `mapstructure:"blob"` TempDir string `mapstructure:"temp_dir"` ArchiveName string `mapstructure:"archive_name"` MaxArchiveSize int64 `mapstructure:"max_archive_size"` }
type JanusGraphConfig ¶
type JanusGraphConfig struct { URL string `mapstructure:"url"` // JanusGraph specific configuration ConnectionTimeout time.Duration `mapstructure:"connection_timeout"` // JanusGraph vertex/edge writer configuration WriterTimeout time.Duration `mapstructure:"writer_timeout"` WriterMaxRetry int `mapstructure:"writer_max_retry"` WriterWorkerCount int `mapstructure:"writer_worker_count"` }
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 { Debug bool `mapstructure:"debug"` // Debug mode 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 Ingestor IngestorConfig `mapstructure:"ingestor"` // Ingestor configuration Dynamic DynamicConfig `mapstructure:"dynamic"` // Dynamic (i.e runtime generated) configuration }
KubehoundConfig defines the top-level application configuration for KubeHound.
func MustLoadConfig ¶
func MustLoadConfig(ctx context.Context, configPath string) *KubehoundConfig
MustLoadConfig loads the application configuration from the provided path, treating all errors as fatal.
func MustLoadEmbedConfig ¶
func MustLoadEmbedConfig(ctx context.Context) *KubehoundConfig
MustLoadEmbedConfig loads the embedded default application configuration, treating all errors as fatal.
func MustLoadInlineConfig ¶ added in v1.3.1
func MustLoadInlineConfig(ctx context.Context) *KubehoundConfig
MustLoadConfig loads the application configuration from the provided path, treating all errors as fatal.
func NewEmbedConfig ¶
func NewEmbedConfig(ctx context.Context, v *viper.Viper, configPath string) (*KubehoundConfig, error)
NewEmbedConfig creates a new config instance from an embedded config file using viper.
func NewInlineConfig ¶ added in v1.3.1
NewConfig creates a new config instance from the provided file using viper.
func NewKubehoundConfig ¶ added in v1.3.1
func NewKubehoundConfig(ctx context.Context, configPath string, inLine bool) *KubehoundConfig
func (*KubehoundConfig) ComputeDynamic ¶ added in v1.2.0
func (kc *KubehoundConfig) ComputeDynamic(opts ...DynamicOption) error
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.
type StatsdConfig ¶
type StatsdConfig struct {
URL string `mapstructure:"url"` // Statsd endpoint URL
}
StatsdConfig configures statsd specific parameters.
type StorageConfig ¶
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.