5 Running Applications with Pods

 

This chapter covers

  • Understanding how and when to group containers
  • Running an application by creating a Pod object from a YAML file
  • Communicating with an application, viewing its logs, and exploring its environment
  • Adding a sidecar container to extend the pod’s main container
  • Initializing pods by running init containers at pod startup

Let me refresh your memory with a diagram that shows the three types of objects you created in chapter 3 to deploy a minimal application on Kubernetes. Figure 5.1 shows how they relate to each other and what functions they have in the system.

Figure 5.1 Three basic object types comprising a deployed application

You now have a basic understanding of how these objects are exposed via the Kubernetes API. In this and the following chapters, you’ll learn about the specifics of each of them and many others that are typically used to deploy a full application. Let’s start with the Pod object, as it represents the central, most important concept in Kubernetes - a running instance of your application.

Note

5.1 Understanding pods

5.1.1 Understanding the purpose of pods

5.1.2 Organizing containers into pods

5.2 Creating pods from YAML or JSON files

5.2.1 Creating a YAML manifest for a pod

5.2.2 Creating the Pod object from the YAML file

5.2.3 Checking the newly created pod

5.3 Interacting with the application and the pod

5.3.1 Sending requests to the application in the pod

5.3.2 Viewing application logs

5.3.3 Attaching to a running container

5.3.4 Executing commands in running containers

5.3.5 Copying files to and from containers

5.3.6 Debugging pods using ephemeral containers

5.4 Running multiple containers in a pod

5.4.1 Extending the Kiada Node.js application using the Envoy proxy

5.4.2 Adding Envoy proxy to the pod

5.4.3 Interacting with the two-container pod

5.5 Running additional containers at pod startup

5.5.1 Introducing init containers

5.5.2 Adding init containers to a pod

5.5.3 Inspecting init containers

5.5.4 Kubernetes-native sidecar containers

5.6 Deleting pods and other objects

5.6.1 Deleting a pod by name

5.6.2 Deleting objects defined in manifest files

5.6.3 Deleting all pods

5.6.4 Deleting objects using the “all” keyword

5.7 Summary