In gci mounter script, expose /var/lib/kubelet only and add more debugging logs.

Added a retry for rkt gc just to be safe.

Signed-off-by: Vishnu Kannan <vishnuk@google.com>
pull/6/head
Vishnu Kannan 2016-10-28 13:40:30 -07:00 committed by Vishnu kannan
parent 1ecc12f724
commit e5c61922f8
1 changed files with 14 additions and 3 deletions

View File

@ -23,14 +23,25 @@ MOUNTER_USER=root
RKT_BINARY=/home/kubernetes/bin/rkt
function gc {
${RKT_BINARY} gc --grace-period=0s &> /dev/null
# Attempt to garbage collect rkt pods with 5 retries.
# Rkt pods end up creating new copies of mounts on the host. Hence it is ideal to clean them up right away.
attempt=0
until [ $attempt -ge 5 ]; do
${RKT_BINARY} gc --grace-period=0s && break
attempt=$[$attempt+1]
sleep 1
done
}
# Garbage collect old rkt containers on exit
trap gc EXIT
echo "Running mount using a rkt fly container"
${RKT_BINARY} run --stage1-name="coreos.com/rkt/stage1-fly:1.18.0" \
--insecure-options=image \
--volume=rootfs,kind=host,source=/,readOnly=false,recursive=true \
--mount volume=rootfs,target=/media/root \
--volume=kubelet,kind=host,source=/var/lib/kubelet,readOnly=false,recursive=true \
--mount volume=kubelet,target=/var/lib/kubelet \
docker://${MOUNTER_DOCKER_IMAGE}:${MOUNTER_DOCKER_VERSION} --user=${MOUNTER_USER} --exec /bin/mount -- "$@"
echo "Successfully ran mount using a rkt fly container"