Kubernetes 101 : Deployment, replicas, matchLabels, labels and Pod names.

Deployments in kubernetes manage replicas which represent one or more copy of the same pod.

In the Yaml configuration of the deployment the matchLabels value tells kubernetes which pods the deployment is managing:

To avoid name conflicts, we don't give a name to pods under the matchLabels section, kubernetes gives a name to pods by adding a series of characters after the name of the container.
The template section is the definition of the pod itself which contains the container definition also.

We can create the deployment above by using:

We can check the deployment using the below command:

And we can also display our "nginx" pods using the below command:


Kubernetes adds random characters to the name of the container "nginx-pods" so that the pods will have unique names.


Leave as a comment: