Kubernetes is really a hot cake in the current market. If you are planning to upgrade your skills and trying to make your hands dirty by installing Kubernetes. But “held broken package error” ruining your experience. Follow this article to get rid of this error, to install your first K8s cluster easily.
Action
You are trying to install Kubernetes on Ubuntu Linux and you are getting “E: Unable to correct problems, you have held broken packages” error
Issue
You are getting the below-mentioned error –
The following packages have unmet dependencies:
kubeadm : Depends: kubernetes-cni (= 0.6.0)
kubelet : Depends: kubernetes-cni (= 0.6.0)
E: Unable to correct problems, you have held broken packages.
** Note
kubernetes-cni version can be different in your case but solution applies to every version
Solution
Follow these steps to resolve the “E: Unable to correct problems, you have held broken packages” error.
If you are trying to install a specific version of the Kubernetes cluster, while installing kubelet, kubeadm and kubectl, you can get this package dependency error. As Ubuntu is unable to locate the dependent package required.
For example, I am trying to install Kubernetes package version 1.12.2-00 and encountered this error.
$ sudo apt-get install -y kubelet=1.12.2-00 kubeadm=1.12.2-00 kubectl=1.12.2-00 Reading package lists… Done Building dependency tree Reading state information… Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: kubeadm : Depends: kubernetes-cni (= 0.6.0) kubelet : Depends: kubernetes-cni (= 0.6.0) E: Unable to correct problems, you have held broken packages.
You must install Kubernetes-cni also with kubectl, kubeadm and kubelet package to meet all dependencies. Please use the specific version of Kubernetes-cni mentioned in your error.
For example – I have included kubernetes-cni=0.6.0-00 dependent package also.
$ sudo apt-get install -y kubelet=1.12.2-00 kubeadm=1.12.2-00 kubectl=1.12.2-00 kubernetes-cni=0.6.0-00
Now you will be able to install Kubernetes in your Ubuntu Linux successfully.
Recommendation
Mark your Kubernetes packages to not update automatically
$ sudo apt-mark hold kubelet kubeadm kubectl Kubernetes-cni
Summary
I hope your issue would have been resolved now. In case you are facing any other issue while installing the Kubernetes cluster, you can leave a comment and I will try to help you.