Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: enrichment for kind and minikube #3598

Merged
merged 1 commit into from Oct 29, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions deploy/helm/tracee/templates/daemonset.yaml
Expand Up @@ -43,6 +43,10 @@ spec:
env:
- name: LIBBPFGO_OSRELEASE_FILE
value: /etc/os-release-host
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
{{- if .Values.config.healthz }}
Expand Down
4 changes: 4 additions & 0 deletions deploy/kubernetes/tracee/tracee.yaml
Expand Up @@ -108,6 +108,10 @@ spec:
env:
- name: LIBBPFGO_OSRELEASE_FILE
value: /etc/os-release-host
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
readinessProbe:
httpGet:
path: /healthz
Expand Down
4 changes: 3 additions & 1 deletion pkg/containers/containers.go
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/aquasecurity/tracee/pkg/cgroup"
cruntime "github.com/aquasecurity/tracee/pkg/containers/runtime"
"github.com/aquasecurity/tracee/pkg/errfmt"
"github.com/aquasecurity/tracee/pkg/k8s"
"github.com/aquasecurity/tracee/pkg/logger"
)

Expand Down Expand Up @@ -210,7 +211,8 @@ func (c *Containers) EnrichCgroupInfo(cgroupId uint64) (cruntime.ContainerMetada
return metadata, errfmt.Errorf("no containerId")
}

if info.Dead {
isMikubeOrKind := k8s.IsMinkube() || k8s.IsKind()
if info.Dead && !isMikubeOrKind {
return metadata, errfmt.Errorf("container already deleted")
}

Expand Down
14 changes: 14 additions & 0 deletions pkg/k8s/k8s.go
@@ -0,0 +1,14 @@
package k8s

import (
"os"
"strings"
)

func IsMinkube() bool {
return strings.HasPrefix(os.Getenv("NODE_NAME"), "minikube")
}

func IsKind() bool {
return strings.HasPrefix(os.Getenv("NODE_NAME"), "kind")
}