skip to Main Content

I am using an Ubuntu 22.04 machine to run and test Kubernetes locally. I need some functionality like Docker-Desktop. I mean it seems both master and worker nodes/machines will be installed by Docker-Desktop on the same machine. But when I try to install Kubernetes and following the instructions like this, at some points it says run the following codes on master node:

sudo hostnamectl set-hostname kubernetes-master

Or run the following comands on the worker node machine:

sudo hostnamectl set-hostname kubernetes-worker

I don’t know how to specify master/worker nodes if I have only my local Ubuntu machine?

Or should I run join command after kubeadm init command? Because I can’t understand the commands I run in my terminal will be considered as a command for which master or worker machine?

I am a little bit confused about this master/worker nodes or client/server machine stuff while I am just using one machine for both client and server machines.

2

Answers


  1. Prerequisites for installing kubernetes in cluster:

    1. Ubuntu instance with 4 GB RAM – Master Node – (with ports open to all traffic)
    2. Ubuntu instance with at least 2 GB RAM – Worker Node – (with ports open to all traffic)

    It means you need to create 3 instances from any cloud provider like Google (GCP), Amazon (AWS), Atlantic.Net Cloud Platform, cloudsigma as per your convenience.

    For creating an instance in gcp follow this guide. If you don’t have an account create a new account ,New customers also get $300 in free credits to run, test, and deploy workloads.

    After creating instances you will get ips of the instance using them you can ssh into the instance using terminal in your local machine by using the command: ssh root@<ip address>

    From there you can follow any guide for installing kubernetes by using worker and master nodes.

    example:

    sudo hostnamectl set-hostname <host name>
    

    Above should be executed in the ssh of the worker node, similarly you need to execute it into the worker node.

    Login or Signup to reply.
  2. The hostname does nothing about node roles.

    If you do kubeadm init, the node will be a master node (currently called control plane).

    This node can also be used as a worker node (currently called just a node), but by default, Pods cannot be scheduled on the control plane node.

    You can turn off this restriction by removing its taints with the following command:

    kubectl taint nodes --all node-role.kubernetes.io/master-
    kubectl taint nodes --all  node-role.kubernetes.io/control-plane-
    

    and then you can use this node as both control-plane and node.

    But I guess some small kubernetes like k0s, k3s, and microk8s are better options for your use case rather than kubeadm.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search