kubernetes/pkg/util
Kubernetes Submit Queue d2495b8329
Merge pull request #63143 from jsafrane/containerized-subpath
Automatic merge from submit-queue (batch tested with PRs 63348, 63839, 63143, 64447, 64567). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Containerized subpath

**What this PR does / why we need it**:
Containerized kubelet needs a different implementation of `PrepareSafeSubpath` than kubelet running directly on the host.

On the host we safely open the subpath and then bind-mount `/proc/<pidof kubelet>/fd/<descriptor of opened subpath>`.

With kubelet running in a container, `/proc/xxx/fd/yy` on the host contains path that works only inside the container, i.e. `/rootfs/path/to/subpath` and thus any bind-mount on the host fails.

Solution:
- safely open the subpath and gets its device ID and inode number
- blindly bind-mount the subpath to `/var/lib/kubelet/pods/<uid>/volume-subpaths/<name of container>/<id of mount>`. This is potentially unsafe, because user can change the subpath source to a link to a bad place (say `/run/docker.sock`) just before the bind-mount.
- get device ID and inode number of the destination. Typical users can't modify this file, as it lies on /var/lib/kubelet on the host.
- compare these device IDs and inode numbers.

**Which issue(s) this PR fixes**
Fixes #61456

**Special notes for your reviewer**:

The PR contains some refactoring of `doBindSubPath` to extract the common code. New `doNsEnterBindSubPath` is added for the nsenter related parts.

**Release note**:

```release-note
NONE
```
2018-06-01 12:12:19 -07:00
..
async Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
bandwidth Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
config Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
configz set right Content-Type for configz 2018-03-29 16:07:47 +08:00
conntrack Auto-updated BUILD files 2018-02-27 11:18:11 -08:00
dbus Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
ebtables Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
env Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
file Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
filesystem unpack dynamic kubelet config payloads to files 2018-04-19 09:18:53 -07:00
flag Log the command line flags 2018-02-15 18:04:04 -05:00
flock Autogenerate BUILD files 2017-12-23 13:12:11 -08:00
goroutinemap Merge pull request #59714 from hzxuzhonghu/clean-up-goroutinemap 2018-02-27 12:05:40 -08:00
hash Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
initsystem kubeadm: Write kubelet config file to disk and persist in-cluster. Also write runtime environment file and fixup the kubelet phases command 2018-05-22 09:12:25 +03:00
interrupt update BUILD files 2017-10-15 18:18:13 -07:00
io Pass Nsenter to NsenterMounter and NsenterWriter 2018-05-23 10:21:21 +02:00
ipconfig Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
ipset Add comments for ipset entries in kube-proxy 2018-05-11 17:11:34 +08:00
iptables iptables: add timeout when checking rules 2018-05-02 16:25:17 +08:00
ipvs auto generated file 2018-05-22 11:20:47 +08:00
keymutex Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
labels Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
limitwriter Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
maps update BUILD files 2017-10-15 18:18:13 -07:00
metrics Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
mount Merge pull request #63143 from jsafrane/containerized-subpath 2018-06-01 12:12:19 -07:00
net Auto-updated BUILD files 2018-02-27 11:18:11 -08:00
netsh Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
node Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
normalizer Clone documentation utility from //pkg/kubectl/cmd/templates 2017-11-16 10:18:00 +01:00
nsenter Nsenter unit tests 2018-05-23 10:21:21 +02:00
oom Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
parsers Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
pod add utils to patch pod status 2018-05-30 11:15:47 -07:00
pointer pkg/util/pointer: Update int pointer functions 2018-03-27 10:30:01 -04:00
procfs Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
reflector/prometheus rename metric reflector_xx_last_resource_version to reflector_last_resource_version{name="xx"} 2017-11-01 16:34:18 +08:00
removeall Enhance ExistsPath check 2018-05-23 10:21:20 +02:00
resizefs Perform resize of mounted volume if necessary 2018-01-29 17:49:50 -05:00
resourcecontainer Autogenerate BUILD files 2017-12-23 13:12:11 -08:00
rlimit Autogenerate BUILD files 2017-12-23 13:12:11 -08:00
selinux Autogenerate BUILD files 2017-12-23 13:12:11 -08:00
slice Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
strings Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
sysctl update BUILD files 2017-10-15 18:18:13 -07:00
system Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
tail Merge pull request #59713 from hanxiaoshuai/fix0211 2018-02-22 23:17:38 -08:00
taints Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
template Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
term Autogenerate BUILD files 2017-12-23 13:12:11 -08:00
threading Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
tolerations Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
version Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
workqueue/prometheus update BUILD files 2017-10-15 18:18:13 -07:00
BUILD add utils to patch pod status 2018-05-30 11:15:47 -07:00
verify-util-pkg.sh Update all script to use /usr/bin/env bash in shebang 2018-04-19 13:20:13 +02:00