How to install Kubernetes on Ubuntu 20.04 Focal Fossa Linux - LinuxConfig.org

Kubernetes is leading software in container orchestration. Kubernetes works by managing clusters, which is simply a set of hosts meant for running containerized applications. In order to have a Kubernetes cluster, you need a minimum of two nodes - a master node and a worker node. Of course, you can expand the cluster by adding as many worker nodes as you need.


This is a companion discussion topic for the original entry at https://linuxconfig.org/how-to-install-kubernetes-on-ubuntu-20-04-focal-fossa-linux

I ran through your guide one and things failed at the flannel section.

I found this: coreos dot com /flannel/docs/latest/kubernetes.html <- wont let me post link.

I had to reinstall ubuntu and run kubeadm with the cidr flag as per flannel’s instructions.

sudo kubeadm init --pod-network-cidr=10.244.0.0/16

Then everything worked perfect!

@Korbin If the doc could be updated with the new command sudo kubeadm init --pod-network-cidr=10.244.0.0/16, it would be helpful for others who stumble upon this doc. I am new to k8 and I was stuck at this step for a long time.

Thanks for this blog :slightly_smiling_face:

The above comments about flannel are very helpful. To avoid reinstalling ubuntu, you can do:
sudo kubeadm reset
sudo rm -rf /etc/cni/net.d
Then retry ‘sudo kubeadm init’ with the extra options.

At kubectl run --image=nginx nginx-server --port=80 --env="DOMAIN=cluster" the STATUS remains in pending status and therefore the next command, the expose command, won’t work. What could be going on?

Hi Gregory_Werner,

Welcome to our forums.

Did you find any relevant log messages about why status stays in pending state?

Hey everyone, I was hoping you might be able to help me through this. Great tutorial, better than the rest I came across. However, to note some help for others in the future. The following line only creates a pod and deploys to a worker node. That worker node will then show that it is running the docker container, but the container has no ports associated with it. Also in the following line the image name must include the tag if the tag is present for the image.

kubectl run --image=nginx:“tag name” nginx-server --port=80 --env=“DOMAIN=cluster”

Now running the following command it doesn’t work. I suspect that the port number here sets the port number for the Worker Node for communication. I don’t know that to be true though.

kubectl expose deployment nginx-server --port=80 --name=nginx-http

The error I get when running the above command line is : “Error from server (NotFound): deployments.apps “nodejs-webapi-deployment” not found”

you will notice the error message has “nodejs-webapi-deployment” that is stuff on my side, that I am trying to resolve. I am actually deploying an image that has a nodejs webapi.

Therefore I am assuming it’s looking for a deployment and this tutorial did not go over deployments. Now from a Kubernetes expert on Youtube Nana, she said you should create a deployment first and then your pods go in the deployment. The first command I list above while it creates a pod I am not exactly sure how to create that pod for a specific deployment if I created a deployment prehand. But from the previous deployments I have created it instantly make the pods for me. So I am not sure how to get the first command above to create the deployment for the 2nd command to work. Is there someone out there than can help guide me on this? If I am wrong in my thinking that is fine. I am new to Kubernetes and I was asked to explore this technology.