WEBVTT

00:00:06.400 --> 00:00:07.400
Good morning, everyone.

00:00:07.400 --> 00:00:14.060
Are you able to use the PDFs, Ralph?

00:00:14.060 --> 00:00:15.060
Okay.

00:00:15.060 --> 00:00:21.940
There are a couple of corrupted slides in SIX, so before each class I go through the

00:00:21.940 --> 00:00:26.260
slide deck and then always have to replace the corrupted slides.

00:00:26.260 --> 00:00:34.580
Yeah, those are the, every lesson starts with a default template and I build on that and

00:00:34.580 --> 00:00:38.340
And I use LibreOffice.

00:00:38.340 --> 00:00:43.240
And for some reason, if you have several slides and you haven't saved and it's been auto-saving,

00:00:43.240 --> 00:00:47.600
it corrupts the underlying data.

00:00:47.600 --> 00:00:51.580
And so that slide will continue to walk back up.

00:00:51.580 --> 00:00:57.610
So yes, yes, yes, yes.

00:00:57.610 --> 00:01:00.590
So that was one of the things I was trying to explain yesterday, that if I send you the

00:01:00.590 --> 00:01:06.470
slides early I go through them before the I go you know in the class and then

00:01:06.470 --> 00:01:12.270
I correct everything at that time because otherwise yeah today's important

00:01:12.270 --> 00:01:17.150
for lesson six you'll utilize this pretty heavily throughout production

00:01:17.150 --> 00:01:23.870
environments yeah all right so we're going to talk about kubernetes

00:01:23.870 --> 00:01:28.730
scheduling now the scheduler word that is scheduling ensures that pods are

00:01:28.730 --> 00:01:32.930
matched to nodes so that the kubelet can run them.

00:01:32.930 --> 00:01:37.130
Kubernetes scheduling is handled by the kube scheduler.

00:01:37.130 --> 00:01:39.170
And Kubernetes scheduling filters out

00:01:39.170 --> 00:01:42.870
any nodes that don't meet a pod's specific scheduling

00:01:42.870 --> 00:01:43.550
needs.

00:01:43.550 --> 00:01:46.290
Nodes that meet the scheduling requirement for a pod

00:01:46.290 --> 00:01:47.490
are called feasible nodes.

00:01:47.490 --> 00:01:49.610
If no nodes are available, the pod

00:01:49.610 --> 00:01:52.050
remains unscheduled until the kube scheduler

00:01:52.050 --> 00:01:53.450
finds a feasible node.

00:01:53.450 --> 00:01:56.850
Node labels and roles are key value pairs.

00:01:56.850 --> 00:02:00.330
Kubernetes ignores the value label for roles.

00:02:00.330 --> 00:02:03.190
Convention for role value is to set it to the same

00:02:03.190 --> 00:02:05.110
as a key or true.

00:02:05.110 --> 00:02:07.270
And occasionally, you'll see it empty.

00:02:07.270 --> 00:02:09.850
Labels and roles may be used in conjunction

00:02:09.850 --> 00:02:10.850
with node selector.

00:02:10.850 --> 00:02:13.130
Kube control is used to create and delete

00:02:13.130 --> 00:02:14.790
node labels and roles.

00:02:14.790 --> 00:02:22.060
Primary node roles are control plane, worker, and storage.

00:02:22.080 --> 00:02:23.760
Node selectors.

00:02:23.760 --> 00:02:26.200
The node selector is the simplest form

00:02:26.200 --> 00:02:28.000
of node selection constraint.

00:02:28.000 --> 00:02:31.740
The node selector key is added to the pod spec where they contain.

00:02:31.840 --> 00:02:35.440
The node selector key contains a key value pair.

00:02:35.600 --> 00:02:39.500
Node selector key value pair must match the node label exactly.

00:02:39.740 --> 00:02:44.780
And a node is required to meet the node selector key value to be scheduled.

00:02:44.780 --> 00:02:48.640
Node affinity is part of the pod spec affinity.

00:02:49.140 --> 00:02:52.480
So we have pod and then we have dot spec and then dot affinity.

00:02:52.860 --> 00:02:54.860
There are two primary types of node affinity.

00:02:55.820 --> 00:03:02.300
required during scheduling and preferred during schedule. Node Affinity offers more granular

00:03:02.300 --> 00:03:08.620
scheduling of pods. If we have a node role of storage in two nodes, one with a node label of

00:03:08.620 --> 00:03:15.260
fast and the other with a node label of slow, we can schedule a pod to require the storage role

00:03:15.900 --> 00:03:23.740
and prefer the fast label. If the fast storage node is not available but the slow storage node

00:03:23.740 --> 00:03:31.870
is, then our pod will be scheduled on the slow storage node. So this would allow us to still

00:03:32.430 --> 00:03:41.580
be able to run our application, although maybe not as with our program. So node selectors are

00:03:41.580 --> 00:03:49.020
a type of node affinity that allow pods to be attracted to or scheduled onto specific nodes.

00:03:49.020 --> 00:03:58.360
nodes. Taints are the opposite. They allow a node to repel pods. Taints are applied directly

00:03:58.360 --> 00:04:05.040
to the node. Taints are viewable in the node resources. And then we have, actually we do,

00:04:05.040 --> 00:04:14.620
we create a taint for a specific node in our lab. Oh, go ahead. So the taint is to repel.

00:04:14.620 --> 00:04:21.300
So let's say we have a control plane, then we would create a taint that would repel application

00:04:21.300 --> 00:04:24.660
pods from a site being scheduled onto the control plane.

