Skip to content

Commit

Permalink
Remove cloud-defend from agent (elastic#5481)
Browse files Browse the repository at this point in the history
* Remove cloud-defend from agent

cloud-defend will be removed from the next major release. This removes cloud-defend
from agent, by removing it from packaging scripts and from template kubernetes files.

* add changelog

* fix typo

* update template

* Remove cloud-defend from agent

cloud-defend will be removed from the next major release. This removes cloud-defend
from agent, by removing it from packaging scripts and from template kubernetes files.

* add changelog

* fix typo

* update template

---------

Co-authored-by: Julien Lind <julien.lind@elastic.co>
  • Loading branch information
mjwolf and jlind23 authored Oct 8, 2024
1 parent 1c994b4 commit ce5f623
Show file tree
Hide file tree
Showing 16 changed files with 25 additions and 184 deletions.
4 changes: 4 additions & 0 deletions changelog/fragments/1725913991-remove-cloud-defend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
kind: breaking-change
summary: Remove cloud-defend from agent package
component: elastic-agent
pr: https://github.com/elastic/elastic-agent/pull/5481
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,6 @@ spec:
value: "false"
securityContext:
runAsUser: 0
# The following capabilities are needed for 'Defend for containers' integration (cloud-defend)
# If you are using this integration, please uncomment these lines before applying.
#capabilities:
# add:
# - BPF # (since Linux 5.8) allows loading of BPF programs, create most map types, load BTF, iterate programs and maps.
# - PERFMON # (since Linux 5.8) allows attaching of BPF programs used for performance metrics and observability operations.
# - SYS_RESOURCE # Allow use of special resources or raising of resource limits. Used by 'Defend for Containers' to modify 'rlimit_memlock'
########################################################################################
# The following capabilities are needed for Universal Profiling.
# More fine graded capabilities are only available for newer Linux kernels.
# If you are using the Universal Profiling integration, please uncomment these lines before applying.
Expand Down Expand Up @@ -141,8 +133,8 @@ spec:
hostPath:
path: /etc/machine-id
type: File
# Needed for 'Defend for containers' integration (cloud-defend) and Universal Profiling
# If you are not using one of these integrations, then these volumes and the corresponding
# Needed for Universal Profiling
# If you are not using this integration, then these volumes and the corresponding
# mounts can be removed.
- name: sys-kernel-debug
hostPath:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,6 @@ spec:
value: "false"
securityContext:
runAsUser: 0
# The following capabilities are needed for 'Defend for containers' integration (cloud-defend)
# If you are using this integration, please uncomment these lines before applying.
#capabilities:
# add:
# - BPF # (since Linux 5.8) allows loading of BPF programs, create most map types, load BTF, iterate programs and maps.
# - PERFMON # (since Linux 5.8) allows attaching of BPF programs used for performance metrics and observability operations.
# - SYS_RESOURCE # Allow use of special resources or raising of resource limits. Used by 'Defend for Containers' to modify 'rlimit_memlock'
########################################################################################
# The following capabilities are needed for Universal Profiling.
# More fine graded capabilities are only available for newer Linux kernels.
# If you are using the Universal Profiling integration, please uncomment these lines before applying.
Expand Down Expand Up @@ -147,8 +139,8 @@ spec:
- name: var-lib
hostPath:
path: /var/lib
# Needed for 'Defend for containers' integration (cloud-defend) and Universal Profiling
# If you are not using one of these integrations, then these volumes and the corresponding
# Needed for Universal Profiling
# If you are not using this integration, then these volumes and the corresponding
# mounts can be removed.
- name: sys-kernel-debug
hostPath:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,6 @@ spec:
value: "false"
securityContext:
runAsUser: 0
# The following capabilities are needed for 'Defend for containers' integration (cloud-defend)
# If you are using this integration, please uncomment these lines before applying.
#capabilities:
# add:
# - BPF # (since Linux 5.8) allows loading of BPF programs, create most map types, load BTF, iterate programs and maps.
# - PERFMON # (since Linux 5.8) allows attaching of BPF programs used for performance metrics and observability operations.
# - SYS_RESOURCE # Allow use of special resources or raising of resource limits. Used by 'Defend for Containers' to modify 'rlimit_memlock'
########################################################################################
# The following capabilities are needed for Universal Profiling.
# More fine graded capabilities are only available for newer Linux kernels.
# If you are using the Universal Profiling integration, please uncomment these lines before applying.
Expand Down Expand Up @@ -141,8 +133,8 @@ spec:
hostPath:
path: /etc/machine-id
type: File
# Needed for 'Defend for containers' integration (cloud-defend) and Universal Profiling
# If you are not using one of these integrations, then these volumes and the corresponding
# Needed for Universal Profiling
# If you are not using this integration, then these volumes and the corresponding
# mounts can be removed.
- name: sys-kernel-debug
hostPath:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,6 @@ spec:
value: "false"
securityContext:
runAsUser: 0
# The following capabilities are needed for 'Defend for containers' integration (cloud-defend)
# If you are using this integration, please uncomment these lines before applying.
#capabilities:
# add:
# - BPF # (since Linux 5.8) allows loading of BPF programs, create most map types, load BTF, iterate programs and maps.
# - PERFMON # (since Linux 5.8) allows attaching of BPF programs used for performance metrics and observability operations.
# - SYS_RESOURCE # Allow use of special resources or raising of resource limits. Used by 'Defend for Containers' to modify 'rlimit_memlock'
########################################################################################
# The following capabilities are needed for Universal Profiling.
# More fine graded capabilities are only available for newer Linux kernels.
# If you are using the Universal Profiling integration, please uncomment these lines before applying.
Expand Down Expand Up @@ -141,8 +133,8 @@ spec:
hostPath:
path: /etc/machine-id
type: File
# Needed for 'Defend for containers' integration (cloud-defend) and Universal Profiling
# If you are not using one of these integrations, then these volumes and the corresponding
# Needed for Universal Profiling
# If you are not using this integration, then these volumes and the corresponding
# mounts can be removed.
- name: sys-kernel-debug
hostPath:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,6 @@ spec:
value: "false"
securityContext:
runAsUser: 0
# The following capabilities are needed for 'Defend for containers' integration (cloud-defend)
# If you are using this integration, please uncomment these lines before applying.
#capabilities:
# add:
# - BPF # (since Linux 5.8) allows loading of BPF programs, create most map types, load BTF, iterate programs and maps.
# - PERFMON # (since Linux 5.8) allows attaching of BPF programs used for performance metrics and observability operations.
# - SYS_RESOURCE # Allow use of special resources or raising of resource limits. Used by 'Defend for Containers' to modify 'rlimit_memlock'
########################################################################################
# The following capabilities are needed for Universal Profiling.
# More fine graded capabilities are only available for newer Linux kernels.
# If you are using the Universal Profiling integration, please uncomment these lines before applying.
Expand Down Expand Up @@ -147,8 +139,8 @@ spec:
- name: var-lib
hostPath:
path: /var/lib
# Needed for 'Defend for containers' integration (cloud-defend) and Universal Profiling
# If you are not using one of these integrations, then these volumes and the corresponding
# Needed for Universal Profiling
# If you are not using this integration, then these volumes and the corresponding
# mounts can be removed.
- name: sys-kernel-debug
hostPath:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,6 @@ spec:
value: "false"
securityContext:
runAsUser: 0
# The following capabilities are needed for 'Defend for containers' integration (cloud-defend)
# If you are using this integration, please uncomment these lines before applying.
#capabilities:
# add:
# - BPF # (since Linux 5.8) allows loading of BPF programs, create most map types, load BTF, iterate programs and maps.
# - PERFMON # (since Linux 5.8) allows attaching of BPF programs used for performance metrics and observability operations.
# - SYS_RESOURCE # Allow use of special resources or raising of resource limits. Used by 'Defend for Containers' to modify 'rlimit_memlock'
########################################################################################
# The following capabilities are needed for Universal Profiling.
# More fine graded capabilities are only available for newer Linux kernels.
# If you are using the Universal Profiling integration, please uncomment these lines before applying.
Expand Down Expand Up @@ -147,8 +139,8 @@ spec:
- name: var-lib
hostPath:
path: /var/lib
# Needed for 'Defend for containers' integration (cloud-defend) and Universal Profiling
# If you are not using one of these integrations, then these volumes and the corresponding
# Needed for Universal Profiling
# If you are not using this integration, then these volumes and the corresponding
# mounts can be removed.
- name: sys-kernel-debug
hostPath:
Expand Down
12 changes: 2 additions & 10 deletions deploy/kubernetes/elastic-agent-managed-kubernetes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,6 @@ spec:
value: "false"
securityContext:
runAsUser: 0
# The following capabilities are needed for 'Defend for containers' integration (cloud-defend)
# If you are using this integration, please uncomment these lines before applying.
#capabilities:
# add:
# - BPF # (since Linux 5.8) allows loading of BPF programs, create most map types, load BTF, iterate programs and maps.
# - PERFMON # (since Linux 5.8) allows attaching of BPF programs used for performance metrics and observability operations.
# - SYS_RESOURCE # Allow use of special resources or raising of resource limits. Used by 'Defend for Containers' to modify 'rlimit_memlock'
########################################################################################
# The following capabilities are needed for Universal Profiling.
# More fine graded capabilities are only available for newer Linux kernels.
# If you are using the Universal Profiling integration, please uncomment these lines before applying.
Expand Down Expand Up @@ -141,8 +133,8 @@ spec:
hostPath:
path: /etc/machine-id
type: File
# Needed for 'Defend for containers' integration (cloud-defend) and Universal Profiling
# If you are not using one of these integrations, then these volumes and the corresponding
# Needed for Universal Profiling
# If you are not using this integration, then these volumes and the corresponding
# mounts can be removed.
- name: sys-kernel-debug
hostPath:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,6 @@ spec:
value: "false"
securityContext:
runAsUser: 0
# The following capabilities are needed for 'Defend for containers' integration (cloud-defend)
# If you are using this integration, please uncomment these lines before applying.
#capabilities:
# add:
# - BPF # (since Linux 5.8) allows loading of BPF programs, create most map types, load BTF, iterate programs and maps.
# - PERFMON # (since Linux 5.8) allows attaching of BPF programs used for performance metrics and observability operations.
# - SYS_RESOURCE # Allow use of special resources or raising of resource limits. Used by 'Defend for Containers' to modify 'rlimit_memlock'
########################################################################################
# The following capabilities are needed for Universal Profiling.
# More fine graded capabilities are only available for newer Linux kernels.
# If you are using the Universal Profiling integration, please uncomment these lines before applying.
Expand Down Expand Up @@ -141,8 +133,8 @@ spec:
hostPath:
path: /etc/machine-id
type: File
# Needed for 'Defend for containers' integration (cloud-defend) and Universal Profiling
# If you are not using one of these integrations, then these volumes and the corresponding
# Needed for Universal Profiling
# If you are not using this integration, then these volumes and the corresponding
# mounts can be removed.
- name: sys-kernel-debug
hostPath:
Expand Down
12 changes: 2 additions & 10 deletions deploy/kubernetes/elastic-agent-standalone-kubernetes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -741,14 +741,6 @@ spec:
value: "false"
securityContext:
runAsUser: 0
# The following capabilities are needed for 'Defend for containers' integration (cloud-defend)
# If you are using this integration, please uncomment these lines before applying.
#capabilities:
# add:
# - BPF # (since Linux 5.8) allows loading of BPF programs, create most map types, load BTF, iterate programs and maps.
# - PERFMON # (since Linux 5.8) allows attaching of BPF programs used for performance metrics and observability operations.
# - SYS_RESOURCE # Allow use of special resources or raising of resource limits. Used by 'Defend for Containers' to modify 'rlimit_memlock'
########################################################################################
# The following capabilities are needed for Universal Profiling.
# More fine graded capabilities are only available for newer Linux kernels.
# If you are using the Universal Profiling integration, please uncomment these lines before applying.
Expand Down Expand Up @@ -816,8 +808,8 @@ spec:
- name: var-lib
hostPath:
path: /var/lib
# Needed for 'Defend for containers' integration (cloud-defend) and Universal Profiling
# If you are not using one of these integrations, then these volumes and the corresponding
# Needed for Universal Profiling
# If you are not using this integration, then these volumes and the corresponding
# mounts can be removed.
- name: sys-kernel-debug
hostPath:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,6 @@ spec:
value: "false"
securityContext:
runAsUser: 0
# The following capabilities are needed for 'Defend for containers' integration (cloud-defend)
# If you are using this integration, please uncomment these lines before applying.
#capabilities:
# add:
# - BPF # (since Linux 5.8) allows loading of BPF programs, create most map types, load BTF, iterate programs and maps.
# - PERFMON # (since Linux 5.8) allows attaching of BPF programs used for performance metrics and observability operations.
# - SYS_RESOURCE # Allow use of special resources or raising of resource limits. Used by 'Defend for Containers' to modify 'rlimit_memlock'
########################################################################################
# The following capabilities are needed for Universal Profiling.
# More fine graded capabilities are only available for newer Linux kernels.
# If you are using the Universal Profiling integration, please uncomment these lines before applying.
Expand Down Expand Up @@ -147,8 +139,8 @@ spec:
- name: var-lib
hostPath:
path: /var/lib
# Needed for 'Defend for containers' integration (cloud-defend) and Universal Profiling
# If you are not using one of these integrations, then these volumes and the corresponding
# Needed for Universal Profiling
# If you are not using this integration, then these volumes and the corresponding
# mounts can be removed.
- name: sys-kernel-debug
hostPath:
Expand Down
35 changes: 0 additions & 35 deletions dev-tools/mage/checksums.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,26 +144,6 @@ func ChecksumsWithManifest(requiredPackage string, versionedFlatPath string, ver
log.Printf(">>>>>>> Calculated directory to copy: [%s]", dirToCopy)
}

// cloud-defend path exception
// When untarred, cloud defend untars to:
// cloud-defend-8.14.0-arm64
// but the manifest (and most of this code) expects to be the same as
// the name in the manifest, which is:
// cloud-defend-8.14.0-linux-x86_64
// So we have to do a bit of a transformation here
if strings.Contains(dirToCopy, "cloud-defend") {
if strings.Contains(dirToCopy, "x86_64") {
dirToCopy = fixCloudDefendDirPath(dirToCopy, componentVersion, "x86_64", "amd64")
}
if strings.Contains(dirToCopy, "arm64") {
// Not actually replacing the arch, but removing the "linux"
dirToCopy = fixCloudDefendDirPath(dirToCopy, componentVersion, "arm64", "arm64")
}
if mg.Verbose() {
log.Printf(">>>>>>> Adjusted cloud-defend directory to copy: [%s]", dirToCopy)
}
}

// Set copy options
options := copy.Options{
OnSymlink: func(_ string) copy.SymlinkAction {
Expand Down Expand Up @@ -263,18 +243,3 @@ func getComponentVersion(componentName string, requiredPackage string, component

return componentVersion
}

// This is a helper function for the cloud-defend package.
// When it is untarred, it does not have the same dirname as the package name.
// This adjusts for that and returns the actual path on disk for cloud-defend
func fixCloudDefendDirPath(dirPath string, componentVersion string, expectedArch string, actualArch string) string {
fixedDirPath := dirPath

cloudDefendExpectedDirName := fmt.Sprintf("cloud-defend-%s-linux-%s", componentVersion, expectedArch)
cloudDefendActualDirName := fmt.Sprintf("cloud-defend-%s-%s", componentVersion, actualArch)
if strings.Contains(fixedDirPath, cloudDefendExpectedDirName) {
fixedDirPath = strings.ReplaceAll(fixedDirPath, cloudDefendExpectedDirName, cloudDefendActualDirName)
}

return fixedDirPath
}
5 changes: 1 addition & 4 deletions dev-tools/mage/pkgtypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -903,10 +903,7 @@ func addFileToZip(ar *zip.Writer, baseDir string, pkgFile PackageFile) error {

// addFileToTar adds a file (or directory) to a tar archive.
func addFileToTar(ar *tar.Writer, baseDir string, pkgFile PackageFile) error {
excludedFiles := []string{
"cloud-defend",
"cloud-defend.spec.yml",
}
excludedFiles := []string{}

return filepath.WalkDir(pkgFile.Source, func(path string, d fs.DirEntry, err error) error {
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ RUN true && \
chmod 0755 {{ $beatHome }}/data/elastic-agent-*/components/*beat && \
(chmod 0755 {{ $beatHome }}/data/elastic-agent-*/components/osquery* || true) && \
(chmod 0755 {{ $beatHome }}/data/elastic-agent-*/components/apm-server || true) && \
(chmod 0755 {{ $beatHome }}/data/elastic-agent-*/components/cloud-defend || true) && \
(chmod 0755 {{ $beatHome }}/data/elastic-agent-*/components/endpoint-security || true) && \
(chmod 0755 {{ $beatHome }}/data/elastic-agent-*/components/fleet-server || true) && \
(chmod 0755 {{ $beatHome }}/data/elastic-agent-*/components/pf-elastic-collector || true) && \
Expand Down
Loading

0 comments on commit ce5f623

Please sign in to comment.