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
Prerequisites for installing kubernetes in cluster:
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:
Above should be executed in the ssh of the worker node, similarly you need to execute it into the worker node.
The hostname does nothing about node roles.
If you do
kubeadm init
, the node will be amaster
node (currently calledcontrol plane
).This node can also be used as a
worker
node (currently called just anode
), 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:
and then you can use this node as both
control-plane
andnode
.But I guess some small kubernetes like
k0s
,k3s
, andmicrok8s
are better options for your use case rather than kubeadm.