00:04:24.660 --> 00:04:30.600
So we would taint the control plane, and then that would repel those pods.

00:04:30.600 --> 00:04:34.730
And we'll go through an exercise with it.

00:04:34.730 --> 00:04:36.290
And then we have tolerations.

00:04:36.290 --> 00:04:43.110
So tolerations then allow a pod to be scheduled to a node with a matching taint.

00:04:43.110 --> 00:04:46.950
So if it's tainted, and let's say we want to run cilium on the control plane, which

00:04:46.950 --> 00:04:53.230
we do, then we would provide a toleration to cilium.

00:04:53.230 --> 00:05:00.210
So tolerations are applied to pods, and the tolerations allow scheduling on the tainted.

00:05:00.210 --> 00:05:04.950
Tolerations don't guarantee scheduling if other parameters are not met.

00:05:04.950 --> 00:05:11.070
If it's storage but there are no space available, etc., then it still may not be scheduling.

00:05:11.070 --> 00:05:17.470
work with taints to ensure pods are not scheduled onto an inappropriate network.

00:05:17.470 --> 00:05:24.910
All right, jobs. So jobs are designed for one-off tasks. After successful completion,

00:05:24.910 --> 00:05:29.950
they will stop. The event describing the completed status is deleted after an hour.

00:05:29.950 --> 00:05:37.870
So typically the events are automatic. Jobs can run in a single pod or multiple pods in parallel.

00:05:37.870 --> 00:05:46.050
It is considered best practice to automatically clean up the jobs.

00:05:46.050 --> 00:05:51.050
Jobs can be used to enable metrics, such as add a metrics user to a database.

00:05:51.050 --> 00:05:52.050
You can use a job for it.

00:05:52.050 --> 00:05:56.150
The job can then be scheduled for deletion after 30 minutes.

00:05:56.150 --> 00:06:01.170
Chrome jobs are designed for repeating tasks or actions.

00:06:01.170 --> 00:06:06.370
Database backups, for example, log or metric shipping, report generation, if you want to

00:06:06.370 --> 00:06:09.130
to do this on a repeated basis, we would use a Chrome job.

00:06:09.130 --> 00:06:12.610
Chrome jobs can be used for SSD trim and garbage collection,

00:06:12.610 --> 00:06:14.910
as well.

00:06:14.910 --> 00:06:18.570
They're useful for deleting old snapshots.

00:06:18.570 --> 00:06:23.660
And Chrome jobs use standard Chrome syntax.

00:06:23.660 --> 00:06:28.360
Also use some Chrome macros, like an example of the format

00:06:28.360 --> 00:06:34.260
that we would use for scheduling a Chrome job.

00:06:34.260 --> 00:06:37.760
Some of the macros are available.

00:06:37.780 --> 00:06:46.340
And for our labs, we're going to practice with node labels, node roles, node selectors,

00:06:46.340 --> 00:06:49.780
taints, tolerations, jobs, and front jobs.

00:06:49.780 --> 00:06:55.780
The first step is start with a fresh Minikube environment and stop and delete Minikube if

00:06:55.780 --> 00:06:56.780
it's running.

00:06:56.780 --> 00:07:00.260
And then we will start Minikube and verify that the nodes are ready.

00:07:00.260 --> 00:07:03.060
And does everyone still have the...

00:07:03.060 --> 00:07:08.020
So I pushed up new YAML files for Lesson 6 and Lesson 7.

00:07:08.020 --> 00:07:13.620
So if you're using git pull origin, you may be able to just pull that right in, although

00:07:13.620 --> 00:07:19.560
you might have to address any issues if you've modified any of the files.

00:07:19.560 --> 00:07:20.560
Oh, yeah.

00:07:20.560 --> 00:07:21.560
Sure.

00:07:21.560 --> 00:07:22.560
Oh, yeah.

00:07:22.560 --> 00:07:28.560
Stanley, is it git pull origin or you can git clone with the HTTPS link?

00:07:28.560 --> 00:07:30.680
Oh, let's see.

00:07:30.680 --> 00:07:31.680
I think I put that in there.

00:07:31.680 --> 00:07:32.680
Let me see.

00:07:32.680 --> 00:07:40.260
Yeah, nginx-app.yaml. I added that in to lesson five. Remember we were bouncing back and forth between

00:07:42.700 --> 00:07:46.680
directories and so I went in and added that one in so we don't have to...

00:07:46.680 --> 00:07:51.060
Well, I guess you'll still have to go back to lesson five, but you won't have to go back to root.

00:07:51.060 --> 00:07:53.180
Yeah, I wanted to make that a little bit easier, but

00:07:54.700 --> 00:07:56.380
Yeah, probably

00:07:56.380 --> 00:07:58.380
it should be okay.

00:07:58.380 --> 00:08:05.060
If you've created anything new though, and you know, it's gonna wipe that out. Yeah, I think I put that into lesson five

00:08:05.400 --> 00:08:12.140
Once you have your nodes up and we'll go ahead and I think you could overwrite those. Oh, okay. Let's see

00:08:14.020 --> 00:08:16.660
So I want to help Ralph out, all right

00:08:18.240 --> 00:08:24.500
All right, we're gonna label a node for kubernetes.io node type equals test

00:08:24.500 --> 00:08:26.500
We can call these whatever we want. Oh

00:08:26.500 --> 00:08:34.780
We use that with kubectl, so this kubectl label node, and our node is minikub, which

00:08:34.780 --> 00:08:40.960
is our 01, but it's just minikub, and then we give it the name, so the key value, so

