Introduction
this is part 51 from the journey it's a long journey(360 day) so go please check previous parts , and if you need to walk in the journey with me please make sure to follow because I may post more than once in 1 Day but surely I will post daily at least one 😍.
And I will cover lot of tools as we move on.
Files for this lab
all the files can be found on the repository of this journey , if you already have it just pull if not clone it.
Files can be found here
Lab
if we have an pod already running it will not be affected by taint because it's running before the taint.
But every new pod will be affected.
to make our POD tainted we run
kubectl taint nodes minikube app=myapp:NoSchedule
this will taint our Node it had a key to determine it.
the key here is 'app' the operator is '=' and the taint effect is NoSchedule.
Now let's take a look for the file I prepare for this lab
it's called app_051.yml
kubectl create -f app_051.yml
kubectl get pods
We can see that the pod is holding on Pending because our node is tainted.
let's do toleration on this pod , I will do it in app_051_v2.yml
this is a look at the v2 , We specify inside spec the toleration of the pod we put same as our taint rules.
now let's delete our old pod
kubectl delete pods test-taint
now let's create new one using v2
kubectl create -f app_051_v2.yml
kubectl get pods
our pod start to create the container if you have a better pc and connection than me it will be running :p
kubectl taint nodes minikube app-
app is the key and - mean delete it
it's now untainted.
kubectl taint nodes minikube app=myapp:PreferNoSchedule
PreferNoSchedule mean "Hello master if you don't have an available pod came and put it inside of me" in another words I am your last choice.
let's delete our pod now again
kubectl delete pods test-taint
kubectl create -f app_051.yml
kubectl get pods
notice it's app v1 which doesn't have toleration inside of it.
It run immediately because we have no other Nodes (only 1 minikube) .
kubectl taint nodes minikube app-
let's remove taint again.
delete pod also again
kubectl delete pods test-taint
Break
End Break
let's go back to our Lab again.
Our last effect that we will talk about is NoExcute which means if you already have pods already running and they doesn't tolerated with condition of tainting terminate them and for every new pods it should be tolerated.
kubectl create deployment hello-node --image=k8s.gcr.io/echoserver:1.4
kubectl taint nodes minikube app=myapp:NoExecute
first I create an hello world image and waited to run the we can take a look at our v3 then I create it.
We can notice the hello-node is terminated because it doesn't have the requirements.
kubectl create -f app_051_v3.yml
kubectl get pods
We can see our hello-node pod is terminated and go back to Pending.
And our new pod is Starting the container.
kubectl taint nodes minikube app-
Top comments (0)