diff --git a/cmd/agent/dist/conf.d/kata_containers.d/conf.yaml.default b/cmd/agent/dist/conf.d/kata_containers.d/conf.yaml.default new file mode 100644 index 000000000000..fa2453f6b8ac --- /dev/null +++ b/cmd/agent/dist/conf.d/kata_containers.d/conf.yaml.default @@ -0,0 +1,22 @@ +ad_identifiers: + - _kata_containers +init_config: +instances: + - + ## @param sandbox_storage_paths - list of strings - optional - default: ["/run/vc/sbs", "/run/kata"] + ## Directories to scan for Kata shim sockets. When running the Agent in a container, + ## host paths are typically mounted under /host — both variants are listed here so the + ## check works without manual configuration in either deployment mode. + # + sandbox_storage_paths: + - /host/run/vc/sbs + - /host/run/kata + + ## @param tags - list of strings following the pattern: "key:value" - optional + ## List of tags to attach to every metric, event, and service check emitted by this integration. + ## + ## Learn more about tagging: https://docs.datadoghq.com/tagging/ + # + # tags: + # - : + # - : diff --git a/comp/core/autodiscovery/listeners/environment.go b/comp/core/autodiscovery/listeners/environment.go index 438d2e56a970..bcfbbd16b79a 100644 --- a/comp/core/autodiscovery/listeners/environment.go +++ b/comp/core/autodiscovery/listeners/environment.go @@ -55,6 +55,7 @@ func (l *EnvironmentListener) createServices() { "kube_orchestrator": env.KubeOrchestratorExplorer, "kubelet_config_orchestrator": env.KubeletConfigOrchestratorCheck, "ecs_orchestrator": env.ECSOrchestratorExplorer, + "kata_containers": env.KataContainers, } for name, feature := range features { diff --git a/pkg/config/env/environment_container_features.go b/pkg/config/env/environment_container_features.go index 49e17840cf21..88a16dc82fcf 100644 --- a/pkg/config/env/environment_container_features.go +++ b/pkg/config/env/environment_container_features.go @@ -44,4 +44,6 @@ const ( // NonstandardCRIRuntime is a fallback value for when customers supply a CRI compliant runtime via the // cri_socket_path configuration field NonstandardCRIRuntime = "nonstandard-cri-runtime" + // KataContainers sandbox storage paths present + KataContainers Feature = "kata_containers" ) diff --git a/pkg/config/env/environment_containers.go b/pkg/config/env/environment_containers.go index 3fe2da91db39..8e1639a9e1b3 100644 --- a/pkg/config/env/environment_containers.go +++ b/pkg/config/env/environment_containers.go @@ -54,6 +54,7 @@ func init() { registerFeature(KubernetesDevicePlugins) registerFeature(NVML) registerFeature(NonstandardCRIRuntime) + registerFeature(KataContainers) } // IsAnyContainerFeaturePresent checks if any of known container features is present @@ -82,6 +83,7 @@ func detectContainerFeatures(features FeatureMap, cfg model.Reader) { detectPodResources(features, cfg) detectDevicePlugins(features, cfg) detectNVML(features, cfg) + detectKata(features) } func detectKubernetes(features FeatureMap, cfg model.Reader) { @@ -342,6 +344,16 @@ func detectNVML(features FeatureMap, cfg model.Reader) { log.Debugf("Agent did not find NVML library in any of the default paths: %v", defaultPaths) } +func detectKata(features FeatureMap) { + for _, basePath := range getDefaultKataPaths() { + if _, err := os.Stat(basePath); err == nil { + features[KataContainers] = struct{}{} + log.Infof("Agent found Kata Containers sandbox path at: %s", basePath) + return + } + } +} + func getHostMountPrefixes() []string { if IsContainerized() { return []string{"", defaultHostMountPrefix} @@ -423,6 +435,18 @@ func getDefaultNvmlPaths() []string { return paths } +func getDefaultKataPaths() []string { + var defaultKataSandboxPaths = []string{"/host/run/vc/sbs", "/host/run/kata"} + + paths := make([]string, 0, len(getHostMountPrefixes())*len(defaultKataSandboxPaths)) + for _, prefix := range getHostMountPrefixes() { + for _, p := range defaultKataSandboxPaths { + paths = append(paths, path.Join(prefix, p)) + } + } + return paths +} + // merge merges and dedupes 2 slices without changing order func merge(s1, s2 []string) []string { dedupe := map[string]struct{}{} diff --git a/releasenotes/notes/kata-containers-autodiscovery-f654d29fe08482c7.yaml b/releasenotes/notes/kata-containers-autodiscovery-f654d29fe08482c7.yaml new file mode 100644 index 000000000000..4e4d8c0347b0 --- /dev/null +++ b/releasenotes/notes/kata-containers-autodiscovery-f654d29fe08482c7.yaml @@ -0,0 +1,7 @@ +--- +features: + - | + Add automatic discovery of Kata Containers environments. The Agent now detects + the presence of Kata sandbox paths (``/host/run/vc/sbs``, ``/host/run/kata``) at startup + and automatically enables the ``kata_containers`` check without manual + configuration.