00:08:40.960 --> 00:08:45.880
kubernetes.io forward slash node type equals test.

00:08:46.000 --> 00:08:50.600
Once we've applied that, we're going to verify that the node label has been applied, so kubectl

00:08:50.600 --> 00:08:56.360
get nodes, and then we'll use a double hyphen, and then show hyphen labels.

00:08:56.500 --> 00:08:59.080
and you'll see a bunch of labels show.

00:09:00.720 --> 00:09:02.260
Parse through those labels

00:09:02.260 --> 00:09:06.000
and someone wants to read them out.

00:09:07.280 --> 00:09:09.060
And this is just on the control plane.

00:09:09.060 --> 00:09:11.120
So this is what we just applied, right?

00:09:12.400 --> 00:09:13.740
Okay, okay.

00:09:13.740 --> 00:09:16.020
And we see we have an exclude from load balancers.

00:09:16.020 --> 00:09:20.400
So, cause we don't want to announce the load balancers

00:09:20.400 --> 00:09:22.300
on the control plane.

00:09:22.300 --> 00:09:24.480
We wanna announce the load balancers

00:09:24.480 --> 00:09:26.540
as close to the service as possible.

00:09:29.040 --> 00:09:31.480
Okay, now we're gonna remove the node label.

00:09:31.480 --> 00:09:36.480
So we're gonna remove that node label that we just applied.

00:09:36.720 --> 00:09:41.360
And we do that instead of the node type equals test,

00:09:41.360 --> 00:09:44.300
it's just node type minus.

00:09:44.300 --> 00:09:47.180
So label node, we're gonna label the node again,

00:09:47.180 --> 00:09:48.960
Kubernetes IO node type.

00:09:50.060 --> 00:09:53.940
And then instead of equals test, we just do the minus.

00:09:53.940 --> 00:09:59.620
Once we do that, we'll verify that the node label was removed, the node type equals test.

00:10:01.850 --> 00:10:03.290
You can see that it has been okay.

00:10:04.750 --> 00:10:07.650
Now we're going to assign a role to a node.

00:10:07.750 --> 00:10:11.590
It is also a type of label, but it is a role type of label.

00:10:11.590 --> 00:10:19.910
So we're going to, again, label the node, but this time it will be node role, Kubernetes.io, node type equals test.

00:10:19.910 --> 00:10:25.650
And once we do that, we'll verify that the node role label has been applied.

00:10:25.810 --> 00:10:27.350
And I can see that on the rouse.

00:10:27.570 --> 00:10:32.690
And once you've verified that, now we're going to practice removing that node role label.

00:10:33.530 --> 00:10:40.190
And again, instead of node type equals test, the same command for the node type minus.

00:10:40.190 --> 00:10:41.650
Take it off the removing.

00:10:45.680 --> 00:10:47.500
Verify that it has been removed.

00:10:47.740 --> 00:10:48.980
And now we're going to...

00:10:49.500 --> 00:10:49.860
What's that?

00:10:49.940 --> 00:10:50.500
It just looks good.

00:10:50.500 --> 00:10:59.510
Who's still showing theirs? Let's see. Right here. So you should have run node-type equals test.

00:10:59.510 --> 00:11:08.510
So it should be node-role.kubernetes.io forward slash node-type equals test should have been the last.

00:11:08.510 --> 00:11:16.890
And then to remove that, I'm going to type kubectl label node minikub.

00:11:16.890 --> 00:11:27.750
Again, node-role.kubernetes.io forward slash node-type minus to denote the negative.

00:11:27.810 --> 00:11:28.870
Might have a typo.

00:11:29.470 --> 00:11:29.990
Typo.

00:11:31.110 --> 00:11:32.330
Everyone able to remove it?

00:11:32.550 --> 00:11:33.690
Okay, Stanley removed his.

00:11:35.370 --> 00:11:37.650
Let's see, Ryan, you have yours removed, right?

00:11:37.930 --> 00:11:38.290
Okay.

00:11:38.690 --> 00:11:42.590
And let's see, John, is yours still there or have you removed yours?

00:11:42.690 --> 00:11:42.970
Okay.

00:11:43.090 --> 00:11:44.010
And then how about you, Ralph?

00:11:44.070 --> 00:11:44.290
Okay.

00:11:44.290 --> 00:11:45.490
All right.

00:11:45.490 --> 00:11:51.970
So now we're going to label the node and then use kubernetes.io node type equals test.

00:11:52.110 --> 00:11:55.390
And then once you have that, show labels, make sure that it has been added.

00:11:55.670 --> 00:11:58.790
Did everyone understand what we were doing with those three exercises?

00:11:59.890 --> 00:12:00.330
Correct.

00:12:00.750 --> 00:12:01.150
All right.

00:12:01.210 --> 00:12:06.050
And once we have the labels present, I'm going to show the labels.

00:12:06.210 --> 00:12:07.910
Hey, what do you show for your labels?

00:12:09.090 --> 00:12:11.030
Is it in there in your label stack?

00:12:11.090 --> 00:12:11.610
Oh, okay.

00:12:11.610 --> 00:12:13.890
Cause when you, yeah.

00:12:13.890 --> 00:12:17.490
So when you went to remove it before you might've had a typo.

00:12:17.910 --> 00:12:23.350
And so when it responded back, it might've said not found when you went to remove it

00:12:23.350 --> 00:12:28.890
before, because it was a typo in there and you check and make sure you don't have a

00:12:28.890 --> 00:12:29.370
typo.

