【我的问题】使用yum安装旧版本kubeadm和kubelet时,提示缺少依赖 kubernetes-cni
[root@k192 ~]# yum -y install kubeadm-1.17.5 kubectl-1.17.5 kubelet-1.17.5 Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * epel: mirrors.njupt.edu.cn * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Resolving Dependencies --> Running transaction check ---> Package kubeadm.x86_64 0:1.17.5-0 will be installed --> Processing Dependency: kubernetes-cni >= 0.7.5 for package: kubeadm-1.17.5-0.x86_64 Package kubernetes-cni is obsoleted by kubelet, but obsoleting package does not provide for requirements ---> Package kubectl.x86_64 0:1.17.5-0 will be installed ---> Package kubelet.x86_64 0:1.17.5-0 will be installed --> Processing Dependency: kubernetes-cni >= 0.7.5 for package: kubelet-1.17.5-0.x86_64 Package kubernetes-cni is obsoleted by kubelet, but obsoleting package does not provide for requirements --> Finished Dependency Resolution Error: Package: kubelet-1.17.5-0.x86_64 (kubernetes) Requires: kubernetes-cni >= 0.7.5 Available: kubernetes-cni-0.3.0.1-0.07a8a2.x86_64 (kubernetes) kubernetes-cni = 0.3.0.1-0.07a8a2 Available: kubernetes-cni-0.5.1-0.x86_64 (kubernetes) kubernetes-cni = 0.5.1-0 Available: kubernetes-cni-0.5.1-1.x86_64 (kubernetes) kubernetes-cni = 0.5.1-1 Available: kubernetes-cni-0.6.0-0.x86_64 (kubernetes) kubernetes-cni = 0.6.0-0 Available: kubernetes-cni-0.7.5-0.x86_64 (kubernetes) kubernetes-cni = 0.7.5-0 Error: Package: kubeadm-1.17.5-0.x86_64 (kubernetes) Requires: kubernetes-cni >= 0.7.5 Available: kubernetes-cni-0.3.0.1-0.07a8a2.x86_64 (kubernetes) kubernetes-cni = 0.3.0.1-0.07a8a2 Available: kubernetes-cni-0.5.1-0.x86_64 (kubernetes) kubernetes-cni = 0.5.1-0 Available: kubernetes-cni-0.5.1-1.x86_64 (kubernetes) kubernetes-cni = 0.5.1-1 Available: kubernetes-cni-0.6.0-0.x86_64 (kubernetes) kubernetes-cni = 0.6.0-0 Available: kubernetes-cni-0.7.5-0.x86_64 (kubernetes) kubernetes-cni = 0.7.5-0 You could try using --skip-broken to work around the problem You could try running: rpm -Va --nofiles --nodigest
【解决办法】加上参数 --setopt=obsoletes=0 即可,大概意思支持旧版本。
[root@k192 ~]# yum -y install kubeadm-1.17.5 kubectl-1.17.5 kubelet-1.17.5 --setopt=obsoletes=0 Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * epel: mirrors.njupt.edu.cn * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Resolving Dependencies --> Running transaction check ---> Package kubeadm.x86_64 0:1.17.5-0 will be installed --> Processing Dependency: kubernetes-cni >= 0.7.5 for package: kubeadm-1.17.5-0.x86_64 ---> Package kubectl.x86_64 0:1.17.5-0 will be installed ---> Package kubelet.x86_64 0:1.17.5-0 will be installed --> Running transaction check ---> Package kubernetes-cni.x86_64 0:0.7.5-0 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================================================================ Package Arch Version Repository Size ============================================================================================================================================================================================================ Installing: kubeadm x86_64 1.17.5-0 kubernetes 8.7 M kubectl x86_64 1.17.5-0 kubernetes 9.4 M kubelet x86_64 1.17.5-0 kubernetes 21 M Installing for dependencies: kubernetes-cni x86_64 0.7.5-0 kubernetes 10 M Transaction Summary ============================================================================================================================================================================================================ Install 3 Packages (+1 Dependent package) Total download size: 49 M Installed size: 221 M Downloading packages: (1/4): 38593cf3e4a15215462f4c42166b5de61eeabc4195c1fe49c6cc48413525533d-kubeadm-1.17.5-0.x86_64.rpm | 8.7 MB 00:00:01 (2/4): 542252f491adf3c73c637ca65be9cd488adfc642648b2dd45cfa9d11150f38a8-kubectl-1.17.5-0.x86_64.rpm | 9.4 MB 00:00:02 (3/4): 548a0dcd865c16a50980420ddfa5fbccb8b59621179798e6dc905c9bf8af3b34-kubernetes-cni-0.7.5-0.x86_64.rpm | 10 MB 00:00:02 (4/4): c1e92b5848fa93b71b3c1ff560f16c2e264ce3bc5d1fcc16cf453254eb081372-kubelet-1.17.5-0.x86_64.rpm | 21 MB 00:00:03 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Total 10 MB/s | 49 MB 00:00:04 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : kubelet-1.17.5-0.x86_64 1/4 Installing : kubernetes-cni-0.7.5-0.x86_64 2/4 Installing : kubectl-1.17.5-0.x86_64 3/4 Installing : kubeadm-1.17.5-0.x86_64 4/4 Verifying : kubectl-1.17.5-0.x86_64 1/4 Verifying : kubernetes-cni-0.7.5-0.x86_64 2/4 Verifying : kubeadm-1.17.5-0.x86_64 3/4 Verifying : kubelet-1.17.5-0.x86_64 4/4 Installed: kubeadm.x86_64 0:1.17.5-0 kubectl.x86_64 0:1.17.5-0 kubelet.x86_64 0:1.17.5-0 Dependency Installed: kubernetes-cni.x86_64 0:0.7.5-0 Complete!
我使用的是阿里云镜像源,之前一直都是没有问题的,直到最近发现不加参数就会一直报错。
cat <<EOF > /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 EOF