WEBVTT

00:00:00.000 --> 00:00:04.160
All right, I think we're just waiting on John and early year timeline.

00:00:07.960 --> 00:00:10.640
Tampa based out of Tampa.

00:00:10.760 --> 00:00:11.000
All right.

00:00:11.000 --> 00:00:18.800
Yesterday we left off with creating a namespace and then using a pod manifest.

00:00:19.800 --> 00:00:23.120
We created a pod while we work on our YAML syntax.

00:00:23.120 --> 00:00:27.440
We'll have a few more YAML files with this lesson.

00:00:27.520 --> 00:00:31.960
And then after that, I'll provide all the YAML files to you for the next lesson.

00:00:31.960 --> 00:00:38.760
and the reason I do that with my training is I've just found that almost half of the errors

00:00:38.760 --> 00:00:45.640
that we experience in Kubernetes come from syntax errors so we can learn how to you know build a

00:00:45.640 --> 00:00:53.740
manifest file correctly at least even though the error might not be descriptive you might be able

00:00:53.740 --> 00:01:00.000
to look at the manifest file even if someone else created it such as a helm values.yaml file and

00:01:00.000 --> 00:01:04.960
hopefully you'll be able to see where the error is because that's a like i said it's about half

00:01:04.960 --> 00:01:10.320
of our troubleshooting is you know manifest errors when we're running our clusters all right so our

00:01:10.320 --> 00:01:17.570
next step we're going to deploy a replica set and see if everyone has it share a fresh minicoob

00:01:17.570 --> 00:01:25.250
cluster and we're going to create a deployment file trying to remember what those commands are

00:01:25.250 --> 00:01:32.130
minicoop stop and then minicoop delete double hyphen all uh not quite yet um yeah you can go

00:01:32.130 --> 00:01:40.290
ahead and yeah you can go ahead and um just do a minicoop start and look at this yeah go ahead and

00:01:40.290 --> 00:01:50.350
run minicoop start it'll help you out if all of your manifest files are created in the same

00:01:50.350 --> 00:01:55.710
directory and on this note the labels as you type this out and we'll have a just a few more

00:01:56.510 --> 00:02:03.150
um of these for this lesson for lesson four and then i'll provide the rest of the um

00:02:03.870 --> 00:02:09.470
yaml files for you all right stanley would you figure out do you know which indentation

00:02:09.470 --> 00:02:18.110
all right looks like ralph is his and then uh see ryan and then john what's your right here

00:02:21.470 --> 00:02:24.270
see if you sudo them and i'll take a look at it

00:02:25.710 --> 00:02:30.170
Okay, there you go. Alright, so now we're gonna view the deployment and we can see

00:02:30.170 --> 00:02:37.710
that we have three of three that are ready. And now we'll view the replica set.

00:02:37.710 --> 00:02:42.030
Alright, notice the unique hash for the replica set that's added to the

00:02:42.030 --> 00:02:46.730
deployment name. And this is how the replica set tracks its replicas in the

00:02:46.730 --> 00:02:53.490
cluster. That's how we differentiate between different replica sets for the same.

00:02:53.490 --> 00:03:00.450
Alright, let's take a look at the events, and notice how we have three unique pods that

00:03:00.450 --> 00:03:03.870
are created with unique hashes.

00:03:03.870 --> 00:03:08.250
So we have the replica set hash, which is the same, then we have a hyphen, and then

00:03:08.250 --> 00:03:12.450
we have three unique hashes for each individual pod.

00:03:12.450 --> 00:03:19.050
And since we only have one replica set, this was easy, but if we needed to describe this

00:03:19.050 --> 00:03:25.450
and we had multiple deployments or replica sets then we would be descriptive. So it would be

00:03:25.450 --> 00:03:30.490
kubectl describe deployment the name and then describe replica set the name. All right now

00:03:30.490 --> 00:03:36.410
let's scale it. So let's scale the deployment. I believe we typed in three where the replica

00:03:36.410 --> 00:03:42.570
is correct. So we're going to scale this now from three to four without changing the yaml.