00:12:29.390 --> 00:12:33.270
Actually go ahead and remove that and then reapply it just to be sure.

00:12:33.650 --> 00:12:39.310
So make sure you can remove that role or I'm sorry, that label of node type equals

00:12:39.310 --> 00:12:48.230
test and then reapply it again. It's going to be node type minus. Okay. And let's go ahead and

00:12:48.230 --> 00:12:54.290
label it again just to make sure it will work. All right. Okay. And then if you show your labels,

00:12:54.290 --> 00:13:00.710
it should be in there. Move on to the next one. Okay. So, and this should be in

00:13:00.710 --> 00:13:12.150
Lesson 6, let's see, it should be pod-selector, node-selector.yaml, I believe, and then we're

00:13:12.150 --> 00:13:20.190
going to apply this, and my slides are frozen, there we go, make sure it matches what I have

00:13:20.190 --> 00:13:25.810
on the screen before you apply it. Hey, Stanley, did you not have that in your lesson 6? Yeah,

00:13:25.810 --> 00:13:33.590
Yeah, I think, yeah, so for you guys, I went and created everything for you, but normally

00:13:33.590 --> 00:13:37.370
for my students, I don't create the YAML file, so I have them type everything.

00:13:37.450 --> 00:13:38.090
Okay, good.

00:13:38.370 --> 00:13:41.430
Yeah, you can just use what I have in the lesson six.

00:13:41.550 --> 00:13:43.810
You don't have to type it all out, unless you just want to.

00:13:45.010 --> 00:13:49.810
Okay, so now let's check the pod events and configuration.

00:13:50.710 --> 00:13:52.710
Control, describe pod, node selector.

00:13:52.710 --> 00:13:56.310
and someone will tell me what they see. Why is the pod in pending status? That's correct,

00:13:56.310 --> 00:14:01.910
it won't sign an IP until it can find something to skip. Okay.

00:14:04.230 --> 00:14:09.990
Yeah, so it says zero of one nodes are available. One node didn't, I'm trying to read

00:14:11.110 --> 00:14:17.270
some screen here. One node didn't match pods node affinity selector. On this case it's going to be

00:14:17.270 --> 00:14:24.910
selector, right? Because we used a node selector on this pod spec. So if you remember down

00:14:24.910 --> 00:14:32.000
at the bottom of that file, we had node selector, node type, and what is listed for the node

00:14:32.000 --> 00:14:38.040
selector, okay? And what is listed for the node label? So let's change the YAML file

00:14:38.040 --> 00:14:43.560
to reflect the correct node selector. And we'll need to delete the current running pod

00:14:43.560 --> 00:14:51.880
using kubectl delete hyphen f pod node selector.yaml and then we'll re-apply it

00:14:52.920 --> 00:15:01.440
the same file after we change it and let's check and see if it's ready so check the pod ready state

00:15:02.000 --> 00:15:09.680
kubectl get pods pending okay so and why isn't it ready and how do we check the pod events yeah

00:15:09.680 --> 00:15:17.400
So let's describe the pod node selector. Okay, so why is the pod still in pending state?

00:15:17.400 --> 00:15:24.440
Check the node labels. Do they match exactly? So show your node labels

00:15:24.440 --> 00:15:29.600
for Minicoob and then compare it to the file that you just applied and see if

00:15:29.600 --> 00:15:33.620
they match exactly. Okay, if you look at your pod description you have a node

00:15:33.620 --> 00:15:40.640
selector there. So it's below QoS class you'll see a node selector and then and

00:15:40.640 --> 00:15:46.500
what does the node selector say? Correct. Correct. So it's looking for an exact

00:15:46.500 --> 00:15:51.560
match. Let's change the YAML file to reflect the correct node selector and

00:15:51.560 --> 00:16:08.380
again I need to delete and then reapply. And now let's check the logs. You can see

00:16:08.380 --> 00:16:14.620
that we're running. All right. So now how do we check the node resource utilization?

00:16:16.550 --> 00:16:21.290
Control logs and then node selector because we're in the default namespace. So we don't

00:16:21.290 --> 00:16:27.070
need a namespace. Everything has spun up and is now running. And then how do we check the

00:16:27.070 --> 00:16:40.220
node resource utilization? Yeah, so when we request, we're scheduling and telling the

00:16:40.220 --> 00:16:49.380
scheduler hey i need let's say i need a quarter of a cpu of a v cpu virtual cpu then we would say i

00:16:49.380 --> 00:16:59.300
need cpu 250m and that's a quarter of a cpu a cpu is a thousand units um so we we schedule it and

00:16:59.300 --> 00:17:07.480
request that and if the node does not have a quarter of a cpu available then that node would

00:17:07.480 --> 00:17:12.400
not be available to schedule on so we can do that in order to keep from

00:17:12.400 --> 00:17:20.440
overloading our nodes we can request and then we can limit our usage of both CPU

00:17:20.440 --> 00:17:28.480
and RAM by utilizing the same same method so we can request say one gig

00:17:28.480 --> 00:17:33.820
of it of RAM and if there is not enough RAM available on that node then we won't

00:17:33.820 --> 00:17:44.060
able to schedule to that node so that can be very um kind of yeah so we generally don't max the cpu

00:17:46.380 --> 00:17:53.340
we don't limit the cpu but we do limit memory so generally you will request cpu and memory

00:17:53.340 --> 00:18:01.580
and then you will limit memory only and the reason why is we rarely have applications that run full

00:18:01.580 --> 00:18:10.460
cpu and so we want to give our applications an additional overhead if they need it to run cpu

