Closed Hawaiideveloper closed 3 years ago
I Checked that the api server is actually running and hasn’t crashed:
docker ps | grep kube-apiserver
I get this error:
Command 'docker' not found, but can be installed with:
sudo snap install docker # version 19.03.11, or sudo apt install docker.io # version 19.03.8-0ubuntu1.20.04.2
See 'snap info docker' for additional versions.
I assume I need to install docker for ubuntu
So I used my script here that contains the following commands:
docker ps | grep kube-apiserver sudo apt-get remove docker docker-engine docker.io containerd runc sudo apt-get update sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io sudo docker run hello-world
That error should only come up if you have no contexts configured in your client. If you run kubectl config view and you get something like this:
kubectl config view apiVersion: v1 clusters: [] contexts: [] current-context: "" kind: Config preferences: {} users: []
Then no contexts are configured.
So I now have a working good version of Docker running on my Virtual Machine with Linux flavor of Ubuntu: lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=20.04 DISTRIB_CODENAME=focal DISTRIB_DESCRIPTION="Ubuntu 20.04.1 LTS"
I used the steps below: first to keep things easy and organized I installed remote dev ssh tools which allowed me to change and revert things quickly and avoid undocumented work.
sudo apt-get update && sudo apt-get install -y apt-transport-https sudo systemctl start docker sudo systemctl enable docker
sudo curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add sudo bash sudo curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add 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 sudo apt-get install -y kubelet kubeadm kubectl sudo apt-mark hold kubelet kubeadm kubectl sudo swapoff -a sudo nano /etc/fstab
In the fstab file, comment out the swap entry (by adding a leading # character):
/swap.img none swap sw 0 0
sudo kubeadm init
I received errors like what is below and... fixed it by using the below two steps
[init] Using Kubernetes version: v1.20.5
[preflight] Running pre-flight checks
[WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/
[WARNING SystemVerification]: this Docker version is not on the list of validated versions: 20.10.5. Latest validated version: 19.03
error execution phase preflight: [preflight] Some fatal errors occurred:
[ERROR NumCPU]: the number of available CPUs 1 is less than the required 2
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher
sudo mkdir /etc/docker
cat <<EOF | sudo tee /etc/docker/daemon.json
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2"
}
EOF
sudo systemctl restart docker
The reason this is occurring is because the hardware on which you are installing Kubernetes does not have enough resources. The developers in the Kubernetes community have mutually agreed that running Kubernetes with less than 2 CPU Cores is not advisable.
This is because in order to run Kubernetes you have to account for a certain amount of overhead. And, when doing so, if you have a system with a very small amount of compute power you will not be able to properly run applications simultaneously.
I increased the cores to two cores
It now appears to function without the errors above, and it took about 4 minutes to pull everything and finish loading
I apologize for a long read, but I had to go through each step listed in the above thread to eliminate all errors within a fusion node running Ubuntu virtual machine that hosts Kubernetes.
Please go through the entire thread above first... and then run the following commands below:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
Then I am sure the error message of:
`The connection to the server localhost:8080 was refused - did you specify the right host or port? '
Will go away
Docker is now being deprecated. I am currently working out the details to install Kubernetes on the systems without using docker
In addition to this awesome fix, I also had to run this on my ubuntu server - sudo chmod a+r /etc/kubernetes/admin.conf
Resolved:
You will need to read everything and do exactly what the above thread says
I apologize for a long read, but I had to go through each step listed in the above thread to eliminate all errors within a fusion node running Ubuntu virtual machine that hosts Kubernetes.
Please go through the entire thread above first... and then run the following commands below:
Failure to read all of the above thread will present errors! So read everything above before issuing the commands below
mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config
Then I am sure the error message of:
`The connection to the server localhost:8080 was refused - did you specify the right host or port? '
Will go away
[Disclaimer : I am a newbie and dont understand any of it. Get informed before you chmod this file.]
Doesn't work for me man. Still getting that error.
No worries.
Can you show your exact error?
On Wed, Oct 5, 2022 at 4:41 AM i do tantra with code < @.***> wrote:
Doesn't work for me man. Still getting that error.
— Reply to this email directly, view it on GitHub https://github.com/Hawaiideveloper/Infastructure-as-Code-Sample_Env/issues/15#issuecomment-1268130865, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGYIJDDMXELFN5SMRJNPITWBU5KPANCNFSM42FCJG7A . You are receiving this because you modified the open/close state.Message ID: <Hawaiideveloper/Infastructure-as-Code-Sample_Env/issues/15/1268130865 @github.com>
It doesn't work for me either.
I run ubuntu20.04 as a service, but when I try to initialize k8s with kubeadm init
command, connection refused
error still occur.
I tried the solutions to resolve it mentioned in this issue, but failed to run on my physical host.
$ docker version
Client: Docker Engine - Community
Version: 20.10.21
API version: 1.40
Go version: go1.18.7
Git commit: baeda1f
Built: Tue Oct 25 18:02:21 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 19.03.9
API version: 1.40 (minimum version 1.12)
Go version: go1.13.10
Git commit: 9d988398e7
Built: Fri May 15 00:23:53 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.10
GitCommit: 770bd0108c32f3fb5c73ae1264f7e503fe7b2661
runc:
Version: 1.1.4
GitCommit: v1.1.4-0-g5fd4c4d
docker-init:
Version: 0.18.0
GitCommit: fec3683
k8s
$ kubelet --version
Kubernetes v1.20.0
I closed the swap function on it.
Sorry for the delay response,
Since your last thread are you running as a VM?
Still not working for me either, even after trying a bunch of stuff. This procedure
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
as well as
kubeadm reset
kubeadm init
I'm desperate. I've really done it all
Are you working with inside of a ubuntu VM?
Have you ensured your vm has 4 processors and 8GB or more Ram?
Reasons I ask is you need it to have enough resources.
Please read above the entire threads
On Sun, Feb 5, 2023 at 15:45 Ettore Pelosato @.***> wrote:
Still not working for me either, even after trying a bunch of stuff. This procedure
mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config
as well as
kubeadm reset kubeadm init
I'm desperate. I've really done it all
— Reply to this email directly, view it on GitHub https://github.com/Hawaiideveloper/Infastructure-as-Code-Sample_Env/issues/15#issuecomment-1418260228, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGYIJHO3PLWYOACSYAH5VDWWAGNJANCNFSM42FCJG7A . You are receiving this because you were mentioned.Message ID: <Hawaiideveloper/Infastructure-as-Code-Sample_Env/issues/15/1418260228@ github.com>
Are you working with inside of a ubuntu VM? Have you ensured your vm has 4 processors and 8GB or more Ram? Reasons I ask is you need it to have enough resources. Please read above the entire threads … On Sun, Feb 5, 2023 at 15:45 Ettore Pelosato @.***> wrote: Still not working for me either, even after trying a bunch of stuff. This procedure mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config as well as kubeadm reset kubeadm init I'm desperate. I've really done it all — Reply to this email directly, view it on GitHub <#15 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGYIJHO3PLWYOACSYAH5VDWWAGNJANCNFSM42FCJG7A . You are receiving this because you were mentioned.Message ID: <Hawaiideveloper/Infastructure-as-Code-Sample_Env/issues/15/1418260228@ github.com>
I think the issue was that somehow I was not using a VM. Anyway I've completely switched tactics and I'm now practicing on the cloud.
Thank you for your reply though :)
After installation when i was checking the version with below command.
kubectl version -o json
I am getting error below along with version information.
{ "clientVersion": { "major": "1", "minor": "20", "gitVersion": "v1.20.5", "gitCommit": "6b1d87acf3c8253c123756b9e61dac642678305f", "gitTreeState": "clean", "buildDate": "2021-03-18T01:10:43Z", "goVersion": "go1.15.8", "compiler": "gc", "platform": "linux/amd64" } }