- [Instructor] A daemon set ensures that all nodes run
a copy of a specific pod.
As nodes are added to the cluster,
pods are added to them as well.
Example of a daemon set would be running your logging
or monitoring agent on all of your nodes.
In this example, I'm going to use a simple busy box
container and deploy it as a daemon set.
This is my yaml for the daemon set.
As you can see, it's a kind of daemon set,
with a spec of example daemon set specifically
it's an image busybox.
Let's go ahead and deploy this.
We deploy this by the kube ctl create minus f
daemon set . yaml command.
Pretty similar to how we've done other deployments before.
To fetch them, we can do a kube ctl get daemon sets.
We notice that we have the example daemon set
up and running and it's desired, current, ready,
up to date, and available.
You'll also notice this node selector
which I'll get into in a second.
If we look at our pods,
you'll notice that we have a pod running.
Great!
The daemon set is working as expected.
This is not something new that we haven't seen before.
Let's see how we can get daemon sets to work on
specific pods.
Let's go into our editor vi daemon set,
and let's pull up infrastructure development.
In this file, we'll notice that we have another daemon set
we just called it example two,
and we add a specific label to this,
called a node selector.
And we add label infra of development.
Back on mini kube, I do a kube ctl,
get nodes,
and I show labels.
I'll notice that mini kube has some labels.
One of these labels that I've added is infra of development.
So if I deploy this daemon set,
clear my screen,
kube ctl create minus f,
daemon set infra development.
It will create the daemon set.
Let's explore.
Kube ctl get daemon sets.
You'll notice that in daemon set two, we have a node
selector with label name infra and value development.
We also had a ndoe for minikube with the label name
infra and value of development.
Which is why we notice that the daemon set is
actually up and running.
So let's take alook at our prod dameon set.
Vi daemon set,
infra,
prod.
You'll notice that this matches prod daemon set,
that's what we've called it.
And under node selectors, we have the label with a key infra
with a value of production.
So let's deploy this.
Kube ctl create minus f,
daemon set infra prod.
Well, our daemon set was created.
But let's take a look if it's actually up and running.
Kube ctl get daemon sets,
and we notice that we have the example daemon set,
example daemon set two,
where we have infra equals development.
And we have the prod daemon set where we have
desired, current, ready, up to date and available
with all zeros.
Because we do not have any infrastructure nodes
of type production.
All the nodes that we have right now are all development.
And we know this because if we do a kube ctl,
get nodes,
show labels,
we have a single node called mini kube
with labels and we have a label of infra,
however there's no values other than development.
Next up, I want to take a look at stateful sets.
I have a vi,
stateful set.
And we're going to do a quick example with zookeeper.
Stateful sets manage the deployment and scaling
for a set of pods, and provide guarantees about
the ordering and the uniqueness of these pods.
But unlike a deployment, a stateful set manages
the sticky identity for each of these pods.
So let's take a look in this example.
So we have a service of zk, I'm going to use zookeeper,
for this example.
And we have an API, and it's of a kind stateful set.
In this case we have afinity associated with it.
And finally we have the container,
it's a Kubernetes zookeeper.
And we have the command that it runs,
which is a little bit hairy,
but the idea of this is to understand how this runs.
If you're not already familiar, zookeeper is just a
simple key value store that's commonly used.
It's Apache zookeper if you want to take a look.
Alright.
So we have the stateful set and I'm going to deploy this
by doing kube ctl create minus f.
And I hae my service and my stateful set created.
To take a look at the stateful set up and running,
kube ctl get.
And we see that we have the stateful set,
called zk,
with a specific age.
Let's make sure that the pods for this are also online.
We have the daemon sets pods running,
but we're going to ignore those and we also have the zk
zero pod that's up and running as well for the last
32 seconds.
So this is a simple example of a stateful set.
Typically you would end up having multiples of these
running on different nodes.
But we're just showing a simple example of single
stateful set running on mini kube.