failed loading custom repository config /etc/yum.repos.d/kubernetes.repo in CentOS 8

Solution 1:

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