Documentation ¶
Index ¶
- Constants
- Variables
- func GetClusterName(ctx context.Context) (string, error)
- func IsCI() bool
- func SetDefaultValues(v *viper.Viper)
- func SetEnvOverrides(c *viper.Viper)
- func SetLocalConfig(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(configPath string) *KubehoundConfig
- func MustLoadEmbedConfig() *KubehoundConfig
- func MustLoadInlineConfig() *KubehoundConfig
- func NewConfig(v *viper.Viper, configPath string) (*KubehoundConfig, error)
- func NewEmbedConfig(v *viper.Viper, configPath string) (*KubehoundConfig, error)
- func NewInlineConfig(v *viper.Viper) (*KubehoundConfig, error)
- func NewKubehoundConfig(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 = 500 DefaultEdgeBatchSizeSmall = DefaultEdgeBatchSize / 5 DefaultEdgeBatchSizeClusterImpact = 10 DefaultVertexBatchSize = 500 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" CollectorFileClusterName = "collector.file.cluster_name" CollectorFileBlobRegion = "collector.file.blob.region" CollectorFileBlobBucket = "collector.file.blob.bucket" )
const ( DefaultConfigType = "yaml" DefaultClusterName = "unknown" DefaultConfigName = "kubehound" GlobalDebug = "debug" )
const ( DynamicRunID = "dynamic.run_id" DynamicClusterName = "dynamic.cluster_name" )
const ( DefaultIngestorAPIEndpoint = "127.0.0.1:9000" 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" IngestorClusterName = "ingestor.cluster_name" IngestorRunID = "ingestor.run_id" IngestorMaxArchiveSize = "ingestor.max_archive_size" IngestorTempDir = "ingestor.temp_dir" IngestorArchiveName = "ingestor.archive_name" IngestorBlobBucketName = "ingestor.blob.bucket_name" IngestorBlobRegion = "ingestor.blob.region" )
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" )
const (
DefaultJanusGraphUrl = "ws://localhost:8182/gremlin"
)
const (
DefaultMongoUrl = "mongodb://localhost:27017"
)
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.
func SetLocalConfig ¶ added in v1.4.0
Load local config file if it exists, check for local file in current dir or in $HOME/.config/ Not returning any error as it is not mandatory to have a local config file
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(_ 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"` // 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() (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 { ClusterName string `mapstructure:"cluster_name"` // 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 Archive *FileArchiveConfig `mapstructure:"archive"` // Archive configuration Blob *BlobConfig `mapstructure:"blob"` // Blob storage 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"` ClusterName string `mapstructure:"cluster_name"` RunID string `mapstructure:"run_id"` }
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 { 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(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 MustLoadInlineConfig ¶ added in v1.3.1
func MustLoadInlineConfig() *KubehoundConfig
MustLoadConfig loads the application configuration from the provided path, treating all errors as fatal.
func NewConfig ¶
func NewConfig(v *viper.Viper, configPath string) (*KubehoundConfig, error)
NewConfig creates a new config instance from the provided file using viper.
func NewEmbedConfig ¶
func NewEmbedConfig(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
func NewInlineConfig(v *viper.Viper) (*KubehoundConfig, error)
NewConfig creates a new config instance from the provided file using viper.
func NewKubehoundConfig ¶ added in v1.3.1
func NewKubehoundConfig(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.