00:03:42.570 --> 00:03:49.170
So just keep the, go ahead and exit out of the YAML, and we're going to use a kubectl

00:03:49.170 --> 00:03:50.170
command to scale.

00:03:50.170 --> 00:03:56.130
The YAML will still say three, but we're actually going to be changing that in cluster.

00:03:56.130 --> 00:04:01.810
And then once that's successful, let's verify it, describe the deployment.

00:04:01.810 --> 00:04:06.330
Oh, you might have a different name for your deployment when you type up the YAML file.

00:04:06.330 --> 00:04:08.330
What do you have for your name?

00:04:08.330 --> 00:04:11.570
Oh, you have double N. Okay.

00:04:11.570 --> 00:04:15.090
Okay, so let's describe the deployment or whatever you named your deployment.

00:04:16.530 --> 00:04:22.770
Let's see what it says and then we'll describe the replica set and notice that the replica set

00:04:22.770 --> 00:04:27.410
hash remained the same but there is a new pod hash. All right, let's scale it down now from

00:04:27.410 --> 00:04:33.730
four to three and just as you would think still scale deploy just set the replicas back to three.

00:04:33.730 --> 00:04:41.010
Once you do that we'll describe both again and I think for everybody it should show that

00:04:42.530 --> 00:04:47.250
Something weird happened. It should show that it deleted the last pod that it created.

00:04:47.250 --> 00:04:50.450
Is that what everyone shows? Okay, now we're going to delete the deployment

00:04:51.650 --> 00:04:54.770
and the replica set. Once we do that, we'll go ahead and describe them again.

00:04:56.530 --> 00:05:00.930
So yeah, that's the way it should be. We deleted it. So they're both

00:05:01.570 --> 00:05:05.330
gone now. Our replica set was deleted along with our deployment.

00:05:05.330 --> 00:05:09.890
All right, so that shows you just how easy it is to create a deployment and a replica set.

00:05:11.570 --> 00:05:14.170
Now these are manifest files, so we're doing this manually,

00:05:14.170 --> 00:05:19.170
but this will be handled through Helm for our applications,

00:05:19.370 --> 00:05:22.810
whether it's eventually cars or automation

00:05:22.810 --> 00:05:25.250
when you write your Helm files.

00:05:25.250 --> 00:05:27.250
Okay, so now we're gonna do a staple set,

00:05:28.250 --> 00:05:30.650
and you should be able to take the same deployment

00:05:33.770 --> 00:05:36.350
file that you had, you can copy it,

00:05:36.350 --> 00:05:40.010
or you can just create sudo vim nginx-stapleset,

00:05:40.010 --> 00:05:43.690
you'll want the name to be nginx-stapleset.yaml.

00:05:43.690 --> 00:05:45.970
So however it works easier for you,

00:05:47.290 --> 00:05:49.510
you'll just modify it to match this.

00:05:50.910 --> 00:05:52.770
Pay attention to the reference.

00:05:52.770 --> 00:05:55.770
Two ways to do that, you can sudo cp

00:05:55.770 --> 00:06:00.770
the nginx-deployment.yaml to nginx-stapleset.yaml,

00:06:00.850 --> 00:06:02.750
or you can cut and paste it.

00:06:02.750 --> 00:06:07.030
Usually, we can get weird with a few of these,

00:06:08.210 --> 00:06:09.750
but generally speaking, yes,

00:06:09.750 --> 00:06:11.730
It would be a replica set.

00:06:11.850 --> 00:06:15.070
We used to have a replica set controller, and that's been deprecated.

00:06:15.190 --> 00:06:16.630
Now the deployment handles that.

00:07:32.320 --> 00:07:35.260
I'm going to go back to the file, Ralph.

00:07:41.410 --> 00:07:48.630
I mean, this is why I do these exercises, because everybody pretty much has a mistake in there.

00:07:48.870 --> 00:07:50.770
Yeah, and then go up two more lines.

00:07:50.910 --> 00:07:54.130
No, no, that's the entire reason we do this lesson.

00:07:54.630 --> 00:07:55.950
It's what lesson four is about.

