From 082d6aa144826a679b9f4707222295eaa28df31e Mon Sep 17 00:00:00 2001 From: Matthias Bertschy Date: Thu, 19 Dec 2024 07:56:12 +0100 Subject: [PATCH] copy igK8sClient.RuntimeConfig and unset RuntimeProtocol for our usage Signed-off-by: Matthias Bertschy --- main.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 321075b4..11225f37 100644 --- a/main.go +++ b/main.go @@ -16,6 +16,7 @@ import ( "github.com/grafana/pyroscope-go" igconfig "github.com/inspektor-gadget/inspektor-gadget/pkg/config" containercollection "github.com/inspektor-gadget/inspektor-gadget/pkg/container-collection" + igtypes "github.com/inspektor-gadget/inspektor-gadget/pkg/container-utils/types" beUtils "github.com/kubescape/backend/pkg/utils" "github.com/kubescape/go-logger" "github.com/kubescape/go-logger/helpers" @@ -290,7 +291,17 @@ func main() { } defer igK8sClient.Close() logger.L().Info("IG Kubernetes client created", helpers.Interface("client", igK8sClient)) - logger.L().Info("Detected container runtime", helpers.String("containerRuntime", igK8sClient.RuntimeConfig.Name.String())) + + // Detect the container containerRuntime of the node + containerRuntime := &igtypes.RuntimeConfig{ + Name: igK8sClient.RuntimeConfig.Name, + SocketPath: igK8sClient.RuntimeConfig.SocketPath, + RuntimeProtocol: "", // deliberately empty + Extra: igtypes.ExtraConfig{ + Namespace: igK8sClient.RuntimeConfig.Extra.Namespace, + }, + } + logger.L().Info("Detected container runtime", helpers.String("containerRuntime", containerRuntime.Name.String())) // Create the SBOM manager var sbomManager sbommanager.SbomManagerClient @@ -304,7 +315,7 @@ func main() { } // Create the container handler - mainHandler, err := containerwatcher.CreateIGContainerWatcher(cfg, applicationProfileManager, k8sClient, igK8sClient, networkManagerClient, dnsManagerClient, prometheusExporter, ruleManager, malwareManager, sbomManager, preRunningContainersIDs, &ruleBindingNotify, igK8sClient.RuntimeConfig, nil, nil, processManager) + mainHandler, err := containerwatcher.CreateIGContainerWatcher(cfg, applicationProfileManager, k8sClient, igK8sClient, networkManagerClient, dnsManagerClient, prometheusExporter, ruleManager, malwareManager, sbomManager, preRunningContainersIDs, &ruleBindingNotify, containerRuntime, nil, nil, processManager) if err != nil { logger.L().Ctx(ctx).Fatal("error creating the container watcher", helpers.Error(err)) }