Nodes in kubernetes
Higor Diego
Posted on January 14, 2023
Introduction
Kubernetes manages its workload by allocating containers in pods in order to run them on nodes. A node can be a physical or virtual machine.
depending on your cluster configuration. Each node contains its control plane containing the necessary resources to run its pods. The master type machine is responsible for controlling the nodes.
The components included in the node are kubelet, container runtime and kube-proxy.
Management of nodes
There are two ways to have a node added to Kube-apiserver.
- kubelet registering on control plane.
- Manually, creating your record based on the node-type object configuration.
When creating a node-type object, the control plane is responsible for validating, if correct, it creates it. Below is an example of json for creation.
{
"kind": "Node",
"apiVersion": "v1",
"metadata": {
"name": "10.20.10.125",
"labels": {
"name": "creating_node_k8s"
}
}
}
After registering the node in kubernetes, the kubelet validates that it was created with its corresponding metada.data
. If the node is available, it is able to receive pods creations, otherwise it will be ignored until it is ready
to receive the new cargo.
When the created node is unavailable, the form of loop will always be checked to identify a new status.
If you do not want to follow the standard routine, it will have to be deleted manually.
Node and its exclusives
Each node has its identification name, and if there is a repetition of the same, there may be duplication of the configuration, and with that, end up generating difficulty in updating data for the node, making it necessary to exclude one of the nodes in duplicate, in order to be able to create a node with your modifications.
There are some commands to register the node in the kubelet, as follows:
-
--kubeconfig
this flag performs data authentication in Kube-apiserver. -
--cloud-provider
this flag reads data from your cloud-controller-manager. -
--register-node
this flag performs self-registration in Kube-apiserver. -
--node-up
this flag informs the physical address the famous ip of the node. -
--node-status-update-frequency
this flag tells kubelet how often the health of the environment will be checked at the.
To create nodes, the administrator has free access to handle (manually) using the kubectl tool.
What is kubectl ?
Kubectl is a command-line tool for managing Kubernetes clusters. To be able to access the cluster, you will need an access file located in the $HOME/.kube
path.
If this file is in another location, use the following command:
kubectl --kubeconfig "file path"
We can install the tools on platforms GNU/Linux, MacOS and Windows, to install their respective OS.
For installation on GNU/Linux follow the commands below:
curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/ kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
kubectl version --client
For installation on MacOS follow the commands below:
sudo brew install kubectl
kubectl version --client
For installation on Windows click here.
To learn more about the installation we have the official documentation click here.
With kubectl we can modify the node objects, creating a node manually using the --register-node=false
flag. Each node has its status that contains some information, which are:
-
Address: The use of this field changes depending on your cloud provider or manual configuration;
- Hostname: this field is used to indicate the name of the node, which can be changed using the following flag `--hostname-override;
- ExternalIP: this field is to indicate the external IP of your cluster;
- InternalIP: this field is to indicate the internal IP of your cluster;
-
Conditions: this field is responsible for signaling the status condition of the running nodes;
-
Ready: this field signals whether or not the node is in compliance with the value (
True
orFalse
); -
DiskPressure: this field indicates whether it contains space on the hard disk with the value (
True
orFalse
); -
MemoryPressure: this field signals whether it contains space in memory with the value (
True
orFalse
); -
PIDPressure: this field signals if there are many processes in the node with the value (
True
orFalse
); -
NetworkUnavailable: this field signals whether the node's network is configured with a value (
True
orFalse
);
-
Ready: this field signals whether or not the node is in compliance with the value (
- Capacity and Allocatable: this field determines the amount of resources that are available on the node, such as CPU, memory and the amount of pods that fit on the node;
- Info: this field determines information about the nodes, for example: kernel version, container runtime and data about the node's operating system.
Heartbeats
This resource is responsible for validating the availability of the nodes, in order to identify computational failures, and to act when they occur. Thus, there are two forms for the heartbeats, which are:
- Updates with the status of a node;
- With Lease in its namespace in kube-node-lease and each node has its own object.
The kubelet is responsible for updating and creating the .status
of the nodes when there are changes.
The interval for updating the .status
of the node by default is 5 minutes, while the unreachable nodes are only 40 seconds.
So that's it guys, I hope you enjoyed it and until next time!
References
https://kubernetes.io/docs/concepts/architecture/nodes/#node-controller
https://kubernetes.io/docs/reference/kubernetes-api/cluster-resources/lease-v1/
https://livro.descomplicandokubernetes.com.br/pt/day_one/descomplicando_kubernetes.html
Posted on January 14, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.