3

I am add a custom repository config in CentOS 8 like this in my kvm virtual machine like this:

[root@localhost ~]# cat /etc/yum.repos.d/kubernetes.repo 
[kubernetes]
   name=Kubernetes
   baseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
   enabled=1
   gpgcheck=0
   repo_gpgcheck=0
   gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
       http://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg

but when I using this command to install kuberentes component, it shows me like this:

[root@localhost ~]# yum -y install kubelet kubeadm kubectl
Warning: failed loading '/etc/yum.repos.d/kubernetes.repo', skipping.
Last metadata expiration check: 0:37:38 ago on Sun 05 Jul 2020 08:38:19 AM EDT.
No match for argument: kubelet
No match for argument: kubeadm
No match for argument: kubectl

am I missing something? what should I do to fix this problem?

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
Dolphin
  • 301
  • 1
  • 6
  • 14

1 Answers1

5

I think the problem is that your repo file is not correctly formatted and contains whitespace where there should not be any.

You should re-create the file according to the instructions:

cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
Michael Hampton
  • 237,123
  • 42
  • 477
  • 940