Lab: Taint, Namespace,ResourceQuota & LimitRange

In this lab:

What is taint in kubernetes and why master is tainted?

Taints are used to influence where workloads are placed (scheduled) within the cluster. A taint on a node tells the Kubernetes scheduler that only pods with matching “tolerations” (an attribute in pod specifications) are allowed to be scheduled on that node. “master” nodes (also known as control plane nodes) are responsible for managing and coordinating the entire cluster.

Lab: Check the master node Taint and un-taint it to schedule the workoad

Note: This is not recommended in production, only for training or testing purpose

kubectl get nodes
kubectl describe nodes <provide the master node name from get nodes command>|grep Taint

Un-taint the master node

kubectl taint node <node name> <Taintvalue>-

example: kubectl taint node k8s

kubectl describe node <node name> |grep Taint


Lab2: Namespace

Create namespace from command line

kubectl create ns labs

kubectl describe ns labs

kubectl get ns labs -o yaml

kubectl delete ns labs

//delete command will delete all the resources of namespace

If you want to create namespace from yaml file

use vi editor and open ns.yaml, copy/paste the below code and save it

apiVersion: v1
kind: Namespace
  name: labs
  • apiVersion: Specifies the API version being used, which is v1 in this case.
  • kind: Specifies the kind of resource, which is a Namespace.
  • metadata: Contains metadata about the Namespace.
    • name: Specifies the name of the Namespace, which is “labs” in this  example

Run command

kubeclt create -f ns.yaml

kubectl get ns

kubectl describe ns labs

Lab3: Assign ResourceQuota namespace

git clone
cd k8s
check the rquota.yaml file

kubectl create ns labs
kubectl apply -f rquota.yaml
kubectl describe ns labs
kubectl delete ns labs

Lab 4: assign LimitRange to namespace

kubectl create ns labs
kubeclt apply -f lrange.yaml
kubectl describe ns labs
kubectl api-resources
kubectl delete ns labs
  • ResourceQuota limits the total resources that can be used within the “labs” namespace. It specifies maximum numbers of pods and limits on CPU and memory usage for requests and limits.
  • LimitRange defines constraints on resources for containers within pods. It specifies limits on CPU and memory for containers, as well as default and minimum values for requests.