-
Notifications
You must be signed in to change notification settings - Fork 584
/
Copy pathci-bootstrap.yaml
92 lines (73 loc) · 3.83 KB
/
ci-bootstrap.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
preKubeadmCommands:
- bash -c /tmp/kubeadm-bootstrap.sh
files:
- path: /tmp/kubeadm-bootstrap.sh
owner: "root:root"
permissions: "0744"
content: |
#!/bin/bash
set -o nounset
set -o pipefail
set -o errexit
[[ $(id -u) != 0 ]] && SUDO="sudo" || SUDO=""
GSUTIL=gsutil
if ! command -v ${GSUTIL} > /dev/null; then
curl -sSL https://sdk.cloud.google.com > /tmp/gcl && bash /tmp/gcl --install-dir=~/gcloud --disable-prompts > /dev/null 2>&1
GSUTIL=~/gcloud/google-cloud-sdk/bin/gsutil
# For faster downloads
pip install --no-cache-dir -U crcmod
fi
${GSUTIL} version
# This test installs release packages or binaries that are a result of the CI and release builds.
# It runs '... --version' commands to verify that the binaries are correctly installed
# and finally uninstalls the packages.
# For the release packages it tests all versions in the support skew.
LINE_SEPARATOR="*************************************************"
echo "$LINE_SEPARATOR"
CI_VERSION=${CI_VERSION:-""}
if [[ "${CI_VERSION}" != "" ]]; then
CI_DIR=/tmp/k8s-ci
mkdir -p $CI_DIR
declare -a PACKAGES_TO_TEST=("kubectl" "kubelet" "kubeadm")
declare -a CONTAINERS_TO_TEST=("kube-apiserver" "kube-controller-manager" "kube-proxy" "kube-scheduler")
CONTAINER_EXT="tar"
echo "* testing CI version $CI_VERSION"
# Check for semver
if [[ "${CI_VERSION}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
CI_URL="gs://kubernetes-release/release/$CI_VERSION/bin/linux/amd64"
VERSION_WITHOUT_PREFIX="${CI_VERSION#v}"
DEBIAN_FRONTEND=noninteractive apt-get install -y apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
echo 'deb https://apt.kubernetes.io/ kubernetes-xenial main' > /etc/apt/sources.list.d/kubernetes.list
apt-get update
# replace . with \.
VERSION_REGEX="${VERSION_WITHOUT_PREFIX//./\\.}"
PACKAGE_VERSION="$(apt-cache madison kubelet|grep ${VERSION_REGEX}- | head -n1 | cut -d '|' -f 2 | tr -d '[:space:]')"
for CI_PACKAGE in "${PACKAGES_TO_TEST[@]}"; do
echo "* installing package: $CI_PACKAGE ${PACKAGE_VERSION}"
DEBIAN_FRONTEND=noninteractive apt-get install -y $CI_PACKAGE=$PACKAGE_VERSION
done
else
CI_URL="gs://kubernetes-release-dev/ci/$CI_VERSION-bazel/bin/linux/amd64"
for CI_PACKAGE in "${PACKAGES_TO_TEST[@]}"; do
echo "* downloading binary: $CI_URL/$CI_PACKAGE"
${GSUTIL} cp "$CI_URL/$CI_PACKAGE" "$CI_DIR/$CI_PACKAGE"
chmod +x "$CI_DIR/$CI_PACKAGE"
mv "$CI_DIR/$CI_PACKAGE" "/usr/bin/$CI_PACKAGE"
done
systemctl restart kubelet
fi
for CI_CONTAINER in "${CONTAINERS_TO_TEST[@]}"; do
echo "* downloading package: $CI_URL/$CI_CONTAINER.$CONTAINER_EXT"
${GSUTIL} cp "$CI_URL/$CI_CONTAINER.$CONTAINER_EXT" "$CI_DIR/$CI_CONTAINER.$CONTAINER_EXT"
${SUDO} ctr -n k8s.io images import "$CI_DIR/$CI_CONTAINER.$CONTAINER_EXT" || echo "* ignoring expected 'ctr images import' result"
${SUDO} ctr -n k8s.io images tag k8s.gcr.io/$CI_CONTAINER-amd64:"${CI_VERSION//+/_}" k8s.gcr.io/$CI_CONTAINER:"${CI_VERSION//+/_}"
${SUDO} ctr -n k8s.io images tag k8s.gcr.io/$CI_CONTAINER-amd64:"${CI_VERSION//+/_}" gcr.io/kubernetes-ci-images/$CI_CONTAINER:"${CI_VERSION//+/_}"
done
fi
echo "* checking binary versions"
echo "ctr version: " $(ctr version)
echo "kubeadm version: " $(kubeadm version -o=short)
echo "kubectl version: " $(kubectl version --client=true --short=true)
echo "kubelet version: " $(kubelet --version)
echo "$LINE_SEPARATOR"