- [Instructor] in this section make sure that you
are looking at the exercise file for this specific movie.
If I do an ls minus al, you'll notice
that there are three files with this section,
the Readme, the helloworld-pod-with-labels.yml,
and a sample-infrastructure-with-labels.yml.
We're going to use both of these files as sample data
that we want to create deployments and services with,
which are already going to have labels associated with them.
So for the first section, let's actually look
at the helloworld-pod with yml.
I'm going to vi helloworld-pod-with-labels.yml.
This is a simple pod which has some labels
called env production, author karthequian,
application type ui, and a release version of 1.0.
So I'm going to run this, kubectl create minus f
and let's make sure that the pod is online.
Alright, sounds good.
We have a helloworld pod, ready status,
which is in the status of running
and it's been online for seven seconds.
So we've seen this before, but how do we actually
look at the labels associated with that.
In order to do that, we would run kubectl get pods,
just like before, and then we'd add the show labels tag.
As you can see, there's a new section called labels
which have the application type ui, author,
environment, and release version.
Just as we had seen in our actual file.
This is how we would add labels at deployment time.
You can also add labels to the running pod
because in some scenarios you might want
to tag a pod after it's been deployed.
This is how we would do that.
Kubectl, we'd use the label construct,
and our pod was called helloworld.
We're going to relabel the app as helloworldapp,
instead of just helloworld, like it was.
In order to change this, we can do an overwrite.
So let's take a look again.
Kubectl, get pods, minus minus, show labels.
So we rewrote this and there we see
the real value of the new label.
What happens in the scenarios
where we want to delete a label?
In order to do that we can actually
rerun a kubectl label, we want to relabel this pod,
pod slash helloworld, and we want
to actually delete this label
because we don't really want it anymore.
So you do an app, because that's the label name,
and if I add a minus, we get a result
saying pod helloworld was labeled.
So let's take a look at this again.
Kubectl, get pods.
You'll notice from before we had apphelloworld
and we do not have that anymore.
So that's how you actually end up
deleting a label or overwriting it.