mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-10 12:32:03 +00:00
Make gci mounter pre-fetch mounter image to reduce startup latency during runtime
Signed-off-by: Vishnu kannan <vishnuk@google.com>
This commit is contained in:
parent
d07396f7c7
commit
773ad9be29
@ -24,13 +24,14 @@ ROOT_DIR=/home/kubernetes/bin
|
|||||||
RKT_BINARY=${ROOT_DIR}/rkt
|
RKT_BINARY=${ROOT_DIR}/rkt
|
||||||
STAGE1_ACI=${ROOT_DIR}/stage1-fly.aci
|
STAGE1_ACI=${ROOT_DIR}/stage1-fly.aci
|
||||||
MOUNTER_ACI=${ROOT_DIR}/gci-mounter-${MOUNTER_VERSION}.aci
|
MOUNTER_ACI=${ROOT_DIR}/gci-mounter-${MOUNTER_VERSION}.aci
|
||||||
|
MOUNTER_IMAGE=gcr.io/google_containers/gci-mounter:${MOUNTER_VERSION}
|
||||||
|
|
||||||
function gc {
|
function gc {
|
||||||
# Attempt to garbage collect rkt pods with 5 retries.
|
# 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.
|
# Rkt pods end up creating new copies of mounts on the host. Hence it is ideal to clean them up right away.
|
||||||
attempt=0
|
attempt=0
|
||||||
until [ $attempt -ge 5 ]; do
|
until [ $attempt -ge 5 ]; do
|
||||||
${RKT_BINARY} gc --grace-period=0s && break
|
${RKT_BINARY} gc --grace-period=0s &> /dev/null && break
|
||||||
attempt=$[$attempt+1]
|
attempt=$[$attempt+1]
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
@ -39,12 +40,16 @@ function gc {
|
|||||||
# Garbage collect old rkt containers on exit
|
# Garbage collect old rkt containers on exit
|
||||||
trap gc EXIT
|
trap gc EXIT
|
||||||
|
|
||||||
|
if [[ ! $(${RKT_BINARY} image list | grep ${MOUNTER_IMAGE}) ]]; then
|
||||||
|
${RKT_BINARY} fetch --insecure-options=image file://${MOUNTER_ACI}
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Running mount using a rkt fly container"
|
echo "Running mount using a rkt fly container"
|
||||||
|
|
||||||
${RKT_BINARY} run --stage1-path=${STAGE1_ACI} \
|
${RKT_BINARY} run --stage1-path=${STAGE1_ACI} \
|
||||||
--insecure-options=image \
|
--insecure-options=image \
|
||||||
--volume=kubelet,kind=host,source=/var/lib/kubelet,readOnly=false,recursive=true \
|
--volume=kubelet,kind=host,source=/var/lib/kubelet,readOnly=false,recursive=true \
|
||||||
--mount volume=kubelet,target=/var/lib/kubelet \
|
--mount volume=kubelet,target=/var/lib/kubelet \
|
||||||
file://${MOUNTER_ACI} --user=${MOUNTER_USER} --exec /bin/mount -- "$@"
|
${MOUNTER_IMAGE} --user=${MOUNTER_USER} --exec /bin/mount -- "$@"
|
||||||
|
|
||||||
echo "Successfully ran mount using a rkt fly container"
|
echo "Successfully ran mount using a rkt fly container"
|
||||||
|
@ -1,5 +1,24 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Copyright 2016 The Kubernetes Authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
# Due to the GCE custom metadata size limit, we split the entire script into two
|
||||||
|
# files configure.sh and configure-helper.sh. The functionality of downloading
|
||||||
|
# kubernetes configuration, manifests, docker images, and binary files are
|
||||||
|
# put in configure.sh, which is uploaded via GCE custom metadata.
|
||||||
|
|
||||||
set -o errexit
|
set -o errexit
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
set -o nounset
|
set -o nounset
|
||||||
|
Loading…
Reference in New Issue
Block a user