Thanks, I did this on a CentOS 8.2 but had to make one tweak.
In this file
/etc/yum.repos.d/kubernetes.repo
I changed this line to have it enabled, so I changed it from:
enabled=0
to:
enabled=1
So my /etc/yum.repos.d/kubernetes.repo file looks like:
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
I then was able to do (for CentOS 8.x or Red Hat 8.x you can use dnf
instead of yum
, the actual command is dnf
but on 8.x they do an alias of some sort to point yum
to dnf
)
mkdir /tmp/k8s
yum -y install --downloadonly --downloaddir=/tmp/k8s kubeadm kubelet kubectl
This downloaded the 3 rpms and dependencies. So my output was
14bfe6e75a9efc8eca3f638eb22c7e2ce759c67f95b43b16fae4ebabde1549f3-cri-tools-1.13.0-0.x86_64.rpm
b1b077555664655ba01b2c68d13239eaf9db1025287d0d9ccaeb4a8850c7a9b7-kubectl-1.19.2-0.x86_64.rpm
conntrack-tools-1.4.4-10.el8.x86_64.rpm
d0ba40edfc0fdf3aeec3dd8e56c01ff0d3a511cc0012aabce55d9a83d9bf2b69-kubeadm-1.19.2-0.x86_64.rpm
d9d997cdbfd6562824eb7786abbc7f4c6a6825662d0f451793aa5ab8c4a85c96-kubelet-1.19.2-0.x86_64.rpm
db7cb5cb0b3f6875f54d10f02e625573988e3e91fd4fc5eef0b1876bb18604ad-kubernetes-cni-0.8.7-0.x86_64.rpm
libnetfilter_cthelper-1.0.0-15.el8.x86_64.rpm
libnetfilter_cttimeout-1.0.0-11.el8.x86_64.rpm
libnetfilter_queue-1.0.2-11.el8.x86_64.rpm
socat-1.7.3.3-2.el8.x86_64.rpm
An alternate way, I also did the following
yum install -y yum-utils
then ran these 3 commands
yumdownloader kubeadm
yumdownloader kubelet
yumdownloader kubectl
This got me these 3 files in the current directory that you ran the command from
-rw-r--r-- 1 root root 9450186 Oct 8 10:11 b1b077555664655ba01b2c68d13239eaf9db1025287d0d9ccaeb4a8850c7a9b7-kubectl-1.19.2-0.x86_64.rpm
-rw-r--r-- 1 root root 8725678 Oct 8 10:10 d0ba40edfc0fdf3aeec3dd8e56c01ff0d3a511cc0012aabce55d9a83d9bf2b69-kubeadm-1.19.2-0.x86_64.rpm
-rw-r--r-- 1 root root 20438926 Oct 8 10:11 d9d997cdbfd6562824eb7786abbc7f4c6a6825662d0f451793aa5ab8c4a85c96-kubelet-1.19.2-0.x86_64.rpm
FYI to download a specific version of kubectl run this command
yum --showduplicates list kubectl
This will show you all the versions available in the 2nd column. The syntax to download a specific version is:
yumdownloader <packagename>-<version number>.x86_64
So for example to download kubectl
version 1.18.9.0
for the x86_64
platform run
yumdownloader kubectl-1.18.9-0.x86_64
See here on how to download specific versions of packages
https://www.thegeekdiary.com/centos-rhel-how-to-install-a-specific-version-of-rpm-package-using-yum