00:18:10.460 --> 00:18:18.380
because it's generally just for a fraction of a second and so we want to make sure that that's

00:18:18.380 --> 00:18:24.540
available to our application in the event that they need it but the there are two ways to do

00:18:24.540 --> 00:18:31.740
that you can you can request and limit at the same amount for RAM or you could

00:18:31.740 --> 00:18:36.960
request and let in your limit being twice the amount of your request so it

00:18:36.960 --> 00:18:43.260
just depends on your application and you know what that application is doing in

00:18:43.260 --> 00:18:47.820
that resource that it needs to have access to and that comes about from

00:18:47.820 --> 00:18:53.860
testing so we test that out and we'll watch this or we'll top our node and top

00:18:53.860 --> 00:19:00.660
our pod and we'll determine what the application is using and that can also help us determine if

00:19:00.660 --> 00:19:05.940
we have an error app running if you have an app that should be limited at one cpu and you see it

00:19:05.940 --> 00:19:12.020
spiking to three cpus or if it should be limited to a half a gig of ram and all of a sudden it's

00:19:12.020 --> 00:19:16.820
blowing up and using two gig and then three gig and then four gig we know we have a problem with

00:19:16.820 --> 00:19:23.620
the application and that's where those limits can you know really come in handy and keep from

00:19:23.620 --> 00:19:28.260
taking down the node and starting our other applications every so you can see here some of the

00:19:30.260 --> 00:19:38.740
some of the nodes have requests but not all of them have requests right and then node selector

00:19:38.740 --> 00:19:43.380
doesn't have request and let's see i'm pretty sure we don't have limits on anything for cpu

00:19:44.100 --> 00:19:52.420
and then we do have limits on something for memory uh let's see core dns maybe and my guess is that

00:19:52.420 --> 00:19:57.460
most of those just don't take a lot of memory. Very small memory requirements, so they don't

00:19:57.460 --> 00:20:04.580
even bother requesting the memory from you. It's amazing how many containers on Kubernetes

00:20:04.580 --> 00:20:12.100
that run, and they can run on a request of 100 M, which is a tenth of a CPU, and then

00:20:12.660 --> 00:20:19.380
the RAM can be as low as like megabyte, like 64 meg, right? And you'll see that frequently

00:20:19.380 --> 00:20:28.220
for low-load containers that run within pods. Okay, now we're going to delete the

00:20:28.220 --> 00:20:31.700
pod using a different method. We're going to Coup Control, delete pod, node

00:20:31.700 --> 00:20:39.940
selector. I'm not even going to mess with the file. After we delete the pod, we're going to remove

00:20:39.940 --> 00:20:46.220
the node label and show your label to make sure that it has been removed. If anyone

00:20:46.220 --> 00:20:51.460
still has their label, let me know. I'll move on to the next. Okay, has everyone

00:20:51.460 --> 00:20:58.580
removed their label? Now, I'm going to taint by def, and freeze this here. Now we're

00:20:58.580 --> 00:21:03.620
gonna taint the control plane node. So this is what Stanley had asked me

00:21:03.620 --> 00:21:08.000
about earlier. So we're gonna actually kubectl taint this time. So we're gonna

00:21:08.000 --> 00:21:17.460
the taint nodes minikub pod equals true colon no schedule all right and once tainted so now

00:21:17.460 --> 00:21:20.860
you don't want to guess how we can verify that the taint has been applied

00:21:20.860 --> 00:21:28.840
that's a good guess but um no so we're gonna kubectl describe node minikub again and under

00:21:28.840 --> 00:21:34.900
taints you should see taints pod equals true no schedule scroll all the way up to taints all right

00:21:34.900 --> 00:21:37.380
And that's where you can verify if a node has been tainted.

00:21:38.260 --> 00:21:42.320
So now we're going to deploy a pod to a tainted node to see what happens.

00:21:43.400 --> 00:21:47.880
So we're going to, well, we were going to copy the previous pod deployment to pod taint,

00:21:47.980 --> 00:21:50.220
but I made it available to you.

00:21:50.240 --> 00:21:52.720
So just make sure it matches what's on the screen here.

00:21:52.820 --> 00:21:58.840
And it would be pod-taint.yaml is the file we're looking for in your lesson six folder.

00:22:00.680 --> 00:22:01.080
Correct.

00:22:02.700 --> 00:22:04.560
So let's create the namespace.

00:22:04.900 --> 00:22:09.060
and then it's applied. And let's check if the pod is running. Okay, we're able to see if the

00:22:09.060 --> 00:22:13.220
pod is running. That's the next step. Let's describe the pod and see what's going on.

00:22:14.980 --> 00:22:22.100
So remember we tainted the node and now the node has an untolerated taint,

00:22:22.900 --> 00:22:28.100
so it's repelling the pod doing exactly what it is supposed to do. It repels that pod,

00:22:28.100 --> 00:22:35.460
so that pod cannot schedule on it. So how do we get the pod to schedule on that node?

00:22:37.410 --> 00:22:43.890
The pod needs a toleration now so it can attach to a tainted node. So we add the tolerations to

00:22:43.890 --> 00:22:49.170
the specs section of the manifest file. So we're going to delete the pod as I'm going to have the

00:22:49.170 --> 00:22:57.330
pod deleted and now we're going to look for the pod tolerated.yaml file and make sure it matches

00:22:57.330 --> 00:23:05.970
this and what we have is we've added a toleration here and we have an effect no schedule the key is

