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

⚠️ run BMO ironic deployment as non-root #1231

Merged
merged 1 commit into from
Mar 23, 2023

Conversation

tuminoid
Copy link
Member

@tuminoid tuminoid commented Mar 10, 2023

BMO ironic has no reason to run as root. Make it run as "ironic" user.

dnsmasq requires elevated capabiities. k8s is missing the feature of ambient capabilities, so it requires us to setcap the binaries with expected capabilities and container must be running with "allowPrivilegeEscalation: true" in the manifest to allow elevation.

Read the ambient capabilities KEP for more details: https://github.com/kubernetes/enhancements/blob/master/keps/sig-security/2763-ambient-capabilities/README.md

Add securityContext to BMO deployment manifest and keepalived component, with correct UIDs and GIDs. This is important to be able to share files via /shared.

Modify keepalived image to run as ironic user, which we use the same UID and GID as the ironic-image.

This commit requires ironic-image with PR metal3-io/ironic-image#410 to be merged to work.

@metal3-io-bot metal3-io-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 10, 2023
@tuminoid tuminoid changed the title WIP: try run ironic non-root to find out painpoints WIP: run BMO as non-root Mar 10, 2023
@tuminoid
Copy link
Member Author

/cc @elfosardo @dtantsur

This is still WIP, but I'd appreciate early comments.

tuminoid added a commit to Nordix/metal3-dev-env that referenced this pull request Mar 10, 2023
tuminoid added a commit to Nordix/metal3-dev-env that referenced this pull request Mar 10, 2023
tuminoid added a commit to Nordix/metal3-dev-env that referenced this pull request Mar 10, 2023
@tuminoid
Copy link
Member Author

/test-centos-e2e-integration-main

tuminoid added a commit to Nordix/metal3-dev-env that referenced this pull request Mar 10, 2023
@tuminoid
Copy link
Member Author

/test-centos-e2e-integration-main

As expected, this fails. This must run on top of Ironic image change.

@tuminoid tuminoid force-pushed the tuomo/run-ironic-non-root branch 2 times, most recently from 6ebd6aa to 88997cc Compare March 13, 2023 12:00
@dtantsur
Copy link
Member

The title is misleading: you're not updating just BMO. Let's maybe start with BMO itself since it is an easy win? And finish with dnsmasq which is the hardest.

@tuminoid
Copy link
Member Author

The title is misleading: you're not updating just BMO. Let's maybe start with BMO itself since it is an easy win? And finish with dnsmasq which is the hardest.

All the technical issues are solved, I just keep to update the pidfile location, and as discussed in Ironic-image PR, I will reuse existing users instead of nonroot and update the UID in this one. Combined BMO and Ironic-image test is running at metal3-io/metal3-dev-env#1172 and were passing already.

I will fix the commit message, title and description of the PR when I get those sorted out, and remove the WIP when its ready for review and merge.

@tuminoid tuminoid force-pushed the tuomo/run-ironic-non-root branch 2 times, most recently from 8d8c0bf to c59d776 Compare March 14, 2023 12:20
@tuminoid tuminoid changed the title WIP: run BMO as non-root ⚠️ run BMO deployment as non-root Mar 14, 2023
@metal3-io-bot metal3-io-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 14, 2023
tuminoid added a commit to Nordix/metal3-dev-env that referenced this pull request Mar 14, 2023
@tuminoid
Copy link
Member Author

tuminoid commented Mar 14, 2023

/hold

No longer WIP, but needs metal3-io/ironic-image#410 to be merged first to test.

@metal3-io-bot metal3-io-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 14, 2023
tuminoid added a commit to Nordix/metal3-dev-env that referenced this pull request Mar 14, 2023
@tuminoid
Copy link
Member Author

/cc @dtantsur @zaneb

PTAL.

@tuminoid tuminoid changed the title ⚠️ run BMO deployment as non-root ⚠️ run BMO ironic deployment as non-root Mar 15, 2023
@tuminoid
Copy link
Member Author

As requested on the ironic-image PR, I changed inspector container to run as ironic-inspector user, and keepalived back to nonroot as it is not sharing the filesystem with other containers.

tuminoid added a commit to Nordix/metal3-dev-env that referenced this pull request Mar 15, 2023
tuminoid added a commit to Nordix/metal3-dev-env that referenced this pull request Mar 15, 2023
BMO ironic has no reason to run as root. Make it run as "ironic" user.

dnsmasq requires elevated capabiities. k8s is missing the feature of
ambient capabilities, so it requires us to setcap the binaries with
expected capabilities and container must be running with
"allowPrivilegeEscalation: true" in the manifest to allow elevation.

Read the ambient capabilities KEP for more details:
https://github.com/kubernetes/enhancements/blob/master/keps/sig-security/2763-ambient-capabilities/README.md

Add securityContext to BMO deployment manifest and keepalived
component, with correct UIDs and GIDs. This is important to be able
to share files via /shared.

Modify keepalived image to run as ironic user, which we use the same
UID and GID as the ironic-image.

This commit requires ironic-image with PR
metal3-io/ironic-image#410 to be merged to
work.
@tuminoid
Copy link
Member Author

Let's see if it picks up the new ironic-image now.

/test-centos-e2e-integration-main
/test-ubuntu-integration-main

tuminoid added a commit to Nordix/metal3-dev-env that referenced this pull request Mar 17, 2023
@tuminoid
Copy link
Member Author

OK, we're passing tests here and in dev-env after fixing CI flake (corrupted node image was built). All comments should be addressed.

Can I get LGTM and approve for this as well? @zaneb @dtantsur @elfosardo

@tuminoid
Copy link
Member Author

/unhold

@metal3-io-bot metal3-io-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 20, 2023
@dtantsur
Copy link
Member

/lgtm

@metal3-io-bot metal3-io-bot added the lgtm Indicates that a PR is ready to be merged. label Mar 20, 2023
Copy link
Member

@kashifest kashifest left a comment

Choose a reason for hiding this comment

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

Thanks for this work. One small nit inline. Otherwise approved.

@metal3-io-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kashifest

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@metal3-io-bot metal3-io-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 23, 2023
@metal3-io-bot metal3-io-bot merged commit c496eac into metal3-io:main Mar 23, 2023
@kashifest
Copy link
Member

Ow it had lgtm already. Didnt notice.

@tuminoid tuminoid deleted the tuomo/run-ironic-non-root branch March 23, 2023 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants