Skip to content

Commit 13892e2

Browse files
[CKS] Create Kubernetes ISO support for ARCH optional parameter (#10986)
* [CKS] Create Kubernetes ISO support for ARCH optional parameter * Include arch on the build name * Refactor * Fix ISO naming * Apply suggestions from code review Co-authored-by: Wei Zhou <[email protected]> * Reorder parameters --------- Co-authored-by: Wei Zhou <[email protected]>
1 parent 0d4147f commit 13892e2

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

scripts/util/create-kubernetes-binaries-iso.sh

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,41 +19,56 @@
1919
set -e
2020

2121
if [ $# -lt 6 ]; then
22-
echo "Invalid input. Valid usage: ./create-kubernetes-binaries-iso.sh OUTPUT_PATH KUBERNETES_VERSION CNI_VERSION CRICTL_VERSION WEAVENET_NETWORK_YAML_CONFIG DASHBOARD_YAML_CONFIG BUILD_NAME [ETCD_VERSION]"
23-
echo "eg: ./create-kubernetes-binaries-iso.sh ./ 1.11.4 0.7.1 1.11.1 https://github.com/weaveworks/weave/releases/download/latest_release/weave-daemonset-k8s-1.11.yaml https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.0/src/deploy/recommended/kubernetes-dashboard.yaml setup-v1.11.4 3.5.1"
22+
echo "Invalid input. Valid usage: ./create-kubernetes-binaries-iso.sh OUTPUT_PATH KUBERNETES_VERSION CNI_VERSION CRICTL_VERSION WEAVENET_NETWORK_YAML_CONFIG DASHBOARD_YAML_CONFIG BUILD_NAME [ARCH] [ETCD_VERSION]"
23+
echo "eg: ./create-kubernetes-binaries-iso.sh ./ 1.11.4 0.7.1 1.11.1 https://github.com/weaveworks/weave/releases/download/latest_release/weave-daemonset-k8s-1.11.yaml https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.0/src/deploy/recommended/kubernetes-dashboard.yaml setup-v1.11.4 amd64"
2424
exit 1
2525
fi
2626

27+
ARCH="amd64"
28+
ARCH_SUFFIX="x86_64"
29+
if [ -n "${8}" ]; then
30+
if [ "${8}" = "x86_64" ] || [ "${8}" = "amd64" ]; then
31+
ARCH="amd64"
32+
ARCH_SUFFIX="x86_64"
33+
elif [ "${8}" = "aarch64" ] || [ "${8}" = "arm64" ]; then
34+
ARCH="arm64"
35+
ARCH_SUFFIX="aarch64"
36+
else
37+
echo "ERROR: ARCH must be 'x86_64' or 'aarch64'. If the optional parameter ARCH is not set then 'x86_64' is used."
38+
exit 1
39+
fi
40+
fi
41+
2742
RELEASE="v${2}"
2843
VAL="1.18.0"
2944
output_dir="${1}"
3045
start_dir="$PWD"
3146
iso_dir="/tmp/iso"
3247
working_dir="${iso_dir}/"
3348
mkdir -p "${working_dir}"
34-
build_name="${7}.iso"
35-
[ -z "${build_name}" ] && build_name="setup-${RELEASE}.iso"
49+
build_name="${7}-${ARCH_SUFFIX}.iso"
50+
[ -z "${build_name}" ] && build_name="setup-${RELEASE}-${ARCH_SUFFIX}.iso"
3651

3752
CNI_VERSION="v${3}"
3853
echo "Downloading CNI ${CNI_VERSION}..."
3954
cni_dir="${working_dir}/cni/"
4055
mkdir -p "${cni_dir}"
41-
cni_status_code=$(curl -L --write-out "%{http_code}\n" "https://github.com/containernetworking/plugins/releases/download/${CNI_VERSION}/cni-plugins-linux-amd64-${CNI_VERSION}.tgz" -o "${cni_dir}/cni-plugins-amd64.tgz")
56+
cni_status_code=$(curl -L --write-out "%{http_code}\n" "https://github.com/containernetworking/plugins/releases/download/${CNI_VERSION}/cni-plugins-linux-${ARCH}-${CNI_VERSION}.tgz" -o "${cni_dir}/cni-plugins-${ARCH}.tgz")
4257
if [[ ${cni_status_code} -eq 404 ]] ; then
43-
curl -L --write-out "%{http_code}\n" "https://github.com/containernetworking/plugins/releases/download/${CNI_VERSION}/cni-plugins-amd64-${CNI_VERSION}.tgz" -o "${cni_dir}/cni-plugins-amd64.tgz"
58+
curl -L --write-out "%{http_code}\n" "https://github.com/containernetworking/plugins/releases/download/${CNI_VERSION}/cni-plugins-${ARCH}-${CNI_VERSION}.tgz" -o "${cni_dir}/cni-plugins-${ARCH}.tgz"
4459
fi
4560

4661
CRICTL_VERSION="v${4}"
4762
echo "Downloading CRI tools ${CRICTL_VERSION}..."
4863
crictl_dir="${working_dir}/cri-tools/"
4964
mkdir -p "${crictl_dir}"
50-
curl -L "https://github.com/kubernetes-incubator/cri-tools/releases/download/${CRICTL_VERSION}/crictl-${CRICTL_VERSION}-linux-amd64.tar.gz" -o "${crictl_dir}/crictl-linux-amd64.tar.gz"
65+
curl -L "https://github.com/kubernetes-incubator/cri-tools/releases/download/${CRICTL_VERSION}/crictl-${CRICTL_VERSION}-linux-${ARCH}.tar.gz" -o "${crictl_dir}/crictl-linux-${ARCH}.tar.gz"
5166

5267
echo "Downloading Kubernetes tools ${RELEASE}..."
5368
k8s_dir="${working_dir}/k8s"
5469
mkdir -p "${k8s_dir}"
5570
cd "${k8s_dir}"
56-
curl -L --remote-name-all https://dl.k8s.io/release/${RELEASE}/bin/linux/amd64/{kubeadm,kubelet,kubectl}
71+
curl -L --remote-name-all https://dl.k8s.io/release/${RELEASE}/bin/linux/${ARCH}/{kubeadm,kubelet,kubectl}
5772
kubeadm_file_permissions=`stat --format '%a' kubeadm`
5873
chmod +x kubeadm
5974

@@ -148,11 +163,12 @@ chmod ${kubeadm_file_permissions} "${working_dir}/k8s/kubeadm"
148163
echo "Updating imagePullPolicy to IfNotPresent in yaml files..."
149164
sed -i "s/imagePullPolicy:.*/imagePullPolicy: IfNotPresent/g" ${working_dir}/*.yaml
150165

151-
if [ -n "${8}" ]; then
166+
# Optional parameter ETCD_VERSION
167+
if [ -n "${9}" ]; then
152168
# Install etcd dependencies
153169
etcd_dir="${working_dir}/etcd"
154170
mkdir -p "${etcd_dir}"
155-
ETCD_VERSION=v${8}
171+
ETCD_VERSION=v${9}
156172
wget -q --show-progress "https://github.com/etcd-io/etcd/releases/download/${ETCD_VERSION}/etcd-${ETCD_VERSION}-linux-amd64.tar.gz" -O ${etcd_dir}/etcd-linux-amd64.tar.gz
157173
fi
158174

0 commit comments

Comments
 (0)