Skip to content

Commit

Permalink
trivy image scan
Browse files Browse the repository at this point in the history
  • Loading branch information
Nithunikzz committed Mar 13, 2024
1 parent 086975f commit ff5aa57
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions agent/kubviz/k8smetrics_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ import (
"github.com/go-co-op/gocron"
"github.com/nats-io/nats.go"

"context"
//"context"

"github.com/intelops/kubviz/pkg/mtlsnats"
"github.com/intelops/kubviz/pkg/opentelemetry"
//"github.com/intelops/kubviz/pkg/opentelemetry"

"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"

"github.com/intelops/kubviz/agent/config"
"github.com/intelops/kubviz/agent/kubviz/plugins/events"

"github.com/intelops/kubviz/agent/kubviz/plugins/ketall"
"github.com/intelops/kubviz/agent/kubviz/plugins/kubepreupgrade"
// "github.com/intelops/kubviz/agent/kubviz/plugins/ketall"
// "github.com/intelops/kubviz/agent/kubviz/plugins/kubepreupgrade"

"github.com/intelops/kubviz/agent/kubviz/plugins/kuberhealthy"
"github.com/intelops/kubviz/agent/kubviz/plugins/kubescore"
"github.com/intelops/kubviz/agent/kubviz/plugins/outdated"
"github.com/intelops/kubviz/agent/kubviz/plugins/rakkess"
// "github.com/intelops/kubviz/agent/kubviz/plugins/kuberhealthy"
// "github.com/intelops/kubviz/agent/kubviz/plugins/kubescore"
// "github.com/intelops/kubviz/agent/kubviz/plugins/outdated"
// "github.com/intelops/kubviz/agent/kubviz/plugins/rakkess"

"github.com/intelops/kubviz/agent/kubviz/plugins/trivy"
"github.com/intelops/kubviz/agent/kubviz/scheduler"
Expand Down Expand Up @@ -67,7 +67,7 @@ var (
func main() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
env := Production
clusterMetricsChan := make(chan error, 1)
//clusterMetricsChan := make(chan error, 1)
cfg, err := config.GetAgentConfigurations()
if err != nil {
log.Fatal("Failed to retrieve agent configurations", err)
Expand Down Expand Up @@ -121,38 +121,38 @@ func main() {
clientset = events.GetK8sClient(config)
}

tp, err := opentelemetry.InitTracer()
if err != nil {
log.Fatal(err)
}
defer func() {
if err := tp.Shutdown(context.Background()); err != nil {
log.Printf("Error shutting down tracer provider: %v", err)
}
}()

go events.PublishMetrics(clientset, js, clusterMetricsChan)
if cfg.KuberHealthyEnable {
go kuberhealthy.StartKuberHealthy(js)
}
// tp, err := opentelemetry.InitTracer()
// if err != nil {
// log.Fatal(err)
// }
// defer func() {
// if err := tp.Shutdown(context.Background()); err != nil {
// log.Printf("Error shutting down tracer provider: %v", err)
// }
// }()

// go events.PublishMetrics(clientset, js, clusterMetricsChan)
// if cfg.KuberHealthyEnable {
// go kuberhealthy.StartKuberHealthy(js)
// }
go server.StartServer()
collectAndPublishMetrics := func() {
err := outdated.OutDatedImages(config, js)
events.LogErr(err)
err = kubepreupgrade.KubePreUpgradeDetector(config, js)
events.LogErr(err)
err = ketall.GetAllResources(config, js)
events.LogErr(err)
err = rakkess.RakeesOutput(config, js)
events.LogErr(err)
err = trivy.RunTrivySbomScan(config, js)
events.LogErr(err)
// err := outdated.OutDatedImages(config, js)
// events.LogErr(err)
// err = kubepreupgrade.KubePreUpgradeDetector(config, js)
// events.LogErr(err)
// err = ketall.GetAllResources(config, js)
// events.LogErr(err)
// err = rakkess.RakeesOutput(config, js)
// events.LogErr(err)
// err = trivy.RunTrivySbomScan(config, js)
// events.LogErr(err)
err = trivy.RunTrivyImageScans(config, js)
events.LogErr(err)
err = trivy.RunTrivyK8sClusterScan(js)
events.LogErr(err)
err = kubescore.RunKubeScore(clientset, js)
events.LogErr(err)
// err = trivy.RunTrivyK8sClusterScan(js)
// events.LogErr(err)
// err = kubescore.RunKubeScore(clientset, js)
// events.LogErr(err)
}

collectAndPublishMetrics()
Expand Down

0 comments on commit ff5aa57

Please sign in to comment.