I am installing Kubernetes on my Ubuntu 20.4 machine.
This is the steps I have done:
- Install Docker from https://docs.docker.com/engine/install/ubuntu/
- Install Docker Compose with
sudo apt install docker-compose
Now I am installing Kubernetes:
Dependencies:
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl
Google key
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
Repository
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
Install kubernetes
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
Test:
kubectl version
And this gives me error:
WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short. Use --output=yaml|json to get the full version.
Client Version: version.Info{Major:"1", Minor:"24", GitVersion:"v1.24.4", GitCommit:"95ee5ab382d64cfe6c28967f36b53970b8374491", GitTreeState:"clean", BuildDate:"2022-08-17T18:54:23Z", GoVersion:"go1.18.5", Compiler:"gc", Platform:"linux/amd64"}
Kustomize Version: v4.5.4
The connection to the server localhost:8080 was refused - did you specify the right host or port?
I have Googled the error and found out that I need a Kubernetes config file in my home directory. This is the solution that I have seen the most:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
My problem is that I do not have any files in /etc/kubernetes:
me@oter:/etc/kubernetes$ ll
total 20
drwxr-xr-x 3 root root 4096 aug. 22 12:14 ./
drwxr-xr-x 133 root root 12288 aug. 22 12:14 ../
drwxr-xr-x 2 root root 4096 aug. 22 12:14 manifests/
CodePudding user response:
Based on the comment, you need to create a cluster before performing any operation.
- Initializing your master
kubeadm init
- Installing a pod network
kubectl apply -f http://docs.projectcalico.org/v2.3/getting-started/kubernetes/installation/hosted/kubeadm/1.6/calico.yaml
- Joining your nodes
kubeadm join --token <token> <master-ip>:<master-port>