14 September 2021 By gabriele pelizzari

Kubernetes: Pods

In previous articles, we have seen that containers are ” abstractplaces where applications run in the form of images.

The PODs are the aggregation of more containers.

A service it is the aggregation of more POD .

The image of Figure 1 shows the concept just outlined.

Figure 1

 

All the applications (images) present to the same POD, will have the same address IP (shared) and the same Hostname (UTS NameSpace).

There communication between the containers inside it HOST takes place through POSIX or le System V IPC

Now imagine you want to provide the service “ the-gable-svc “, built with two images (container): a Database it’s a Front-End.

In the design phase is it better to draw a single POD that contains the two containers ( Figure 2) or two POD with a container each ( figure 3 )? ( 1POD x 2 CONTAINER or 2 POD x 1 CONTAINER )

Figure 2

Figure 3

For answering carefully it is necessary to understand which application has the greatest need for scalability and flexibility.

In our example it is the DB that has to manage access peaks, that may require more resources (RAM & CPU).

If I had designed a single POD, the increase in resources would involve both applications, effectively not optimizing energy expenditure.

Note 1: Resources CPU & RAM are assigned during the creation of the POD.

It gets better and better create more POD?

This latter statement is not aligned with the policy of resilience of K8s, where the PODs should run on different physical hosts ( k8s is a cluster).

To resolve the demise, there is a good one rule:

If the service works correctly even if the PODsare distributed on multiple hosts then it is better to use multiple POD (figure 2).

Figure 4 shows the contents of the file mysql-pod.yaml which creates the POD for the application MySQL.

Figure 4

Let’s see the basic syntax of PODmanaging :

  • To start it, simply run the command: kubectl apply -f mysql-pod.yaml
  • To check its status: kubectl get pods
  • To get all the details: kubectl describe pods some-mysql
  • If we wanted to delete it: kubectl delete -f mysql-pod.yaml

For today it’s all, in a little bit we are going to talk about Access to the POD, how to copy files, and much more.

Soon