在 CentOS 8 中加载自定义存储库配置 /etc/yum.repos.d/kubernetes.repo 失败

Dol*_*hin 3 centos yum kubernetes

我在 CentOS 8 中添加一个自定义存储库配置,如下所示:

[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
Run Code Online (Sandbox Code Playgroud)

但是当我使用此命令安装 kuberentes 组件时,它显示如下:

[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
Run Code Online (Sandbox Code Playgroud)

我错过了什么吗?我应该怎么做才能解决这个问题?

Mic*_*ton 5

我认为问题在于您的存储库文件格式不正确,并且包含不应有的空格。

您应该根据说明重新创建该文件:

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
Run Code Online (Sandbox Code Playgroud)