00:07:55.970 --> 00:07:57.010
Oh, do you need the apply?

00:07:57.430 --> 00:07:57.790
Sorry.

00:07:58.230 --> 00:07:58.990
Let's go back again.

00:07:58.990 --> 00:08:08.490
Oh, yeah, you'll have to delete the deployment, so kubectl delete-f nginx-staple-set.

00:08:08.490 --> 00:08:13.490
Yeah, so, well, did you call it nginx-staple-set, though?

00:08:13.490 --> 00:08:18.490
Okay, the YAML file should be named nginx-staple-set, though, right?

00:08:18.490 --> 00:08:23.490
Yeah, so do delete for that, because we're going to delete...

00:08:23.490 --> 00:08:25.490
Actually, that probably won't work.

00:08:25.490 --> 00:08:29.450
We should have, um, yeah, it's not going to work.

00:08:29.570 --> 00:08:34.650
Uh, do your, um, kubectl get pods hyphen a.

00:08:34.710 --> 00:08:35.630
Let's just see what's in there.

00:08:35.670 --> 00:08:36.990
Maybe a deployment in there.

00:08:37.010 --> 00:08:38.510
See, I don't see a deployment in there.

00:08:38.510 --> 00:08:38.910
Do you?

00:08:40.510 --> 00:08:40.930
Okay.

00:08:40.990 --> 00:08:41.370
Yep.

00:08:41.450 --> 00:08:41.730
Okay.

00:08:41.730 --> 00:08:42.470
So we should be good.

00:08:42.530 --> 00:08:44.630
So just go ahead and apply that staples.

00:08:45.230 --> 00:08:45.650
Yeah.

00:08:45.710 --> 00:08:49.190
Go ahead and just apply it and get the staple set and describe it.

00:08:50.090 --> 00:08:53.450
And you should see if two pods ending in zero and one.

00:08:53.450 --> 00:08:59.450
We have one more error in there, we should have started with 2 instead of 3.

00:08:59.450 --> 00:09:03.990
You can delete it and then re-apply it.

00:09:03.990 --> 00:09:09.990
kubectl delete hyphen hyphen f and then int net stapleset dot yaml.

00:09:09.990 --> 00:09:16.720
You want a hyphen f in front of the int net stapleset dot yaml.

00:09:16.720 --> 00:09:18.720
Alright, now apply it.

00:09:18.720 --> 00:09:25.060
And you can just in that case just change the word delete to apply, but now it should be correct.

00:09:25.060 --> 00:09:32.420
And now when you check it should be two of two. We should have two pods ending in zero and one.

00:09:49.800 --> 00:10:08.390
Yep and then describe the stateful set. And so how does this differ from the prior NGINX deployment

00:10:08.390 --> 00:10:38.340
replica sets? And then how about the naming convention? So remember when we had a replica

00:10:38.340 --> 00:10:45.700
set we had two hashes on the end of the name and then we had one for the deployment and one for the

00:10:45.700 --> 00:10:52.580
replica set pod and then in this case we don't have any hashes because the hashes change with

00:10:52.580 --> 00:11:06.530
each pod so we have a zero and a one and they always index the zero all right let's list it

00:11:06.530 --> 00:11:17.330
using a pod label it's going to be kubectl command resource i have an l and the label name um

00:11:17.330 --> 00:11:26.870
Um, you know, generally no, however, within a namespace, you can have multiple labels.

00:11:26.870 --> 00:11:31.390
So you could have an application where not every part of it has the same label.

00:11:31.390 --> 00:11:40.110
It allows you to query, um, under a label name as well as tie and select a resource

00:11:40.110 --> 00:11:40.950
to that label.

00:11:41.010 --> 00:11:44.670
I mean, you could apply the same label, I guess, across namespaces.

00:11:44.670 --> 00:11:51.730
I generally don't see that done at the application. Yeah I mean I guess you could

00:11:51.730 --> 00:11:55.430
query let's say you use the same label and multiple namespaces. I haven't

00:11:55.430 --> 00:12:00.130
tried this but I guess you could query it with a hyphen capital A and then that

