Kubectl (kubernetes) does not install with the install-script.sh

Following the instructions in the DevSecOps course, section 2 (Demo – Installing software in VM), after creating and connecting to the VM via SSH. The install-script.sh does not work as expected. Kubernetes fails to install. I get the following error messages:

E: The repository ‘http://apt.kubernetes.io kubernetes-xenial Release’ does not have a Release
file.
N: Updating from such a repository can’t be done securely, and is therefore disabled by default
N: See apt-secure(8) manpage for repository creation and user configuration details.
Reading package lists… Done

E: Unable to locate package kubectl
E: Unable to locate package kubernetes-cni
E: Unable to locate package kubeadm
install-script.sh: line 21: pip3: command not found
install-script.sh: line 25: jc: command not found
install-script.sh: line 25: jq: command not found
install-script.sh: line 27: /etc/docker/daemon.json: No such file or directory
Failed to restart docker.service: Unit docker.service not found.
Failed to enable unit: Unit file docker.service does not exist.
Failed to enable unit: Unit file kubelet.service does not exist.
Failed to start kubelet.service: Unit kubelet.service not found.

KUBERNETES-.-._.#################--------------

rm: cannot remove ‘/root/.kube/config’: No such file or directory
install-script.sh: line 44: kubeadm: command not found
install-script.sh: line 48: kubeadm: command not found
cp: cannot stat ‘/etc/kubernetes/admin.conf’: No such file or directory
install-script.sh: line 53: kubectl: command not found
untaint controlplane node
install-script.sh: line 58: kubectl: command not found
install-script.sh: line 58: kubectl: command not found
install-script.sh: line 59: kubectl: command not found
install-script.sh: line 59: kubectl: command not found
install-script.sh: line 60: kubectl: command not found

I am unable to continue with the course as a result of the above issue.
Thanks,

This script is currently being updated. A newer version should be published to the github repo sometime in the coming week.

1 Like

Please try the updated version. I have updated both the install script and the Azure Template.

Please download the repo to your laptop using the following commands

git clone https://github.com/kodekloudhub/kubernetes-devops-security.git
cd kubernetes-devops-security
git checkout ubuntu-2204

Then use the template and install.sh from your local copy.

1 Like

Many thanks Alistair, this worked.

Splendid!

I will merge that change so it becomes current.

Note also that it includes a slightly newer version of Jenkins, so the Jenkins UI might look a little different to what it shown in the videos. It should still work the same though.

Also the Kubernetes version is upgraded to 1.29 (latest), but that should not cause any issues.