Learn about Pod in Kubernetes

As I said in the tutorial about Overview of Kubernetes components, Pod is a concept, where containers will run in Kubernetes. A Pod may contain one or more containers with the same context, the same node, shared network namespace and volume. When a Pod is dead or in trouble, Kubernetes will automatically create a new one using Controller Manager.

We have 2 ways to create a new Pod in Kubernetes that is running the container directly from the Image using the “run” command or defining the Pod’s information using a YAML configuration file and then using the “create” command” or the “apply” command to run. You can define the information of a Pod using the file with the following basic content:


  • <name> is the name of Pod
  • <container_name> which is the name of the container in Pod after initializing
  • <container_image> is the name of the Image used to create the container.

As you can see, we can define one or more containers running in the same Pod by adding multiple sections for container names and container images in this YAML file.

My example is as follows:

Result when using create command to create this Pod is as follows:

Learn about Pod in Kubernetes

You can get all Pods information using:

command as follows:

Learn about Pod in Kubernetes

View the information of the newly created Pod using:


Learn about Pod in Kubernetes

As you can see, the 2 containers named node-hello and nginx were created in Pod “huongdanjava”. Based on this information, we also know which node our Pod is running.

You can also use the command:

to see the log stdout of a container if that container is having. The two containers I just created, just nginx has logs, so when I execute this command, the result is as follows:

To delete a Pod, you can use the following command:

My example is as follows:


Add Comment