Run istio-init with non-root UID#20380
Conversation
|
The capabilities are not yet sufficient: |
|
The inability to read See the kernel patch that enforces that. I will try to work around this by passing |
2b63f9e to
3749b90
Compare
|
Passing |
|
Passing It's weird that |
|
The
In this run, the call to |
|
The
This call shouldn't fail. This container has This matches the actual implementation in the kernel: |
|
One hypothesis is that the Docker host is running LSM modules with a policy which prevents opening raw sockets, like in this SELinux bug: https://bugzilla.redhat.com/show_bug.cgi?id=1179489 |
sdake
left a comment
There was a problem hiding this comment.
looks good - although the RAW socket usage is strongly discouraged by everyone going back 30+ years :). For CentOS based distros, have a look at https://bugzilla.redhat.com/show_bug.cgi?id=1133654
Which distro are you struggling to get this runnign on?
3749b90 to
ff3d0bc
Compare
410ac12 to
ac7153e
Compare
CAP_NET_RAW is required by iptables. |
|
Tests still fail, likely because of |
|
My hypothesis is that this is hitting Docker's years-old bug about not setting ambient capabilities. |
|
cc @mandarjog fyi |
a252727 to
bac5f38
Compare
|
@istio/wg-config-maintainers please review! |
howardjohn
left a comment
There was a problem hiding this comment.
The idea lgtm, can we look into making the docker files a bit simpler?
Update the base image's version BASE_VERSION to 1.6-dev.1, which has the libcap2-bin package installed. Use the setcap command from libcap2-bin to add CAP_NET_ADMIN and CAP_NET_RAW as Permitted capabilities on the istio-iptables binary. Modfiy istio-iptables to add CAP_NET_ADMIN and CAP_NET_RAW as ambient capabilities when exec'ing any iptables command.
bac5f38 to
4a51bf7
Compare
Addressed comments: installed libcap2-bin in base image.
|
/cherrypick release-1.3 |
|
@rlenglet: #20380 failed to apply on top of branch "release-1.3": DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
/cherrypick release-1.5 |
|
@rlenglet: #20380 failed to apply on top of branch "release-1.5": DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
This reverts commit 0996b80.
|
master build crashes in my GKE cluster, with kernel version |
* Run istio-init with UID 1337 * Make make common-test pass * Limit iptables-restore/save to only the tables used * Set the ambient capabilities for iptables commands Update the base image's version BASE_VERSION to 1.6-dev.1, which has the libcap2-bin package installed. Use the setcap command from libcap2-bin to add CAP_NET_ADMIN and CAP_NET_RAW as Permitted capabilities on the istio-iptables binary. Modfiy istio-iptables to add CAP_NET_ADMIN and CAP_NET_RAW as ambient capabilities when exec'ing any iptables command.
This reverts commit 0996b80.
istio-initcontainer with UID 1337 instead of UID 0.--table=mangle --table=natarguments to everyiptablescommand to explicitly specify the tables to setup / clean, so it won't try to access file/proc/net/ip_tables_nameswhich is accessible only to UID/GID 0.CAP_NET_ADMINandCAP_NET_RAWas ambient capabilities inistio-iptablesto make them inherited and effective when callingiptablescommands, even whenistio-iptablesruns as non-root. ❗️This requires Linux kernel version ≥4.3.CAP_NET_ADMINandCAP_NET_RAWas permitted capabilities on theistio-iptablesbinary in theproxyv2Docker image. ❗️This requires a filesystem supporting extended attributes. The benefits of running as non-root outweigh the (small) risk of encountering a platform which filesystem doesn't support extended attributes.The
CAP_SYS_MODULEcapability is not added to theistio-initcontainer. It is normally needed byiptablesto install kernel modules if they are not compiled into the kernel or already loaded. The previous configuration (non-privileged, UID 0, noCAP_SYS_MODULEcapability) has always preventedistio-initfrom loading modules anyway, so this is not an issue.