Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions configs/etc/kubehound-reference.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ mongodb:
# Timeout on requests to the mongo DB instance
connection_timeout: 30s

# Wipe old copy of k8s/kubehound resources in mongodb
wipe: false

# Graph database configuration
janusgraph:
# Connection URL to the JanusGraph DB instance
Expand Down
5 changes: 4 additions & 1 deletion configs/etc/kubehound.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ mongodb:

# Timeout on requests to the mongo DB instance
connection_timeout: 30s


# Wipe old copy of k8s/kubehound resources in mongodb
wipe: false

# Graph database configuration
janusgraph:
# Connection URL to the JanusGraph DB instance
Expand Down
3 changes: 3 additions & 0 deletions deployments/k8s/khaas/conf/ingestor/kubehound.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ janusgraph:
# Timeout on requests to the JanusGraph DB instance
connection_timeout: 30s

# Wipe old copy of k8s/kubehound resources in mongodb
wipe: false

# Datadog telemetry configuration
telemetry:
# Whether to enable Datadog telemetry (default false)
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func SetDefaultValues(ctx context.Context, v *viper.Viper) {
// Default value for MongoDB
v.SetDefault(MongoUrl, DefaultMongoUrl)
v.SetDefault(MongoConnectionTimeout, DefaultConnectionTimeout)
v.SetDefault(MongoWipe, DefaultMongoWipe)

// Defaults values for JanusGraph
v.SetDefault(JanusGraphUrl, DefaultJanusGraphUrl)
Expand Down
5 changes: 4 additions & 1 deletion pkg/config/mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ import (
)

const (
DefaultMongoUrl = "mongodb://localhost:27017"
DefaultMongoUrl = "mongodb://localhost:27017"
DefaultMongoWipe = false

MongoUrl = "mongodb.url"
MongoConnectionTimeout = "mongodb.connection_timeout"
MongoWipe = "mongodb.wipe"
)

// MongoDBConfig configures mongodb specific parameters.
type MongoDBConfig struct {
URL string `mapstructure:"url"` // Mongodb specific configuration
ConnectionTimeout time.Duration `mapstructure:"connection_timeout"`
Wipe bool `mapstructure:"wipe"`
}
12 changes: 12 additions & 0 deletions pkg/ingestor/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,23 @@ func (g *IngestorAPI) Ingest(ctx context.Context, path string) error { //nolint:

// Run the ingest pipeline
l.Info("Starting Kubernetes raw data ingest")

// Droping the storedb data for the cluster if the wipe flag is set
if g.Cfg.MongoDB.Wipe {
err = g.providers.StoreProvider.Clean(runCtx, "*", clusterName) //nolint: contextcheck
if err != nil {
return err
}
l.Info("Droped storedb data for the cluster", log.String(log.FieldClusterKey, clusterName))
}

// Checking if the data is already ingested in the database
alreadyIngestedInDB, err := g.isAlreadyIngestedInDB(runCtx, clusterName, runID) //nolint: contextcheck
if err != nil {
return err
}

// Droping the storedb data for the cluster if the data is already ingested in the database
if alreadyIngestedInDB {
l.Info("Data already ingested in the database for %s/%s, droping the current data", log.String(log.FieldClusterKey, clusterName), log.String(log.FieldRunIDKey, runID))
err := g.providers.StoreProvider.Clean(runCtx, runID, clusterName) //nolint: contextcheck
Expand Down
Loading