Download and offline install kubeadm-*kubectl-* kubelet-* for RPM based OS.

Jbn1233
2 min readNov 26, 2023

--

Sometimes this way may work faster and more controllable than “yum install” way.

#!/bin/bash

URLX="http://prod-cdn.packages.k8s.io/repositories/isv:/kubernetes:/core:/stable:/v$1"
PRIMARY=$(curl -sS $URLX/rpm/repodata/repomd.xml|grep primary.xml.gz| awk -F\" {'print $2'})

curl -sS $URLX/rpm/$PRIMARY | gunzip - | grep x86_64.rpm | awk -F\" {'print $(NF-1)'} | awk -F / {'print $2'}|\
sort -t '-' -k 1,1 -k 2Vr | awk -F '-' '!seen[$1]++' |\
awk -v x1="$1" {'print "http://prod-cdn.packages.k8s.io/repositories/isv:/kubernetes:/core:/stable:/v"x1"/rpm/x86_64/"$1'}| \
xargs -I{} curl -LO {}
ls -lrt

Usage:

./lazy.sh [ Kubernetes major version number ]

Sample:

[root@worker1 src]# ./lazy.sh 1.26
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 8004k 100 8004k 0 0 35.2M 0 --:--:-- --:--:-- --:--:-- 35.2M
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 9748k 100 9748k 0 0 42.3M 0 --:--:-- --:--:-- --:--:-- 42.1M
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 9.7M 100 9.7M 0 0 42.9M 0 --:--:-- --:--:-- --:--:-- 42.9M
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 20.2M 100 20.2M 0 0 61.2M 0 --:--:-- --:--:-- --:--:-- 61.2M
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6329k 100 6329k 0 0 30.9M 0 --:--:-- --:--:-- --:--:-- 30.9M
total 54892
-rwxr-xr-x 1 root root 525 Nov 26 11:55 lazy.sh
-rw-r--r-- 1 root root 8196676 Nov 26 11:55 cri-tools-1.26.0-150500.1.1.x86_64.rpm
-rw-r--r-- 1 root root 9982080 Nov 26 11:55 kubeadm-1.26.11-150500.1.1.x86_64.rpm
-rw-r--r-- 1 root root 10271100 Nov 26 11:55 kubectl-1.26.11-150500.1.1.x86_64.rpm
-rw-r--r-- 1 root root 21258392 Nov 26 11:55 kubelet-1.26.11-150500.1.1.x86_64.rpm
-rw-r--r-- 1 root root 6481496 Nov 26 11:55 kubernetes-cni-1.2.0-150500.2.1.x86_64.rpm

And the yum install *.rpm

Thanks ChatGPT for !seen part.

That’s all

Update1:

For Debian use this

curl -L -sS https://prod-cdn.packages.k8s.io/repositories/isv:/kubernetes:/core:/stable:/v1.29/deb/Packages.gz  | zgrep amd64/|awk -F/ {'print $2'}
cri-tools_1.29.0-1.1_amd64.deb
kubeadm_1.29.0-1.1_amd64.deb
kubeadm_1.29.1-1.1_amd64.deb
kubeadm_1.29.10-1.1_amd64.deb
kubeadm_1.29.2-1.1_amd64.deb
kubeadm_1.29.3-1.1_amd64.deb
kubeadm_1.29.4-2.1_amd64.deb
kubeadm_1.29.5-1.1_amd64.deb
kubeadm_1.29.6-1.1_amd64.deb
kubeadm_1.29.7-1.1_amd64.deb
kubeadm_1.29.8-1.1_amd64.deb
kubeadm_1.29.9-1.1_amd64.deb
kubectl_1.29.0-1.1_amd64.deb
kubectl_1.29.1-1.1_amd64.deb
kubectl_1.29.10-1.1_amd64.deb
kubectl_1.29.2-1.1_amd64.deb
kubectl_1.29.3-1.1_amd64.deb
kubectl_1.29.4-2.1_amd64.deb
kubectl_1.29.5-1.1_amd64.deb
kubectl_1.29.6-1.1_amd64.deb
kubectl_1.29.7-1.1_amd64.deb
kubectl_1.29.8-1.1_amd64.deb
kubectl_1.29.9-1.1_amd64.deb
kubelet_1.29.0-1.1_amd64.deb
kubelet_1.29.1-1.1_amd64.deb
kubelet_1.29.10-1.1_amd64.deb
kubelet_1.29.2-1.1_amd64.deb
kubelet_1.29.3-1.1_amd64.deb
kubelet_1.29.4-2.1_amd64.deb
kubelet_1.29.5-1.1_amd64.deb
kubelet_1.29.6-1.1_amd64.deb
kubelet_1.29.7-1.1_amd64.deb
kubelet_1.29.8-1.1_amd64.deb
kubelet_1.29.9-1.1_amd64.deb
kubernetes-cni_1.3.0-1.1_amd64.deb

--

--

Jbn1233
Jbn1233

Written by Jbn1233

Very short and simple notes for CKA/SRE and may not works on your environment | jbn1233@gmail.com | Bangkok, Thailand |

No responses yet