00:12:00.130 --> 00:12:03.370
would query for that label. So right now we're in default. We're in the default

00:12:03.370 --> 00:12:11.130
namespace so that's why we don't have a namespace listed. So hyphen L we're just

00:12:11.130 --> 00:12:19.290
querying for the label in the default namespace and now if we get the get all of the resources

00:12:19.290 --> 00:12:28.330
for this label we can kubectl get all and then hyphen l equals engine and we can see we have a

00:12:28.330 --> 00:12:35.050
stapleset and two stapleset and so you can see how this might be useful in locating resources if

00:12:35.050 --> 00:12:40.970
you're working in you know automation or cars you can apply a label to everything in that

00:12:41.610 --> 00:12:46.730
application and then you can query for everything related to that label you can't think of any

00:12:46.730 --> 00:12:54.330
downsides or if you forget to add a label to one of your resources then it's not going to show up

00:12:55.290 --> 00:13:01.290
if you rely on listing by positive so it will be missing from your list of resources all right

00:13:01.290 --> 00:13:07.530
Let's scale the state. Let's say you had three resources and put labels on two and forgot to

00:13:07.530 --> 00:13:13.210
add the label to the third when you query for all. It's not going to actually show

00:13:13.210 --> 00:13:17.850
all relating to your application. It's just going to show all relating to that label.

00:13:17.850 --> 00:13:23.610
Let's scale the state set from two pods to one. Let's check the state set for the correct number

00:13:23.610 --> 00:13:29.690
of pods and then we'll check the events and what is the name of the remaining pod. Which pod was

00:13:29.690 --> 00:13:35.210
deleted by the Stapleset. And so it will always count backwards when you're deleting and it will

00:13:35.210 --> 00:13:41.050
always scale upwards from zero. So if you scale it down to one pod, zero will be the one that's

00:13:41.050 --> 00:13:45.770
always left with the Stapleset. Now let's scale the Stapleset from one pod to 10 pods. Do that,

00:13:45.770 --> 00:13:50.890
we'll do the same thing. We'll get the Stapleset, check the events. So we created that before.

00:13:51.610 --> 00:13:56.170
Yeah. So if you scroll up to when you ran this, when there were two, you'll see that it says

00:13:56.170 --> 00:14:02.490
create for that pod but no delete and so we already had it create and so we deleted it so

00:14:02.490 --> 00:14:09.270
then we had a create a create and a delete and now we have a create delete create times two because

00:14:09.270 --> 00:14:16.070
we've created it twice now again yes that's correct all yeah and all of them down to one

00:14:16.070 --> 00:14:27.230
and then back to ten so everything from one on yeah so now let's delete it and even my

00:14:27.230 --> 00:14:31.950
And with staple sets, we need, in order to delete it, we need to scale the replicas to

00:14:31.950 --> 00:14:32.950
zero.

00:14:32.950 --> 00:14:39.610
That's why sometimes Helm charts do not work when you go to remove the Helm chart.

00:14:39.610 --> 00:14:42.650
Helm charts, by default, do not scale to zero.

00:14:42.650 --> 00:14:46.290
So in this case, we're going to scale it down, but if you just try to delete it with the

00:14:46.290 --> 00:14:51.110
Helm chart, sometimes it will delete it, and other times it'll just leave it running.

00:14:51.110 --> 00:14:55.750
So Helm will report back that it was successful, and you'll look and your staple sets will

00:14:55.750 --> 00:15:02.150
still be running. Well, the stateful set would still be there. So the stateful set before it

00:15:02.150 --> 00:15:06.790
deletes, it needs to scale to zero. That's just the way stateful sets work. They're stateful.

00:15:07.590 --> 00:15:15.910
And so that's just one area where Helm can fail on you, is if you are using Helm to install or delete

00:15:15.910 --> 00:15:20.230
a stateful set. It's just something to keep in mind when you work with stateful sets.

00:15:20.230 --> 00:15:26.350
All right, so we scale to zero.

00:15:26.350 --> 00:15:30.790
Let's check the staple set for the correct number of pods, and we'll check the events.