00:23:05.970 --> 00:23:11.570
pod the operator is equal and the value is true but that is the difference that is what we've

00:23:11.570 --> 00:23:17.410
added to this so now this pod should be tolerated to make sure it matches this then go ahead and

00:23:19.010 --> 00:23:25.010
apply yep you'll go ahead and apply it and go ahead has everyone applied it go ahead and check

00:23:25.010 --> 00:23:30.450
your pods. Did you apply it? Oh, so you're going to describe the pod but the pod name

00:23:31.170 --> 00:23:41.320
and remove the yaml. So the pod name is pod ns f a. Under metadata name,

00:23:41.320 --> 00:23:45.880
it'll provide the name of the pod. So we have pod hyphen ns hyphen app hyphen a.

00:23:47.400 --> 00:23:54.920
And you will need a namespace in there as well because we have a namespace to app hyphen a.

00:23:54.920 --> 00:24:01.800
so you'll do a hyphen in for namespace and then app hyphen there it is all right so now everyone

00:24:01.800 --> 00:24:09.800
has it described out and what does it say your one nodes are available but we we tolerated it

00:24:09.800 --> 00:24:16.760
right so now it's not giving us the untolerated taint message but it is telling us that we have

00:24:16.760 --> 00:24:24.760
an affinity selector issue all right so what does our node selector say it's right in front of you

00:24:24.920 --> 00:24:30.760
right above your tolerations right above your events i'll say node selector someone read that

00:24:30.760 --> 00:24:37.880
jimmy okay and um let's look at the node show labels so what is what what does the control

00:24:37.880 --> 00:24:42.840
plane say yeah so it's equals nothing after that right so true is missing at the end

00:24:44.200 --> 00:24:50.040
so we need to relabel the node to reflect that control plane equals to true everyone tried to

00:24:50.040 --> 00:24:54.600
apply it. So we have a label that already exists. Now we need to overwrite it. So

00:24:54.600 --> 00:25:00.780
we're gonna re-label the node using the overwrite flag. And then we'll check the

00:25:00.780 --> 00:25:05.720
node labels and make sure that it's labeled correctly. And now check your

00:25:05.720 --> 00:25:10.940
pods and see if it's running. I'm not sure. I haven't actually done it that way.

00:25:10.940 --> 00:25:15.420
There are applications that are looking specifically for that node selector and

00:25:15.420 --> 00:25:22.400
they will probably start repelling off of there and you'll see them go into

00:25:22.400 --> 00:25:26.460
terminated status would be my guess. Yeah, so we wouldn't actually do this live on a

00:25:26.460 --> 00:25:30.280
server. This is just so you can understand how it works. We would do this

00:25:30.280 --> 00:25:34.280
with infrastructure as code and it would be set as a server is spinning up.

00:25:34.280 --> 00:25:40.460
And anytime we want to change this, we would change it on our development server

00:25:40.460 --> 00:25:44.080
and then write that into the infrastructure as code. So we would

00:25:44.080 --> 00:25:50.240
never do this on a production server, but if we wanted to add a new node

00:25:50.240 --> 00:25:55.480
role or a toleration or a taint, we would test it on a test server first.

00:25:56.960 --> 00:26:02.220
So this gives you the way to be able to verify it and modify it on a development.

00:26:03.380 --> 00:26:04.740
It's okay.

00:26:06.280 --> 00:26:08.480
So pods should be running, right?

00:26:08.480 --> 00:26:09.540
Let's check the pod event.

00:26:09.580 --> 00:26:09.940
All right.

00:26:09.940 --> 00:26:13.920
And now we're going to destroy a namespace and all of its resources.

00:26:14.160 --> 00:26:15.080
So let's watch what happens.

00:26:15.100 --> 00:26:18.420
Destroy the namespace app A and verify that the resources have been destroyed.

00:26:18.540 --> 00:26:20.340
All right, we're going to take a quick two-minute break.

00:26:20.780 --> 00:26:24.560
And when we come back, we will create a job.

00:26:25.380 --> 00:26:27.100
Back in about two minutes.

00:26:27.100 --> 00:26:31.440
When you come back from break, you want to make sure you have a fresh Minikube profile.

00:26:31.640 --> 00:26:36.800
All right, so sometimes it's just easier to understand if you see the error while you're going through.

00:26:36.800 --> 00:26:40.960
So I like to, especially with taints and tolerations, teach you with errors

00:26:41.640 --> 00:26:43.740
so you can see the error for the first time.

00:26:45.440 --> 00:26:48.040
And hopefully it'll help you out later on

00:26:49.040 --> 00:26:51.040
when you do encounter that error.

00:26:51.240 --> 00:26:58.240
Yeah, and sometimes it also helps if you're typing out the YAML because you'll see the differences in the three different YAML files.

00:27:00.420 --> 00:27:01.920
Okay, so now...

00:27:01.920 --> 00:27:02.800
Go ahead.

00:27:02.800 --> 00:27:10.960
Yeah, it takes a while to write these and try to, you know, find the best mix here for the errors.

00:27:11.160 --> 00:27:13.680
Because sometimes errors are just not descriptive at all.

00:27:15.080 --> 00:27:16.300
It's not real helpful.

00:27:17.480 --> 00:27:22.520
So make sure your job.yaml that's in your folder matches the screen.

00:27:22.520 --> 00:27:24.960
When you're sure that it matches, go ahead and apply it.

00:27:25.120 --> 00:27:28.750
Do you see a case issue?

00:27:28.910 --> 00:27:30.050
Oh, lowercase hello.

00:27:30.290 --> 00:27:31.070
Oh, that'll be fine.

00:27:31.070 --> 00:27:38.750
Yeah, and if you apply it, let's check the pods, remember this did not have a namespace

00:27:38.750 --> 00:27:40.850
so it will be on the default namespace.

00:27:40.850 --> 00:27:45.950
And notice that the ready state is, let's say zero over one, right?

00:27:45.950 --> 00:27:50.630
It means that it had a container in the pod, but none of the containers are running right

00:27:50.630 --> 00:27:51.630
now.

00:27:51.630 --> 00:27:54.430
And now everyone else is able to apply it.

00:27:54.430 --> 00:27:59.470
It looks like you might have, oh yeah, so it looks like you don't have a minikube.

00:27:59.470 --> 00:28:04.190
You have a kubectl and a kubconfig and it can't find your cluster.

00:28:05.750 --> 00:28:10.310
So it's trying to hit whatever that endpoint is and it's saying

00:28:10.310 --> 00:28:12.030
that the connection is refused.

00:28:12.050 --> 00:28:13.910
And now you know what that error looks like.

00:28:14.010 --> 00:28:18.650
And sometimes you'll just see like four, you know, localhost 8080 can't connect.

00:28:18.650 --> 00:28:18.870
All right.

00:28:18.870 --> 00:28:20.170
So now we'll check the job.

00:28:20.270 --> 00:28:22.150
So kubectl get job.

00:28:22.370 --> 00:28:29.410
Notice that the batch shows complete and the number of completions is one of one.

00:28:29.470 --> 00:28:34.750
Oh yeah, so we can do the logs, so kubectl logs, and then the name of the pod.

00:28:34.750 --> 00:28:36.010
Remember what the name of the pod is?

00:28:36.010 --> 00:28:39.930
I believe the name is hello single job or something like that.

00:28:41.210 --> 00:28:41.970
Isn't that the name?

00:28:41.970 --> 00:28:43.830
There you have a hash.

00:28:43.830 --> 00:28:44.670
Does it say hello?

00:28:44.730 --> 00:28:45.030
All right.

00:28:45.690 --> 00:28:48.210
And it should be at like a date and time that it actually ran.

00:28:51.380 --> 00:28:52.860
Yeah, I totally get it.

00:28:54.600 --> 00:28:55.080
Okay.

00:28:55.080 --> 00:28:58.080
So we can see that we have completions one of one, so that's good.

00:28:58.080 --> 00:29:06.000
But, um, if we do kubectl get pods, hyphen a, it just kind of hangs around, right?

00:29:06.480 --> 00:29:10.080
What happens if we just keep running jobs for a few weeks?

00:29:10.120 --> 00:29:12.540
Yeah, it's going to keep getting cluttered, right?

00:29:12.600 --> 00:29:13.860
Do we want that clutter?

00:29:13.880 --> 00:29:15.000
I mean, probably not.

00:29:15.640 --> 00:29:16.140
Yeah.

00:29:16.560 --> 00:29:16.960
All right.

00:29:16.960 --> 00:29:19.920
So let's create a job that we could have checked.

00:29:19.980 --> 00:29:20.460
Here we go.

00:29:20.460 --> 00:29:22.620
Let's go here and we're going to delete the job.

00:29:22.620 --> 00:29:24.080
This is another way to describe it.

00:29:24.080 --> 00:29:31.840
so we can kubectl describe the job hello single job now we can kubectl delete job

00:29:32.400 --> 00:29:37.040
hello single job and i believe you'll need a hash actually you may not need the hash on the

00:29:37.040 --> 00:29:41.200
end of that no because we're not deleting the pod we're deleting the job so i believe it will work

00:29:41.200 --> 00:29:46.000
without that yeah if you're deleting the pod you would need the hash but if you're just deleting

00:29:46.000 --> 00:29:52.080
the job the job name itself is hello correct and it tracks itself with a hash so it tracks the pods

00:29:52.080 --> 00:29:59.680
with a hash. So if it were to spin up multiple jobs, each job would have its own hash. Each pod

00:29:59.680 --> 00:30:06.780
would have its own. Okay, so now has everyone deleted the job? Hello single job? Okay, so now

00:30:06.780 --> 00:30:13.660
let's automatically clean up our completed jobs. So we should have an auto job autodelete.yml that

00:30:13.660 --> 00:30:22.990
we can apply and make sure that it matches this. And the difference is we added a TTL time to live

00:30:22.990 --> 00:30:30.750
seconds after finish 30. So what this is telling it with this extra line is that after 30 seconds

00:30:30.750 --> 00:30:38.350
we want to delete it. So 30 seconds after it finishes completely completed successfully we

00:30:38.350 --> 00:30:50.490
want to delete it. All right so now we'll go ahead and apply it and we'll do kubectl get job

00:30:50.490 --> 00:30:56.010
and we'll see it there and after 30 seconds it should no longer be present. So if we keep trying

00:30:56.010 --> 00:31:04.330
we'll see that it will disappear all right yeah that leads us to this if you auto delete a job

00:31:04.330 --> 00:31:09.370
and you'd like a record that it has been run successfully what process should be implemented

00:31:09.370 --> 00:31:18.250
in the cluster yeah log and event shipping to a kubernetes native logging system so we'd be

00:31:18.250 --> 00:31:24.810
able to go to our grafana and actually view the logs and events even though it's been deleted

00:31:24.810 --> 00:31:31.770
All right, let's create a cronjob. So go to your cronjob.yaml and make sure it matches this.

