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

Cherry-pick #18873 to 7.x: Allow the Docker image to be run with a random user id (#12905) #19555

Merged
merged 1 commit into from
Jul 2, 2020

Conversation

jsoriano
Copy link
Member

@jsoriano jsoriano commented Jul 1, 2020

Cherry-pick of PR #18873 to 7.x branch. Original message:

Apply changes on ownership proposed in #12905, but keep the permissions, to avoid the
issues reported in #18858.

I think this could be enough to run containers with arbitrary user ids, because beats don't need to write these files, only read them.

Make changes also to the kubernetes reference manifests to help running beats with arbitrary user ids. These manifests still won't work on restricted environments.

Fixes #18871
Changes were previously reverted in #18872

Co-authored-by: Michael Morello [email protected]

How to test

  • Do it with auditbeat (that uses the root user by default), and with some other beat like metricbeat or filebeat (that use a non-root user by default):
    • Build the docker image for the beat with PLATFORMS=linux/amd64 mage package, or use one of the pre-built snapshots including this change.
    • Run the docker container with and without explicit user id, and check that beat is able to start and read configuration without --privileged and without BEAT_STRICT_PERMS.
      It should behave the same on these scenarios (auditbeat will fail to configure audit, this is expected unless --privileged --user 0 --pid=host is also used):
      • Default user: docker run -it --rm docker.elastic.co/beats/filebeat:8.0.0
      • Root: docker run -it --rm --user 0 docker.elastic.co/beats/filebeat:8.0.0
      • Beat user: docker run -it --rm --user 1000 docker.elastic.co/beats/filebeat:8.0.0
      • Arbitrary user (use any other user id): docker run -it --rm --user 100042 docker.elastic.co/beats/filebeat:8.0.0
    • Check that reference kubernetes manifests continue working as they are (using arbitrary user ids there will require more changes).

elastic#18873)

Prepare docker images to be run with arbitrary user ids. Following common practices
and recommendations, files that need to be read by Beats have now read permissions
for the group and belong to the root group. Also, the user included in the docker image
is added to the root group so it can read these files when run on docker with default
user and privileges.

Some changes are also added to Kubernetes reference manifests to help running beats
with arbitrary user ids, though this is not completely supported and it requires additional
setup.

Co-authored-by: Michael Morello <[email protected]>
(cherry picked from commit 3ff02cb)
@jsoriano jsoriano added [zube]: In Review backport Team:Platforms Label for the Integrations - Platforms team labels Jul 1, 2020
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jul 1, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations-platforms (Team:Platforms)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Jul 1, 2020
@jsoriano jsoriano self-assigned this Jul 1, 2020
@jsoriano jsoriano merged commit 6d4bedb into elastic:7.x Jul 2, 2020
@jsoriano jsoriano deleted the backport_18873_7.x branch July 2, 2020 11:56
@zube zube bot removed the [zube]: Done label Oct 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Team:Platforms Label for the Integrations - Platforms team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants