Skip to content

KennethS0/K8s-taints

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

K8s-taints

This repository shows how we can configure different pods/deployments to be executed in specific nodes based on taints and tolerations.

In this case we have 3 different types of nodes:

  1. Public node (Any pod is able to be executed here)
  2. Private node (Only database related pods should be allowed to be executed here)
  3. Critical node (Only critical pods are supposed to be executed here)

Create Cluster and Nodes

To create these different node we make use of kind, which allows for an easier way to create clusters and nodes. The following command creates the different nodes with corresponding labels in order to identify them.

kind create cluster --config kind-cluster.yaml -n taint-cluster

The kind-cluster.yaml file contains the configurations necessary to set labels to the different worker nodes to identify them. This is useful for monitoring and later on applying any taints or specific configurations to the node.

To apply the taints run the apply-taints.sh file, inside you will find 2 kubectl commands that filter by the name tag given in the kind-cluster.yaml.

With the following commands we can examine the configurations of the nodes to verify the taints and labels:

  • kubectl cluster-info --context kind-taint-cluster: Shows general data.
  • kubectl get nodes --name=taint-cluster: Obtains the nodes that are being executed, to make sure all of them were created.
  • kubectl describe node <node-name>: Obtains the specific node data.

Create Pod

Creating a pod is very straight forward. Just execute the following command: kubectl apply -f nginx-pod.yaml

The nginx-pod.yaml file does not contain any toleration or nodeSelector so it will end up being created in the node with the label name=public-node.

Create Deployments

Both of the deployments contain tolerations, this allows them to be created in nodes that have taints on them.

The postgres.yaml file contains the configuration necessary for the pod to be created ONLY in nodes that contain the taint key=data-storage:NoSchedule.

To create the Deployment run the following command: kubectl apply -f postgres.yaml

The httpd.yaml file contains the configuration necessary for the pod to be created ONLY in nodes that contain the taint key=critical-app:NoSchedule and nodes with the label name=critical-node.

To create the Deployment run the following command: kubectl apply -f postgres.yaml

Monitor Pods and Deployments

Execute kubectl get pods -o wide to see in which node the pods are being created.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages