I used below mentioned commands to remove kubernetes from my ubuntu 18.04 server.
kubeadm reset
sudo apt-get purge kubeadm kubectl kubelet kubernetes-cni kube*
sudo apt-get autoremove
sudo rm -rf ~/.kube
but still its showing :
Client Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.0", GitCommit:"2bd9643cee5b3b3a5ecbd3af49d09018f0773c77", GitTreeState:"clean", BuildDate:"2019-09-18T14:36:53Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}
The connection to the server `localhost:8080 was refused - did you specify the right host or port? while running kubectl version .
How can i completely remove kubectl from my ubuntu server 18.04 ?
Depending on the method you chose in https://kubernetes.io/docs/tasks/tools/install-kubectl/, it can be any of these:
Install kubectl binary via curl: sudo rm /usr/local/bin/kubectl
Download as part of the Google Cloud SDK: gcloud components remove kubectl
Install with snap on Ubuntu (just as Gparmar said): snap remove kubectl
In addition, you may need to remove the configuration files in ~/.kube.
If you exectute commands below:
kubeadm reset
sudo apt-get purge kubeadm kubectl kubelet kubernetes-cni kube*
sudo apt-get autoremove
sudo rm -rf ~/.kube
remember to restart computer.
Related
A.ON MASTER AND WORKER BOTH
Install and enable container
i. sudo apt-get update
ii. sudo apt-get install docker.io
install and enable k8s runtime
i. sudo apt-get update
ii. sudo apt-get install -y apt-transport-https ca-certificates curl
iii. sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
iv. echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
v. sudo apt-get update
vi. sudo apt-get install -y kubelet kubeadm kubectl
vii. sudo apt-mark hold kubelet kubeadm kubectl
B.ON MASTER ONLY
(RUN AS A ROOT) Initiate API server
i. kubeadm init --apiserver-advertise-address= --pod-network-cidr=192.168.0.0/16 enter image description here
In screenshot shared it has successfully bootstrapped master. As non root user you can create .kube and apply the network. It has given the join command which can be used in worker nodes to join them in k8s cluster.
I performed the steps in https://minikube.sigs.k8s.io/docs/start/ to properly install minikube locally in my ubuntu running on my VM:
pcname#ubuntu:~$curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
also
pcname#ubuntu:~$sudo install minikube-linux-amd64 /usr/local/bin/minikube
an empty cmd line is returned. When I type minikube start as if it is install properly I get the following error:
😄 minikube v1.22.0 on Ubuntu 20.04 👎 Unable to pick a default
driver. Here is what was considered, in preference order:
▪ docker: Not installed: exec: "docker": executable file not found in $PATH
▪ kvm2: Not installed: exec: "virsh": executable file not found in $PATH
▪ podman: Not installed: exec: "podman": executable file not found in $PATH
▪ vmware: Not installed: exec: "docker-machine-driver-vmware": executable file not found in $PATH
▪ virtualbox: Not installed: unable to find VBoxManage in $PATH
❌ Exiting due to DRV_NOT_DETECTED: No possible driver was detected.
Try specifying --driver, or see
https://minikube.sigs.k8s.io/docs/start/
Notice: Before those, I followed all steps in https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/ and I installed kubectl and verified it is installed by:
pcname#ubuntu:kubectl version --client
Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.3", GitCommit:"ca643a4d1f7bfe3***************", GitTreeState:"clean", BuildDate:"2021-07-15T21:04:39Z", GoVersion:"go1.16.6", Compiler:"gc", Platform:"linux/amd64"}
even if the 3 step failed.
What is wrong? I am just trying to install kubectl and then minikube. Do I have to install Docker as it is suggested when I type "minikube start" ?
Solution
-sudo chmod 755 /usr/local/bin/minikube to give execute permission to minikube
-minikube version => It gave the version
-minikube start => it did not work.
-Figured out that I have to install Virtual Box so I typed:
sudo apt install virtualbox virtualbox-ext-pack
-minikube start [again] and installation started and goes on without a hitch.
Upgraded to PC to ubuntu 20.04 and having problems re-installing microk8s (1.19 and 1.20 have the same issue on my PC).
starting fresh to demo problem
snap remove microk8s
Following instructions on Install MicroK8s
sudo snap install microk8s --classic --channel=1.19
result:
microk8s (1.19/stable) v1.19.5 from Canonical✓ installed
Step: Join the group
sudo usermod -a -G microk8s $USER
sudo chown -f -R $USER ~/.kube
su - $USER
Step: Check the status
microk8s status --wait-ready
Result: Hangs forever
Figure out what is going on:
microk8s inspect
The tar files contain lots of
Container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:Network plugin returns error: cni plugin not initialized
dial tcp 127.0.0.1:16443: connect: connection refused
Any suggestions would be appreciated.
I had the same issue on a new Ubuntu 20.04.1 Server install and following the same instructions... e.g.
sudo snap install microk8s --classic --channel=1.19
What worked for me was using the 1.18 channel
sudo snap remove microk8s
sudo snap install microk8s --classic --channel=1.18/stable
And then refreshing to 1.19 once microk8s 1.18 became ready...
sudo snap refresh microk8s --classic --channel=1.19/stable
Don't ask me why this worked but it did.
Check your /etc/ hosts file there should be these lines
127.0.0.1 localhost 127.0.1.1 name you servers
It's funny in microk8s 1.18 all works good)
Is there a way to run Kubernetes minikube on a RHEL VM (Hypervisor)? Or is there any other way to try out Kubernetes with a single VM?
To run minikube on a RHEL CentOS VM, you need to install docker and virtualbox, before installing minikube and kubectl. Since minikube runs in a VM also, you be using nested virtualization, so you need to ensure that virtualization is enabled in the BIOS of your RHEL CentOS VM.
Once your VM is up and running, SSH in as root and run the following:
# Install docker dependencies
yum install -y yum-utils device-mapper-persistent-data lvm2
# Add Docker repo
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce epel-release wget
cd /etc/yum.repos.d/
wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo
yum update
Reboot your VM here and ensure that virtualization is enabled in the BIOS
# Install EPEL repo, Minikube kubectl etc.
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum --enablerepo=epel install dkms
yum groupinstall "Development Tools"
yum install -y kernel-devel VirtualBox-5.2
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.23.0/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
sudo /sbin/vboxconfig
# Start the minikube cluster
minikube start --vm-driver=virtualbox SERVICE_CLUSTER_IP_RANGE="X.X.X.X/24" --container-runtime=docker --extra-config kubelet.EnableCustomMetrics=true
# Start the dashboard
minikube dashboard
The minikube dashboard should be running and accessible at http://192.168.99.100:30000
I started minikube with k8s version 1.5.2 and I would like to downgrade my kubectl so that it is also 1.5.2. Currently when I run kubectl version I get:
Client Version: version.Info{Major:"1", Minor:"7", GitVersion:"v1.7.5", GitCommit:"17d7182a7ccbb167074be7a87f0a68bd00d58d97", GitTreeState:"clean", BuildDate:"2017-08-31T19:32:12Z", GoVersion:"go1.9", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.2", GitCommit:"08e099554f3c31f6e6f07b448ab3ed78d0520507", GitTreeState:"clean", BuildDate:"1970-01-01T00:00:00Z", GoVersion:"go1.7", Compiler:"gc", Platform:"linux/amd64"}
I would like to use kubectl to fetch PetSets but in later versions this was updated to StatefulSets so I cannot use the commands with my current kubectl version
kubectl get petsets
the server doesn't have a resource type "petsets"
Thanks!
You can just download the previous version binary and replace the one you have now.
Linux:
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.5.2/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
macOS:
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.5.2/bin/darwin/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
Windows:
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.5.2/bin/windows/amd64/kubectl.exe
And add it to PATH.
If not follow instructions for other Operating Systems here: https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl-binary-via-curl
With APT you can install the exact version as well:
sudo apt install kubectl=1.17.2-00
In my macOS, I was struggling, because I had multiple kubectl executables installed. First you need to remove the existing kubectl binaries. Do the following iteratively until it says command not found: kubectl.
which kubectl
sudo rm -f <path-from-above-command>
Next, follow the kubernetes official documentation to install your specific kubectl version.
https://kubernetes.io/docs/tasks/tools/install-kubectl-macos/
If you want to install v1.18.0 for Apple M1 (see the above link for other OS versions)
curl -LO "https://dl.k8s.io/release/v1.18.0/bin/darwin/arm64/kubectl"
Make the kubectl binary executable.
chmod +x ./kubectl
Move the kubectl binary to a file location on your system PATH.
sudo mv ./kubectl /usr/local/bin/kubectl
sudo chown root: /usr/local/bin/kubectl
Test to ensure the version you installed is up-to-date:
kubectl version --client
What helped me on Centos was running the following:
sudo yum downgrade kubeadm-1.16.9 kubernetes-cni-0.7.5 kubelet-1.16.9 kubectl-1.16.9
Then to disable updates forever, edit /etc/yum.repos.d/Kubernetes.repo and change the line with enabled to enabled=0.
Just manipulate the link
https://kubernetes.io/docs/tasks/tools/install-kubectl-windows/ shows 1.21.0
at https://dl.k8s.io/release/v1.21.0/bin/windows/amd64/kubectl.exe
The old 1.20.6 version is
https://dl.k8s.io/release/v1.20.6/bin/windows/amd64/kubectl.exe