00:31:31.770 --> 00:31:36.890
And once you have made sure that it matches, you can apply it. And you can see that we're

00:31:36.890 --> 00:31:44.890
scheduling this. So basically, I believe it's scheduled to run every 60 seconds.

00:31:46.810 --> 00:31:54.590
Yeah, so if we were to go back to a previous chart, it should be every 60 seconds. So let's

00:31:54.590 --> 00:32:00.430
go ahead and apply it and we can do kubectl get chrome job we can describe the chrome job

00:32:00.990 --> 00:32:06.830
and after we get over 60 seconds we'll see what happens here you should see another pod spinning

00:32:06.830 --> 00:32:14.190
up now another job and we'll let it keep running for about oh let's see let's give it how long have

00:32:14.190 --> 00:32:21.150
we been running how many seconds since the first one started anyone tell me okay let's go to four

00:32:21.150 --> 00:32:25.230
let's see what happens after about four minutes so keep checking you should see three now

00:32:26.430 --> 00:32:34.110
close to it i think we get over 120 seconds it'll spin up the third one there we go right and let's

00:32:34.110 --> 00:32:42.750
keep let's take about another minute and then we'll see what it does here after the third one

00:32:42.750 --> 00:32:46.510
is completed and it gets ready to spin up before because now we're getting kind of cluttered right

00:32:46.510 --> 00:32:53.310
we've got three of them in there in our list and let's see what happens. And you can look at this

00:32:53.310 --> 00:32:58.990
with kubectl get pods. You can see with kubectl get pods and as soon as we see three minutes

00:32:58.990 --> 00:33:06.030
go by on the age we'll watch it again. One of them went away right? Yeah so it will maintain

00:33:06.030 --> 00:33:11.950
three and you can set that but um the standard the default is three and so it will maintain three

00:33:11.950 --> 00:33:22.930
actively in there. You can set it to 2 I believe or even 1 and that way you know

00:33:22.930 --> 00:33:27.950
that they've been running successfully. But it won't continue to clutter up your

00:33:27.950 --> 00:33:32.570
list. So it creates a new pod for each run with a new name and hash and then it

00:33:32.570 --> 00:33:37.750
deletes the old successfully completed pods automatically. Well now let's go

00:33:37.750 --> 00:33:41.730
ahead and delete the Chrome job. Alright so everyone should be deleted. Now let's

00:33:41.730 --> 00:33:47.730
create a job with a node selector and toleration so that's kind of a team exercise i'll let you

00:33:47.730 --> 00:33:54.210
guys turn on your microphones and and work this out as a team so first ensure we have a fresh

00:33:54.210 --> 00:33:59.890
minicoop cluster minicoop stop and you could delete double hyphen all and then minicoop starting

00:34:00.770 --> 00:34:06.770
all right so as a team you guys can work this out between you we're going to ensure we have

00:34:06.770 --> 00:34:13.810
a labeled node with a role of control plane equals true. Verify the control plane node has a role

00:34:13.810 --> 00:34:22.450
labeled tainted. We're going to create a job with a TTL of 180. Remember before we did 30 seconds.

00:34:22.450 --> 00:34:29.890
We're going to do 180. We're going to add a node selector and a toleration using spec.template.spec.node

00:34:29.890 --> 00:34:37.170
selector and spec.template.spec.tolerations. We're going to deploy the job, test and troubleshoot,

00:34:37.170 --> 00:34:41.890
see if there are any issues, and then we're going to make sure it auto-deletes. I'm still

00:34:41.890 --> 00:34:49.890
working it out. Okay, is your node tainted? Kube control, describe node, minikube, and scroll up

00:34:49.890 --> 00:34:56.050
to the top and you should see it taint. Okay, so to taint the node, we had a kube control command

00:34:56.050 --> 00:35:02.690
that we ran which tainted the node. So if you scroll up through your bash history you'll find

00:35:03.570 --> 00:35:09.090
a kubectl command that tainted the node. I think I saw that Stanley found that early on and applied

00:35:09.090 --> 00:35:14.450
it. No it won't be a yaml file it's a kubectl command where you taint the node. Start with

00:35:14.450 --> 00:35:21.650
kubectl and it has the word taint and then nodes and then you just give it the node name so it'll

00:35:21.650 --> 00:35:28.610
the mini kube and then you have your taint after uh john has it up correct looks like

00:35:29.410 --> 00:35:35.970
and as long as you're when you describe your node as long as your node has a taint

00:35:37.250 --> 00:35:45.410
then yep there you go okay there you go yeah that's correct all right so

00:35:46.050 --> 00:35:50.130
to review lesson six and this is actually one of the more key lessons that you'll

00:35:50.690 --> 00:35:57.170
you'll put into practice with your production cluster. So we learned how to apply taints to

00:35:57.170 --> 00:36:03.810
a node and repel pods, how to apply tolerations to a pod to enable scheduling on a node.

00:36:04.770 --> 00:36:09.010
We learned how to destroy a namespace and all of its resources, how to automate tasks with

00:36:09.010 --> 00:36:16.770
jobs and chrome jobs, when a job is appropriate for single tasks, when a chrome job is appropriate

00:36:16.770 --> 00:36:22.610
for repeating happens to the logs and events when we auto delete and jobs create a new pod

00:36:22.610 --> 00:36:29.810
for each job how chrome jobs delete successful thought jobs after completion all right we're

00:36:29.810 --> 00:36:36.370
going to go ahead and take a 30 minute break for lunch and we'll be back at 1 35 eastern time
