Software Engineering

Teach me Kubernetes – Part 2


Looking for the entire 7 part guide? Start at the Overview

In Kubernetes, a Node is a worker machine that runs containerized applications. Nodes are responsible for running Pods, which are the smallest deployable units in Kubernetes.

Nodes in a Kubernetes cluster can be physical or virtual machines, and they typically have multiple CPUs and large amounts of memory and storage. Each Node runs a container runtime, such as Docker or containerd, which is responsible for managing the containers that run on the Node.

Here are some important characteristics of Nodes in Kubernetes:

  • Nodes are managed by the control plane: Kubernetes uses a control plane to manage and coordinate the Nodes in the cluster. The control plane is responsible for scheduling Pods onto Nodes, monitoring the health of Nodes and Pods, and scaling the cluster up or down.
  • Nodes can have labels: Nodes can be labeled with key/value pairs that are used for scheduling Pods onto specific Nodes. Labels can also be used to group Nodes together for easier management and organization.
  • Nodes have a capacity: Each Node in a Kubernetes cluster has a finite amount of CPU, memory, and storage capacity. The control plane uses this information to schedule Pods onto Nodes that have available resources.
  • Nodes can be taints or tolerations: Nodes can be “tainted” with a label that indicates that they are not suitable for running certain types of workloads. Pods can be configured with “tolerations” that allow them to be scheduled onto tainted Nodes, but this should be used with caution.
  • Nodes can be cordoned or drained: Nodes can be “cordoned” to prevent new Pods from being scheduled onto them, and they can be “drained” to gracefully remove existing Pods from the Node before shutting it down.

Overall, Nodes in Kubernetes provide the infrastructure and resources necessary to run containerized applications. By managing Nodes through the control plane, Kubernetes makes it easier to scale and manage applications in a dynamic and distributed environment.

Hhere are some examples of managing nodes in Kubernetes using the command line interface (CLI):

Get information about the nodes:

$ kubectl get nodes

This command will display information about all the nodes in the Kubernetes cluster, including their name, status, and version.

Label a node:

$ kubectl label nodes <node-name> environment=production

This command will add a label named environment with a value of production to the node with the specified name.

Taint a node:

$ kubectl taint nodes <node-name> key=value:NoSchedule

This command will add a taint with a key/value pair of key=value and an effect of NoSchedule to the node with the specified name. This will prevent new pods from being scheduled on the node unless they have a matching toleration.

Uncordon a node:

$ kubectl uncordon <node-name>

This command will mark the specified node as schedulable again after it has been marked unschedulable due to a maintenance operation or other reason.

Drain a node:

$ kubectl drain <node-name>

This command will evict all the pods running on the specified node and mark it as unschedulable, allowing for maintenance or other operations to be performed on the node.

These are just a few examples of the many commands available for managing nodes in Kubernetes.