From de19a5db82d9a66bae0579931acd25d4b23e4b4b Mon Sep 17 00:00:00 2001 From: QwQwQ <47418664+stephen-zeng@users.noreply.github.com> Date: Sat, 3 May 2025 00:25:02 +0800 Subject: [PATCH] Update the binary downloading link to ALWAYS up-to-date. --- docs/02-jumpbox.md | 51 +++++++++++++++++++++++++++++++------------ download-template.txt | 11 ++++++++++ downloads-amd64.txt | 11 ---------- downloads-arm64.txt | 11 ---------- 4 files changed, 48 insertions(+), 36 deletions(-) create mode 100644 download-template.txt delete mode 100644 downloads-amd64.txt delete mode 100644 downloads-arm64.txt diff --git a/docs/02-jumpbox.md b/docs/02-jumpbox.md index 09d3da6..76f9f30 100644 --- a/docs/02-jumpbox.md +++ b/docs/02-jumpbox.md @@ -52,20 +52,46 @@ pwd In this section you will download the binaries for the various Kubernetes components. The binaries will be stored in the `downloads` directory on the `jumpbox`, which will reduce the amount of internet bandwidth required to complete this tutorial as we avoid downloading the binaries multiple times for each machine in our Kubernetes cluster. -The binaries that will be downloaded are listed in either the `downloads-amd64.txt` or `downloads-arm64.txt` file depending on your hardware architecture, which you can review using the `cat` command: +The binaries that will be downloaded are listed in `download-template.txt`, which is a template file that will match your system architecture and the latest software version. You can check it by the following command. ```bash -cat downloads-$(dpkg --print-architecture).txt +cat downloads-template.txt ``` Download the binaries into a directory called `downloads` using the `wget` command: ```bash -wget -q --show-progress \ +{ + export ARCH=$(dpkg --print-architecture) + echo $ARCH + + export K8S_VERSION=$(curl -sSL https://dl.k8s.io/release/stable.txt) + echo "K8S Version: $K8S_VERSION" + + export CRI_VERSION=$(wget -qO- https://api.github.com/repos/kubernetes-sigs/cri-tools/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') + echo "CRI Version: $CRI_VERSION" + + + export RUNC_VERSION=$(wget -qO- https://api.github.com/repos/opencontainers/runc/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') + echo "runc Version: $RUNC_VERSION" + + export CNI_VERSION=$(wget -qO- https://api.github.com/repos/containernetworking/plugins/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') + echo "cni Version: $CNI_VERSION" + + export CONTAINERD_VERSION=$(wget -qO- https://api.github.com/repos/containerd/containerd/releases/latest | grep '"tag_name":' | sed -E 's/.*"v?([^"]+)".*/\1/') + echo "containerd Version: v$CONTAINERD_VERSION" + + export ETCD_VERSION=$(wget -qO- https://api.github.com/repos/etcd-io/etcd/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') + echo "etcd Version: $ETCD_VERSION" + + envsubst < download-template.txt > download.txt + + wget -q --show-progress \ --https-only \ --timestamping \ -P downloads \ - -i downloads-$(dpkg --print-architecture).txt + -i download.txt +} ``` Depending on your internet connection speed it may take a while to download over `500` megabytes of binaries, and once the download is complete, you can list them using the `ls` command: @@ -78,20 +104,19 @@ Extract the component binaries from the release archives and organize them under ```bash { - ARCH=$(dpkg --print-architecture) mkdir -p downloads/{client,cni-plugins,controller,worker} - tar -xvf downloads/crictl-v1.32.0-linux-${ARCH}.tar.gz \ + tar -xvf downloads/crictl-${CRI_VERSION}-linux-${ARCH}.tar.gz \ -C downloads/worker/ - tar -xvf downloads/containerd-2.1.0-beta.0-linux-${ARCH}.tar.gz \ + tar -xvf downloads/containerd-${CONTAINERD_VERSION}-linux-${ARCH}.tar.gz \ --strip-components 1 \ -C downloads/worker/ - tar -xvf downloads/cni-plugins-linux-${ARCH}-v1.6.2.tgz \ + tar -xvf downloads/cni-plugins-linux-${ARCH}-${CNI_VERSION}.tgz \ -C downloads/cni-plugins/ - tar -xvf downloads/etcd-v3.6.0-rc.3-linux-${ARCH}.tar.gz \ + tar -xvf downloads/etcd-${ETCD_VERSION}-linux-${ARCH}.tar.gz \ -C downloads/ \ --strip-components 1 \ - etcd-v3.6.0-rc.3-linux-${ARCH}/etcdctl \ - etcd-v3.6.0-rc.3-linux-${ARCH}/etcd + etcd-${ETCD_VERSION}-linux-${ARCH}/etcdctl \ + etcd-${ETCD_VERSION}-linux-${ARCH}/etcd mv downloads/{etcdctl,kubectl} downloads/client/ mv downloads/{etcd,kube-apiserver,kube-controller-manager,kube-scheduler} \ downloads/controller/ @@ -107,9 +132,7 @@ rm -rf downloads/*gz Make the binaries executable. ```bash -{ - chmod +x downloads/{client,cni-plugins,controller,worker}/* -} +chmod +x downloads/{client,cni-plugins,controller,worker}/* ``` ### Install kubectl diff --git a/download-template.txt b/download-template.txt new file mode 100644 index 0000000..e37f45f --- /dev/null +++ b/download-template.txt @@ -0,0 +1,11 @@ +https://dl.k8s.io/${K8S_VERSION}/bin/linux/${ARCH}/kubectl +https://dl.k8s.io/${K8S_VERSION}/bin/linux/${ARCH}/kube-apiserver +https://dl.k8s.io/${K8S_VERSION}/bin/linux/${ARCH}/kube-controller-manager +https://dl.k8s.io/${K8S_VERSION}/bin/linux/${ARCH}/kube-scheduler +https://dl.k8s.io/${K8S_VERSION}/bin/linux/${ARCH}/kube-proxy +https://dl.k8s.io/${K8S_VERSION}/bin/linux/${ARCH}/kubelet +https://github.com/kubernetes-sigs/cri-tools/releases/download/${CRI_VERSION}/crictl-${CRI_VERSION}-linux-${ARCH}.tar.gz +https://github.com/opencontainers/runc/releases/download/${RUNC_VERSION}/runc.${ARCH} +https://github.com/containernetworking/plugins/releases/download/${CNI_VERSION}/cni-plugins-linux-${ARCH}-${CNI_VERSION}.tgz +https://github.com/containerd/containerd/releases/download/v${CONTAINERD_VERSION}/containerd-${CONTAINERD_VERSION}-linux-${ARCH}.tar.gz +https://github.com/etcd-io/etcd/releases/download/${ETCD_VERSION}/etcd-${ETCD_VERSION}-linux-${ARCH}.tar.gz \ No newline at end of file diff --git a/downloads-amd64.txt b/downloads-amd64.txt deleted file mode 100644 index 3a392da..0000000 --- a/downloads-amd64.txt +++ /dev/null @@ -1,11 +0,0 @@ -https://dl.k8s.io/v1.32.3/bin/linux/amd64/kubectl -https://dl.k8s.io/v1.32.3/bin/linux/amd64/kube-apiserver -https://dl.k8s.io/v1.32.3/bin/linux/amd64/kube-controller-manager -https://dl.k8s.io/v1.32.3/bin/linux/amd64/kube-scheduler -https://dl.k8s.io/v1.32.3/bin/linux/amd64/kube-proxy -https://dl.k8s.io/v1.32.3/bin/linux/amd64/kubelet -https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.32.0/crictl-v1.32.0-linux-amd64.tar.gz -https://github.com/opencontainers/runc/releases/download/v1.3.0-rc.1/runc.amd64 -https://github.com/containernetworking/plugins/releases/download/v1.6.2/cni-plugins-linux-amd64-v1.6.2.tgz -https://github.com/containerd/containerd/releases/download/v2.1.0-beta.0/containerd-2.1.0-beta.0-linux-amd64.tar.gz -https://github.com/etcd-io/etcd/releases/download/v3.6.0-rc.3/etcd-v3.6.0-rc.3-linux-amd64.tar.gz diff --git a/downloads-arm64.txt b/downloads-arm64.txt deleted file mode 100644 index 9459acf..0000000 --- a/downloads-arm64.txt +++ /dev/null @@ -1,11 +0,0 @@ -https://dl.k8s.io/v1.32.3/bin/linux/arm64/kubectl -https://dl.k8s.io/v1.32.3/bin/linux/arm64/kube-apiserver -https://dl.k8s.io/v1.32.3/bin/linux/arm64/kube-controller-manager -https://dl.k8s.io/v1.32.3/bin/linux/arm64/kube-scheduler -https://dl.k8s.io/v1.32.3/bin/linux/arm64/kube-proxy -https://dl.k8s.io/v1.32.3/bin/linux/arm64/kubelet -https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.32.0/crictl-v1.32.0-linux-arm64.tar.gz -https://github.com/opencontainers/runc/releases/download/v1.3.0-rc.1/runc.arm64 -https://github.com/containernetworking/plugins/releases/download/v1.6.2/cni-plugins-linux-arm64-v1.6.2.tgz -https://github.com/containerd/containerd/releases/download/v2.1.0-beta.0/containerd-2.1.0-beta.0-linux-arm64.tar.gz -https://github.com/etcd-io/etcd/releases/download/v3.6.0-rc.3/etcd-v3.6.0-rc.3-linux-arm64.tar.gz