Skip to content

Commit

Permalink
debugginh trivy scan
Browse files Browse the repository at this point in the history
  • Loading branch information
vijeyash1 committed Mar 8, 2024
1 parent 086975f commit 47557d8
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 45 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 = trivy.RunTrivyImageScans(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 = kubescore.RunKubeScore(clientset, js)
// events.LogErr(err)
}

collectAndPublishMetrics()
Expand Down
16 changes: 8 additions & 8 deletions agent/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
_ "net/http/pprof"

"github.com/gin-gonic/gin"
"github.com/intelops/kubviz/pkg/opentelemetry"
"go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin"
// "github.com/intelops/kubviz/pkg/opentelemetry"
// "go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin"
)

func EnableProfile(r *gin.Engine) {
Expand Down Expand Up @@ -35,13 +35,13 @@ func EnableProfile(r *gin.Engine) {
func StartServer() {
r := gin.Default()

config, err := opentelemetry.GetConfigurations()
if err != nil {
log.Println("Unable to read open telemetry configurations")
}
// config, err := opentelemetry.GetConfigurations()
// if err != nil {
// log.Println("Unable to read open telemetry configurations")
// }

// r.Use(otelgin.Middleware(config.ServiceName))

r.Use(otelgin.Middleware(config.ServiceName))

EnableProfile(r)
log.Fatal(r.Run(":8080"))
}

0 comments on commit 47557d8

Please sign in to comment.