kubernetes/pkg/kubelet/cm
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
..
cpumanager avoid dobule RLock() in cpumanager 2018-04-23 10:33:40 +08:00
cpuset Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
devicemanager Move pkg/scheduler/schedulercache -> pkg/scheduler/cache 2018-05-31 22:55:34 +08:00
util Autogenerate BUILD files 2017-12-23 13:12:11 -08:00
BUILD Move pkg/scheduler/schedulercache -> pkg/scheduler/cache 2018-05-31 22:55:34 +08:00
cgroup_manager_linux.go Use a []string for CgroupName, which is a more accurate internal representation 2018-05-01 08:29:06 -07:00
cgroup_manager_linux_test.go Use a []string for CgroupName, which is a more accurate internal representation 2018-05-01 08:29:06 -07:00
cgroup_manager_test.go Lift embedded structure out of eviction-related KubeletConfiguration fields 2017-11-16 18:35:13 -08:00
cgroup_manager_unsupported.go Use a []string for CgroupName, which is a more accurate internal representation 2018-05-01 08:29:06 -07:00
container_manager.go Move pkg/scheduler/schedulercache -> pkg/scheduler/cache 2018-05-31 22:55:34 +08:00
container_manager_linux.go Move pkg/scheduler/schedulercache -> pkg/scheduler/cache 2018-05-31 22:55:34 +08:00
container_manager_linux_test.go Enhance ExistsPath check 2018-05-23 10:21:20 +02:00
container_manager_stub.go Move pkg/scheduler/schedulercache -> pkg/scheduler/cache 2018-05-31 22:55:34 +08:00
container_manager_unsupported.go Remove redundant code in container manager. 2017-11-24 03:15:55 -08:00
container_manager_windows.go Extends deviceplugin to gracefully handle full device plugin lifecycle. 2017-11-20 23:40:14 -08:00
fake_internal_container_lifecycle.go Un-revert "CPU manager wiring and none policy" 2017-09-04 07:24:59 -07:00
helpers_linux.go Fix cpu cfs quota flag with pod cgroups 2018-03-16 15:27:11 -04:00
helpers_linux_test.go Merge pull request #56525 from tianshapjq/testcase-helpers_linux.go 2018-04-20 18:55:13 -07:00
helpers_unsupported.go Fix cpu cfs quota flag with pod cgroups 2018-03-16 15:27:11 -04:00
internal_container_lifecycle.go Fixed nil InternalContainerLifecycle in cm stubs. 2017-09-04 07:24:59 -07:00
node_container_manager.go Use a []string for CgroupName, which is a more accurate internal representation 2018-05-01 08:29:06 -07:00
node_container_manager_test.go codeClean-merge-logfAndFailnow-to-fatalf 2018-01-31 11:39:31 +08:00
OWNERS Add ConnorDoyle as approver in /pkg/kubelet/cm. 2017-12-06 09:05:59 -06:00
pod_container_manager_linux.go Merge pull request #63344 from RobertKrawitz/fix-process-kill-algorithm 2018-05-11 11:41:19 -07:00
pod_container_manager_linux_test.go Apply pod name and namespace labels for pod cgroup for cadvisor metrics 2018-05-07 14:51:12 -04:00
pod_container_manager_stub.go Apply pod name and namespace labels for pod cgroup for cadvisor metrics 2018-05-07 14:51:12 -04:00
pod_container_manager_unsupported.go Remove redundant code in container manager. 2017-11-24 03:15:55 -08:00
qos_container_manager_linux.go Use a []string for CgroupName, which is a more accurate internal representation 2018-05-01 08:29:06 -07:00
types.go Apply pod name and namespace labels for pod cgroup for cadvisor metrics 2018-05-07 14:51:12 -04:00