00:15:30.790 --> 00:15:33.670
Yeah, yeah, it counts down.

00:15:33.670 --> 00:15:37.410
And then the staple set remains, even though no pods are running.

00:15:37.410 --> 00:15:44.390
So now we'll delete the staple set, and we can check and try to get the staple set, and

00:15:44.390 --> 00:15:47.530
try to describe the staple set.

00:15:47.530 --> 00:15:50.350
So it's now been deleted.

00:15:50.350 --> 00:15:58.210
So when you run into this with a Helm chart, this is the one area where Helm does not do

00:15:58.210 --> 00:16:01.710
a great job because of the way stateful sets are designed.

00:16:01.710 --> 00:16:10.190
So that's why other upstream CNCF foundation projects are working on different ways to

00:16:10.190 --> 00:16:15.010
deploy similar to a stateful set for databases to avoid.

00:16:15.010 --> 00:16:21.970
is one of many areas where staple sets and the way they're designed can fail. Okay,

00:16:23.890 --> 00:16:29.650
let's see. We're going to deploy a daemon set, so we're going to ensure a fresh minikube cluster,

00:16:30.690 --> 00:16:36.770
and in order to create a daemon set on multiple nodes, we're going to create three nodes. So we're

00:16:36.770 --> 00:16:42.690
just going to minikube start and then nodes equals three, and we'll make sure we have three nodes.

00:16:42.690 --> 00:16:50.690
correct. Anytime you see ensure fresh minicoop cluster that would be stop and then delete all.

00:16:52.290 --> 00:16:57.730
And once it comes up we'll check that the nodes are ready. You should see one control plane and

00:16:57.730 --> 00:17:05.890
two unnamed nodes. And well unnamed so they have no roles associated so the role would be none.

00:17:07.330 --> 00:17:12.450
You'll see this is not an H8 cluster it's a single control plane with two worker nodes.

00:17:12.690 --> 00:17:18.610
So we'll go ahead and get the pods. If we notice anything different. Three kind nets, yep. So that

00:17:18.610 --> 00:17:29.090
is the CNI overlay. It's a very basic CNI that's just for Minikube. Yep, three proxies. So each

00:17:31.090 --> 00:17:35.810
node has a kind net CNI and each node has a proxy. All right, now we're going to create a...

00:17:36.530 --> 00:17:42.610
What's that? Yes, it is a replica set. So it's got a hash. And so core DNS can be deployed on

00:17:42.610 --> 00:17:51.330
different types of nodes so now we're going oh go ahead um yes but in modern uh clusters we

00:17:51.330 --> 00:17:57.970
actually don't use kube proxy because it's slow it's an older way of doing it um so we actually

00:17:57.970 --> 00:18:04.450
do that at the cni level so it would be replaced and would be included in the kinet well of course

00:18:04.450 --> 00:18:14.610
kinet doesn't have that capability but cnis capability so now we're going to deploy a daemon

00:18:14.610 --> 00:18:24.500
set. And so we don't normally run Elasticsearch in a Kubernetes cluster. It's a cloud product.

00:18:25.460 --> 00:18:32.260
It's very resource intensive. So there are Kubernetes products today that use fewer

00:18:32.260 --> 00:18:39.460
resources and do similar work, but it's great for testing a daemon set. Yeah, Elasticsearch is very

00:18:40.660 --> 00:18:45.860
resource hungry in a Kubernetes cluster. And once you have it finished, you can go ahead

00:18:45.860 --> 00:18:51.220
Oops. Sorry about that. There we go. Apply the daemon set. Oh, did it not show back up?

00:18:52.660 --> 00:18:55.140
And when you have it finished, go ahead and apply it. Correct.

00:18:55.780 --> 00:19:01.460
Then we'll check that the daemon set is ready. That's all right. That's what this exercise is

00:19:01.460 --> 00:19:09.220
for. I think this is the last one that you have to type out by hand because we're moving on to

00:19:09.220 --> 00:19:15.140
lesson five after this and I provide all of those. Ryan, let's see, you applied it.

00:19:16.740 --> 00:19:28.100
What's frozen? Yes, so someone needed to change one of the probably values or keys. They do

