Skip to content

Commit 324ffc1

Browse files
committed
Fix e2e test Kubernetes official binaries version
commit ea003df is incomplete. The commit removed preKubeadmCommands which installs binaries and images of CI version. But we should have update to install Kubernetes official binaries version. Only binaries are needed in preKubeadmCommands, because the images version is specified by version in the manifest.
1 parent c98a16c commit 324ffc1

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,8 @@ create-cluster: $(CLUSTERCTL) $(KUSTOMIZE) $(ENVSUBST) ## Create a development K
379379

380380
# Patch Kubernetes version
381381
cat ./hack/ci/e2e-conformance/e2e-conformance_patch.yaml.tpl | \
382+
sed "s|\$${OPENSTACK_CLOUD_PROVIDER_CONF_B64}|$(OPENSTACK_CLOUD_PROVIDER_CONF_B64)|" | \
383+
sed "s|\$${OPENSTACK_CLOUD_CACERT_B64}|$(OPENSTACK_CLOUD_CACERT_B64)|" | \
382384
sed "s|\$${KUBERNETES_VERSION}|$(KUBERNETES_VERSION)|" | \
383385
sed "s|\$${CLUSTER_NAME}|$(CLUSTER_NAME)|" \
384386
> ./hack/ci/e2e-conformance/e2e-conformance_patch.yaml

hack/ci/e2e-conformance/e2e-conformance_patch.yaml.tpl

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,59 @@ spec:
1313
kubeletExtraArgs:
1414
v: "8"
1515
verbosity: 8
16+
preKubeadmCommands:
17+
- bash -c /tmp/kubeadm-bootstrap.sh
18+
files:
19+
- path: /etc/kubernetes/cloud.conf
20+
owner: root
21+
permissions: "0600"
22+
content: ${OPENSTACK_CLOUD_PROVIDER_CONF_B64}
23+
encoding: base64
24+
- path: /etc/certs/cacert
25+
owner: root
26+
permissions: "0600"
27+
content: ${OPENSTACK_CLOUD_CACERT_B64}
28+
encoding: base64
29+
- path: /tmp/kubeadm-bootstrap.sh
30+
owner: "root:root"
31+
permissions: "0744"
32+
content: |
33+
#!/bin/bash
34+
35+
set -o nounset
36+
set -o pipefail
37+
set -o errexit
38+
set -e
39+
40+
[[ $(id -u) != 0 ]] && SUDO="sudo" || SUDO=""
41+
42+
# This script installs kubectl, kubelet, and kubeadm binaries.
43+
LINE_SEPARATOR="*************************************************"
44+
echo "$LINE_SEPARATOR"
45+
46+
K8S_DIR="/tmp/k8s"
47+
mkdir -p ${K8S_DIR}
48+
K8S_URL="https://storage.googleapis.com/kubernetes-release/release/${KUBERNETES_VERSION}/kubernetes-server-linux-amd64.tar.gz"
49+
cd ${K8S_DIR}
50+
wget -q ${K8S_URL}
51+
tar zxf kubernetes-server-linux-amd64.tar.gz
52+
K8S_SERVER_BIN_DIR="${K8S_DIR}/kubernetes/server/bin"
53+
54+
declare -a BINARIES_TO_TEST=("kubectl" "kubelet" "kubeadm")
55+
for BINARY in "${BINARIES_TO_TEST[@]}"; do
56+
# move old binary away to avoid err "Text file busy"
57+
${SUDO} mv /usr/bin/${BINARY} /usr/bin/${BINARY}.bak
58+
${SUDO} cp ${K8S_SERVER_BIN_DIR}/${BINARY} /usr/bin/${BINARY}
59+
${SUDO} chmod +x /usr/bin/${BINARY}
60+
done
61+
62+
echo "$(date): checking binary versions"
63+
echo "ctr version: " $(ctr version)
64+
echo "kubeadm version: " $(kubeadm version -o=short)
65+
echo "kubectl version: " $(kubectl version --client=true --short=true)
66+
echo "kubelet version: " $(kubelet --version)
67+
68+
echo "$LINE_SEPARATOR"
1669
---
1770
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha3
1871
kind: KubeadmConfigTemplate
@@ -22,3 +75,56 @@ spec:
2275
template:
2376
spec:
2477
verbosity: 8
78+
preKubeadmCommands:
79+
- bash -c /tmp/kubeadm-bootstrap.sh
80+
files:
81+
- content: ${OPENSTACK_CLOUD_PROVIDER_CONF_B64}
82+
encoding: base64
83+
owner: root
84+
path: /etc/kubernetes/cloud.conf
85+
permissions: "0600"
86+
- content: ${OPENSTACK_CLOUD_CACERT_B64}
87+
encoding: base64
88+
owner: root
89+
path: /etc/certs/cacert
90+
permissions: "0600"
91+
- path: /tmp/kubeadm-bootstrap.sh
92+
owner: "root:root"
93+
permissions: "0744"
94+
content: |
95+
#!/bin/bash
96+
97+
set -o nounset
98+
set -o pipefail
99+
set -o errexit
100+
set -e
101+
102+
[[ $(id -u) != 0 ]] && SUDO="sudo" || SUDO=""
103+
104+
# This script installs kubectl, kubelet, and kubeadm binaries.
105+
LINE_SEPARATOR="*************************************************"
106+
echo "$LINE_SEPARATOR"
107+
108+
K8S_DIR=/tmp/k8s
109+
mkdir -p $K8S_DIR
110+
K8S_URL="https://dl.k8s.io/${KUBERNETES_VERSION}/kubernetes-server-linux-amd64.tar.gz"
111+
cd ${K8S_DIR}
112+
wget ${K8S_URL}
113+
tar zxvf kubernetes-server-linux-amd64.tar.gz
114+
K8S_SERVER_BIN_DIR="${K8S_DIR}/kubernetes/server/bin"
115+
116+
declare -a BINARIES_TO_TEST=("kubectl" "kubelet" "kubeadm")
117+
for BINARY in "${BINARIES_TO_TEST[@]}"; do
118+
# move old binary away to avoid err "Text file busy"
119+
${SUDO} mv /usr/bin/${BINARY} /usr/bin/${BINARY}.bak
120+
${SUDO} cp ${K8S_SERVER_BIN_DIR}/${BINARY} /usr/bin/${BINARY}
121+
${SUDO} chmod +x /usr/bin/${BINARY}
122+
done
123+
124+
echo "$(date): checking binary versions"
125+
echo "ctr version: " $(ctr version)
126+
echo "kubeadm version: " $(kubeadm version -o=short)
127+
echo "kubectl version: " $(kubectl version --client=true --short=true)
128+
echo "kubelet version: " $(kubelet --version)
129+
130+
echo "$LINE_SEPARATOR"

0 commit comments

Comments
 (0)