Merge pull request #740 from Random-Liu/improve-gce-bootstrap

Improve gce bootstrapping in various ways.
This commit is contained in:
Lantao Liu
2018-04-18 14:12:27 -07:00
committed by GitHub
19 changed files with 246 additions and 236 deletions

View File

@@ -0,0 +1,49 @@
#!/bin/bash
# Copyright 2018 The containerd 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.
set -o errexit
set -o nounset
set -o pipefail
source $(dirname "${BASH_SOURCE[0]}")/utils.sh
CNI_CONFIG_DIR=${DESTDIR}/etc/cni/net.d
${SUDO} mkdir -p ${CNI_CONFIG_DIR}
${SUDO} bash -c 'cat >'${CNI_CONFIG_DIR}'/10-containerd-net.conflist <<EOF
{
"cniVersion": "0.3.1",
"name": "containerd-net",
"plugins": [
{
"type": "bridge",
"bridge": "cni0",
"isGateway": true,
"ipMasq": true,
"promiscMode": true,
"ipam": {
"type": "host-local",
"subnet": "10.88.0.0/16",
"routes": [
{ "dst": "0.0.0.0/0" }
]
}
},
{
"type": "portmap",
"capabilities": {"portMappings": true}
}
]
}
EOF'

View File

@@ -20,7 +20,6 @@ set -o pipefail
source $(dirname "${BASH_SOURCE[0]}")/utils.sh
CNI_DIR=${DESTDIR}/opt/cni
CNI_CONFIG_DIR=${DESTDIR}/etc/cni/net.d
CNI_PKG=github.com/containernetworking/plugins
# Create a temporary GOPATH for cni installation.
@@ -34,33 +33,6 @@ cd ${GOPATH}/src/${CNI_PKG}
FASTBUILD=true ./build.sh
${SUDO} mkdir -p ${CNI_DIR}
${SUDO} cp -r ./bin ${CNI_DIR}
${SUDO} mkdir -p ${CNI_CONFIG_DIR}
${SUDO} bash -c 'cat >'${CNI_CONFIG_DIR}'/10-containerd-net.conflist <<EOF
{
"cniVersion": "0.3.1",
"name": "containerd-net",
"plugins": [
{
"type": "bridge",
"bridge": "cni0",
"isGateway": true,
"ipMasq": true,
"promiscMode": true,
"ipam": {
"type": "host-local",
"subnet": "10.88.0.0/16",
"routes": [
{ "dst": "0.0.0.0/0" }
]
}
},
{
"type": "portmap",
"capabilities": {"portMappings": true}
}
]
}
EOF'
# Clean the tmp GOPATH dir.
rm -rf ${TMPGOPATH}

View File

@@ -34,6 +34,9 @@ cd $(dirname "${BASH_SOURCE[0]}")
# and configurations in cluster.
INSTALL_CNI=${INSTALL_CNI:-true}
# INSTALL_CNI indicates whether to install CNI config.
INSTALL_CNI_CONFIG=${INSTALL_CNI_CONFIG:-true}
# Install runc
./install-runc.sh
@@ -42,6 +45,11 @@ if ${INSTALL_CNI}; then
./install-cni.sh
fi
# Install cni config
if ${INSTALL_CNI_CONFIG}; then
./install-cni-config.sh
fi
# Install containerd
./install-containerd.sh

View File

@@ -43,7 +43,8 @@ fi
rm -rf ${destdir}
# Install dependencies into release stage.
NOSUDO=true INSTALL_CNI=${INCLUDE_CNI} DESTDIR=${destdir} ./hack/install/install-deps.sh
NOSUDO=true INSTALL_CNI=${INCLUDE_CNI} INSTALL_CNI_CONFIG=false DESTDIR=${destdir} \
./hack/install/install-deps.sh
if ${CUSTOM_CONTAINERD}; then
make install -e DESTDIR=${destdir}
@@ -56,7 +57,9 @@ cp ${ROOT}/contrib/systemd-units/* ${destdir}/etc/systemd/system/
mkdir -p ${destdir}/opt/containerd
cp -r ${ROOT}/cluster ${destdir}/opt/containerd
# Write a version file into the release tarball.
echo ${VERSION} > ${destdir}/opt/containerd/cluster/version
cat > ${destdir}/opt/containerd/cluster/version <<EOF
CONTAINERD_VERSION: $(yaml-quote ${VERSION})
EOF
# Create release tar
tarball=${BUILD_DIR}/${TARBALL}

View File

@@ -40,7 +40,7 @@ test_setup() {
exit 1
fi
sudo pkill -x containerd
keepalive "sudo ${ROOT}/_output/containerd ${CONTAINERD_FLAGS}" \
keepalive "sudo PATH=${PATH} ${ROOT}/_output/containerd ${CONTAINERD_FLAGS}" \
${RESTART_WAIT_PERIOD} &> ${report_dir}/containerd.log &
containerd_pid=$!
# Wait for containerd to be running by using the containerd client ctr to check the version

View File

@@ -95,3 +95,10 @@ from-vendor() {
fi
eval $setvars
}
# yaml-quote quotes something appropriate for a yaml string.
# This is the same with:
# https://github.com/kubernetes/kubernetes/blob/v1.10.1/cluster/gce/util.sh#L471.
yaml-quote() {
echo "'$(echo "${@:-}" | sed -e "s/'/''/g")'"
}