From fcd5afa152e90291621eab3d6369e9cd0736a1f6 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Tue, 1 Aug 2017 15:52:11 +0100 Subject: [PATCH] kubernetes: Adjust for /var/run->/run symlink PR #2314 turned /var into a tmpfs (possibly overmounted by a persistent disk) and made /var/run into a symlink to /run. Adjust various containers and bind mount settings to allow for this change. In particular ensuring that everything can find the correct shared /var/run/docker.sock, which due to the symlink is now actually at /run. Signed-off-by: Ian Campbell --- projects/kubernetes/image-cache/Dockerfile | 2 ++ projects/kubernetes/kube-master.yml | 1 + projects/kubernetes/kube-node.yml | 1 + projects/kubernetes/kubernetes/Dockerfile | 4 +++- 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/projects/kubernetes/image-cache/Dockerfile b/projects/kubernetes/image-cache/Dockerfile index 39e68d3e2..31910a794 100644 --- a/projects/kubernetes/image-cache/Dockerfile +++ b/projects/kubernetes/image-cache/Dockerfile @@ -12,6 +12,8 @@ RUN apk add --no-cache --initdb -p /out \ # Remove apk residuals. We have a read-only rootfs, so apk is of no use. RUN rm -rf /out/etc/apk /out/lib/apk /out/var/cache +RUN rmdir /out/var/run && ln -nfs /run /out/var/run + FROM scratch WORKDIR / COPY --from=build /out / diff --git a/projects/kubernetes/kube-master.yml b/projects/kubernetes/kube-master.yml index d6e3e1abc..07f5a7184 100644 --- a/projects/kubernetes/kube-master.yml +++ b/projects/kubernetes/kube-master.yml @@ -51,6 +51,7 @@ services: - /dev:/dev - /etc/resolv.conf:/etc/resolv.conf - /lib/modules:/lib/modules + - /run:/run:rshared,rbind - /var:/var:rshared,rbind - /var/lib/kubeadm:/etc/kubernetes - /etc/cni:/etc/cni:rshared,rbind diff --git a/projects/kubernetes/kube-node.yml b/projects/kubernetes/kube-node.yml index 9a3ae3691..78cbf19aa 100644 --- a/projects/kubernetes/kube-node.yml +++ b/projects/kubernetes/kube-node.yml @@ -51,6 +51,7 @@ services: - /dev:/dev - /etc/resolv.conf:/etc/resolv.conf - /lib/modules:/lib/modules + - /run:/run:rshared,rbind - /var:/var:rshared,rbind - /var/lib/kubeadm:/etc/kubernetes - /etc/cni:/etc/cni:rshared,rbind diff --git a/projects/kubernetes/kubernetes/Dockerfile b/projects/kubernetes/kubernetes/Dockerfile index 6b5bfb057..5d615b948 100644 --- a/projects/kubernetes/kubernetes/Dockerfile +++ b/projects/kubernetes/kubernetes/Dockerfile @@ -30,6 +30,8 @@ RUN apk add --no-cache --initdb -p /out \ # Remove apk residuals. We have a read-only rootfs, so apk is of no use. RUN rm -rf /out/etc/apk /out/lib/apk /out/var/cache +RUN rmdir /out/var/run && ln -nfs /run /out/var/run + RUN curl -fSL -o /tmp/cni.tgz https://github.com/containernetworking/cni/releases/download/v0.5.2/cni-amd64-${cni_version}.tgz && \ mkdir -p /out/opt/cni/bin /out/etc/cni/net.d && \ tar -xzf /tmp/cni.tgz -C /out/opt/cni/bin @@ -47,4 +49,4 @@ WORKDIR / ENTRYPOINT ["/usr/bin/kubelet.sh"] COPY --from=build /out / ENV KUBECONFIG "/etc/kubernetes/admin.conf" -LABEL org.mobyproject.config='{"binds": ["/dev:/dev", "/etc/resolv.conf:/etc/resolv.conf", "/var:/var:rshared,rbind", "/var/lib/kubeadm:/etc/kubernetes", "/etc/cni:/rootfs/etc/cni:rshared,rbind", "/opt/cni:/rootfs/opt/cni:rshared,rbind"], "mounts": [{"type": "cgroup", "options": ["rw","nosuid","noexec","nodev","relatime"]}], "capabilities": ["all"], "rootfsPropagation": "shared", "pid": "host"}' +LABEL org.mobyproject.config='{"binds": ["/dev:/dev", "/etc/resolv.conf:/etc/resolv.conf", "/run:/run", "/var:/var:rshared,rbind", "/var/lib/kubeadm:/etc/kubernetes", "/etc/cni:/rootfs/etc/cni:rshared,rbind", "/opt/cni:/rootfs/opt/cni:rshared,rbind"], "mounts": [{"type": "cgroup", "options": ["rw","nosuid","noexec","nodev","relatime"]}], "capabilities": ["all"], "rootfsPropagation": "shared", "pid": "host"}'