00:19:28.100 --> 00:19:33.460
sometimes freeze. They freeze on me sometimes. And once I had a student that had control over

00:19:33.460 --> 00:19:37.860
my slide deck somehow, every time they clicked on their own screen, it advanced the slide deck. So

00:19:39.220 --> 00:19:41.240
So you never know with this platform.

00:19:41.360 --> 00:19:42.180
Oh, yeah, okay.

00:19:43.400 --> 00:19:44.320
Yep, no problem.

00:19:45.500 --> 00:19:47.080
All right, so now we'll get the daemon sets.

00:19:48.200 --> 00:19:53.560
And so generally, if you do this, it won't be ready up if we do this fast enough.

00:19:53.840 --> 00:19:55.060
Actually, Ralph will see that.

00:19:56.420 --> 00:19:56.980
How about Ralph?

00:19:57.080 --> 00:19:58.020
How's your, is it ready?

00:19:59.920 --> 00:20:05.260
Okay, so normally, if you do this fast enough, you'll see that it's not quite ready up.

00:20:05.260 --> 00:20:11.020
and the reason why is it has to download an image onto all three nodes so it'll show that

00:20:11.020 --> 00:20:19.360
you know one is complete and the rest are not um well so that's for fluent d but if you look at

00:20:19.360 --> 00:20:24.820
your pods you'll see different ages so you go ahead and check your pods hyphen a you'll see

00:20:24.820 --> 00:20:33.520
different ages for the three fluent d actually yours are pretty close ryan and uh let's see here

00:20:33.520 --> 00:20:40.880
yeah yeah yeah yours are all pretty close so um so we used to be able to demonstrate this but they

00:20:40.880 --> 00:20:47.040
uh must have yeah the network is a little bit faster so you can kind of see the difference

00:20:47.040 --> 00:20:51.600
here all right now we're going to delete the daemon set and we're just we're not going to

00:20:51.600 --> 00:20:57.520
use kubectl delete hyphen f we're just going to kubectl delete daemon set fluent d not correct

00:20:57.520 --> 00:21:01.680
so just with staple sets that's the only one that we have to do that with

00:21:03.520 --> 00:21:11.360
And you don't have to. Sometimes you get lucky and you can delete it. It won't delete it, but again

00:21:12.400 --> 00:21:17.040
oftentimes it will not unless you scale to zero. And then we'll clean up the Minicoop profile.

00:21:17.600 --> 00:21:20.960
So Minicoop stop, Minicoop delete all. All right, let's do a review

00:21:22.160 --> 00:21:27.840
and then we'll take a two minute break. We learned how to use namespaces to separate resources.

00:21:27.840 --> 00:21:33.180
how namespaces can have constraints for memory and CPU. Some of this was done

00:21:33.180 --> 00:21:39.420
yesterday at the end. How namespaces can be labeled. We learned how to destroy a

00:21:39.420 --> 00:21:45.340
namespace in all of the resources and how to list resources using a pod label.

00:21:45.340 --> 00:21:48.780
So if you remember, that's a quick way when you're troubleshooting to just

00:21:48.780 --> 00:21:53.820
delete the namespace. If you're building something and it freezes, delete the

00:21:53.820 --> 00:22:01.960
namespace and let it delete everything. How to list resources using a pod label. How deployments

00:22:01.960 --> 00:22:09.580
create replica sets. Learn how to scale a replica set. How staple sets create unique pods with

00:22:09.580 --> 00:22:17.340
sticky names. How to scale staple sets and how staple sets generally need to be scaled to zero

00:22:17.340 --> 00:22:23.780
before deleting, how daemon sets can be used for cluster-wide applications, so

00:22:23.780 --> 00:22:27.520
with that fluent D it automatically applied it to every node in the cluster,

00:22:27.520 --> 00:22:33.900
and how pods may take a few seconds longer to deploy cluster-wide. All right,

00:22:33.900 --> 00:22:38.340
we'll take a couple minute break and come back in a couple of minutes for

00:22:38.340 --> 00:22:40.880
lesson five.
