diff --git a/dev-tools/packaging/templates/docker/Dockerfile.elastic-agent.tmpl b/dev-tools/packaging/templates/docker/Dockerfile.elastic-agent.tmpl index a54a9edde71..3c2f9b036d1 100644 --- a/dev-tools/packaging/templates/docker/Dockerfile.elastic-agent.tmpl +++ b/dev-tools/packaging/templates/docker/Dockerfile.elastic-agent.tmpl @@ -56,8 +56,7 @@ RUN true && \ true # Keep this after any chown command, chown resets any applied capabilities -RUN setcap =p {{ $beatHome }}/data/elastic-agent-{{ commit_short }}/elastic-agent -RUN setcap cap_net_raw,cap_setuid+p {{ $beatHome }}/data/elastic-agent-{{ commit_short }}/components/agentbeat && \ +RUN setcap =p {{ $beatHome }}/data/elastic-agent-{{ commit_short }}/elastic-agent && \ {{- if .linux_capabilities }} # Since the beat is stored at the other end of a symlink we must follow the symlink first # For security reasons setcap does not support symlinks. This is smart in the general case diff --git a/testing/integration/kubernetes_agent_standalone_test.go b/testing/integration/kubernetes_agent_standalone_test.go index b2ad15da818..ebd10d0c634 100644 --- a/testing/integration/kubernetes_agent_standalone_test.go +++ b/testing/integration/kubernetes_agent_standalone_test.go @@ -30,6 +30,7 @@ import ( batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" rbacv1 "k8s.io/api/rbac/v1" + "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/serializer" @@ -122,18 +123,18 @@ func TestKubernetesAgentStandalone(t *testing.T) { int64Ptr(1000), // elastic-agent uid nil, []corev1.Capability{"ALL"}, - []corev1.Capability{"CHOWN", "SETPCAP"}, + []corev1.Capability{"CHOWN", "SETPCAP", "DAC_READ_SEARCH", "SYS_PTRACE"}, true, - "https://github.com/elastic/elastic-agent/issues/5275", + "", }, { "drop ALL add CHOWN, SETPCAP capabilities - rootless agent random uid:gid", int64Ptr(500), int64Ptr(500), []corev1.Capability{"ALL"}, - []corev1.Capability{"CHOWN", "SETPCAP", "DAC_READ_SEARCH"}, + []corev1.Capability{"CHOWN", "SETPCAP", "DAC_READ_SEARCH", "SYS_PTRACE"}, true, - "https://github.com/elastic/elastic-agent/issues/5275", + "", }, } @@ -160,6 +161,10 @@ func TestKubernetesAgentStandalone(t *testing.T) { // as the image is already loaded by the kubernetes provisioner container.ImagePullPolicy = "Never" + container.Resources.Limits = corev1.ResourceList{ + corev1.ResourceMemory: resource.MustParse("800Mi"), + } + if tc.capabilitiesDrop != nil || tc.capabilitiesAdd != nil || tc.runUser != nil || tc.runGroup != nil { // set security context container.SecurityContext = &corev1.SecurityContext{