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

hubble-relay: use distroless as the base image and run as non-root #23259

Merged
merged 2 commits into from Jan 25, 2023

Conversation

rolinh
Copy link
Member

@rolinh rolinh commented Jan 23, 2023

In order to improve the security posture of Hubble Relay, this patch updates the base image for Hubble Relay from scratch to distroless. Distroless images come in different variants and the one being used here is the most basic one that only contains the following:

  • ca-certificates
  • A /etc/passwd entry for a root, nonroot and nobody users
  • A /tmp directory
  • tzdata

Given that this new base image comes with CA certificates, we no longer need to import CA certificates from the Alpine image. Moreover, the hack for running gops, namely setting ENV GOPS_CONFIG_DIR=/ is no longer required. Finally, the patch sets the image user to the nonroot user with UID 65532.

At last, to run as non-root, the securityContext for the Hubble Relay container is updated to drop all capabilities and run as the user:group 65532:65532.

Run Hubble Relay as non-root user by default.

@rolinh rolinh added release-note/misc This PR makes changes that have no direct user impact. sig/hubble Impacts hubble server or relay labels Jan 23, 2023
@rolinh rolinh requested review from a team as code owners January 23, 2023 16:33
@rolinh rolinh requested a review from sayboras January 23, 2023 16:33
@rolinh rolinh force-pushed the pr/rolinh/rootless-relay branch 2 times, most recently from 1687951 to c8261a1 Compare January 23, 2023 16:40
@rolinh
Copy link
Member Author

rolinh commented Jan 23, 2023

/test

Job 'Cilium-PR-K8s-1.24-kernel-5.4' failed:

Click to show.

Test Name

K8sDatapathConfig Host firewall With VXLAN and endpoint routes

Failure Output

FAIL: Found 1 k8s-app=cilium logs matching list of errors that must be investigated:

If it is a flake and a GitHub issue doesn't already exist to track it, comment /mlh new-flake Cilium-PR-K8s-1.24-kernel-5.4 so I can create one.

Copy link
Contributor

@michi-covalent michi-covalent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

Copy link
Contributor

@chancez chancez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth adding a note in upgrade.rst.

@rolinh
Copy link
Member Author

rolinh commented Jan 24, 2023

/test

images/hubble-relay/Dockerfile Show resolved Hide resolved
Documentation/operations/upgrade.rst Outdated Show resolved Hide resolved
These docs are already stored in the v1.12 branch and exposed via the
corresponding docs on docs.cilium.io, so there is no need to include
that text directly in the page. Removing it will also help developers to
update the correct notes for the upcoming release.

Signed-off-by: Robin Hahling <robin.hahling@gw-computing.net>
In order to improve the security posture of Hubble Relay, this patch
updates the base image for Hubble Relay from scratch to distroless.
Distroless images come in different variants and the one being used here
is the most basic one that only contains the following:

  - ca-certificates
  - A /etc/passwd entry for a root, nonroot and nobody users
  - A /tmp directory
  - tzdata

Given that this new base image comes with CA certificates, we no longer
need to import CA certificates from the Alpine image. Moreover, the hack
for running gops, namely setting `ENV GOPS_CONFIG_DIR=/` is no longer
required. Finally, the patch sets the image user to the nonroot user
with UID 65532.

At last, to run as non-root, the securityContext for the Hubble Relay
container is updated to drop all capabilities and run as the user:group
65532:65532.

Signed-off-by: Robin Hahling <robin.hahling@gw-computing.net>
Copy link
Member

@qmonnet qmonnet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, nice!

@qmonnet qmonnet added the area/documentation Impacts the documentation, including textual changes, sphinx, or other doc generation code. label Jan 24, 2023
@rolinh rolinh added the area/helm Impacts helm charts and user deployment experience label Jan 24, 2023
@rolinh
Copy link
Member Author

rolinh commented Jan 24, 2023

/test

Copy link
Member

@sayboras sayboras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ✔️

Copy link
Member

@kaworu kaworu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Jan 25, 2023
@ldelossa ldelossa merged commit 95a4d37 into master Jan 25, 2023
@ldelossa ldelossa deleted the pr/rolinh/rootless-relay branch January 25, 2023 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/documentation Impacts the documentation, including textual changes, sphinx, or other doc generation code. area/helm Impacts helm charts and user deployment experience ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact. sig/hubble Impacts hubble server or relay
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants