• Kubernetes Submit Queue's avatar
    Merge pull request #62057 from cofyc/fixlocalupscript · b2f19b0d
    Kubernetes Submit Queue authored
    Automatic merge from submit-queue (batch tested with PRs 58784, 62057, 62621, 62652, 62656). 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>.
    
    Update docker run flags for containized kubelet in hack/local-up-cluster.sh
    
    **What this PR does / why we need it**:
    
    I'm working on https://github.com/kubernetes/kubernetes/issues/61741, and found `docker run` flags in `hack/local-up-cluster.sh` for kubelet container is too old.
    
    - /var/lib/docker should be mount read-write, because kubelet needs to
      update /etc/resolv.conf file in container, see #29378
    - /var/lib/kubelet should be mount shared, because mountpoints under
      this directory must be propagated to other containers
    - `--pid=host` is needed to run `nsenter --mount=/rootfs/proc/1/ns/mnt -- /usr/bin/systemd-run --scope` correctly (don't know exact reason, but with `--pid=host`, it works)
    - configure cluster dns for kubelet running in a container
    - should propagate sub-mounts of / to kubelet for local volume
    
    With this fix, we can start a local cluster with containerized kubelet.
    
    ```
    # pull or build a hyperkube image first
    docker tag k8s.gcr.io/hyperkube-amd64:<tag> k8s.gcr.io/kubelet:latest
    export DOCKERIZE_KUBELET=y
    ./hack/local-up-cluster.sh
    ```
    
    **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
    Fixes #
    
    **Special notes for your reviewer**:
    
    refer to: https://github.com/kubernetes/kubernetes-anywhere/blob/master/phase2/ignition/vanilla/kubelet.service.
    
    **Release note**:
    
    ```release-note
    NONE
    ```
    b2f19b0d
local-up-cluster.sh 39 KB