Kubernets: Health-Check & Port-Forwarding

HEALTH-CHECK

One of the features advanced and most important of Kubernetes is the health-check which allows you to control the integrity services.

It is an additional layer that adds to the standard controls that guarantee that the application processes are always running ( livenessProbe ), the application integrity controls ( ReadinessProbe )

The benefits of health-check are:

  • It’s customizable for any container
  • It uses the same application logic (for example, loading a web page or DB pings).
  • The livenessProbe determines if the application is working correctly. if not the application is restarted.
  • The ReadinessProbe describes when the container is ready to satisfy the user’s requests (it means the service is running)

The configuration of the health -check is done by adding the livenessProbe and ReadinessProbe items to the POD configuration yaml file (see figure 1)

Figure 1

PORT-FORWARDING

Port forwarding authorizes the service (configured at the POD level) to communicate both with other PODs and with the outside world. Without Port Forwarding, the service is totally isolated.

The simplest example is a website. As long as port-forwarding is not started, the pages of the site are not available to users.

In our example ( some-mysql ), after POD has started, the command to enable application port-forwarding on port 8000 is:

kubectl port forward some-mysql 8000: 8000

An article is available on the website www.gable.it that explores the networking issue of Container environments. To read it click here.

In a future article, we will talk about load balancers that help networking management.

See you Soon

 

Kubernets: Health-Check & Port-Forwarding

HEALTH-CHECK

One of the advanced and most important features of kubernetes is the health-check which allows you to check the integrity of the services.

It is an additional layer that adds to the standard controls that guarantee that the application processes are always running ( livenessProbe ), the application integrity controls ( ReadinessProbe )

The advantage of the health check is that:

  • It is specific for each container.
  • It uses the same logic as the application (for example, loading a web page, pinging a DB ).
  • The livenessProbe determines if the application is running correctly. Otherwise, the application is restarted.
  • The ReadinessProbe describes when the container is ready to satisfy the requests of the users (and therefore of the service)

The configuration of the health -check is done by adding the livenessProbe and ReadinessProbe items to the POD configuration yaml file (see figure 1)

Figure 1

PORT-FORWARDING

Port forwarding authorizes the service (configured at the POD level) to communicate both with other PODs and with the outside world. Without Port Forwarding, the service is totally isolated.

The simplest example is that of a website. As long as port-forwarding is not started, the pages of the site are not available to users.

In our example ( some-mysql ), after POD has started, the command to enable application port-forwarding on port 8000 is:

kubectl port forward some-mysql 8000: 8000

An article is available on the website www.gable.it that explores the networking issue of Container environments. To read it click here.

In a future article, we will talk about load balancers that help networking management.

Soon

 

Kubernetes: Pods

Nei precedenti articoli, abbiamo visto che i container sono dei luoghi “astratti” dove girano le applicazioni sotto forma di immagini.

I POD sono l’aggregazione di più container.

Un servizio è l’aggragazione di più POD.

L’immagine di figura 1 mostra il concetto appena esposto.

Figura 1

 

Tutte le applicazioni (immagini) presenti all’interno dello stesso POD, avranno lo stesso indirizzo IP (condiviso) e lo stesso Hostname (UTS NameSpace).

La comunicazione tra i container all’interno dello stesso HOST avviene attraverso POSIX o le IPC di System V

Immaginate ora di voler erogare il servizio “the-gable-svc“, costruito con due immagini (container): un Database e un Front-End.

In fase di progetto è meglio disegnare un unico POD che contenga i due contanier (figura 2) oppure due POD con ognuno un container (figura 3)?  (1POD x 2 CONTAINER oppure 2 POD x 1 CONTAINER)

Figura 2

Figura 3

Per rispondere accuratamente è necessario comprendere quale applicazione ha la necessita di maggiore scalabilità e flessibilità.

Nel nostro esempio è il DB che per gestire picchi di accesso, potrebbe richiedere maggiori risorse (RAM & CPU).

Se avessi disegnato un unico POD, l’aumento delle risorse coinvolgerebbe entrambe le applicazioni, andando di fatto a non ottimizzare il dispendio energetico.

Nota 1: Le risorse CPU & RAM sono assegnate durante la creazione del POD.

E’ sempre meglio creare più POD?

Quest’ultima affermazione non è allineata con la politica di resilienza di K8s, dove  i POD dovrebbero girare su host fisici differenti (k8s è un cluster).

Per risolvere la dipartita, esista una buona regola:

Se il servizio funziona correttamente anche se i POD sono distribuiti su più host, allora è meglio utilizzare più POD (figura 2).

La Figura 4 mostra il contenuto del file mysql-pod.yaml che crea il POD per l’applicazione mySQL.

Figura 4

Vediamo la sintassi di base di gestione del POD:

  • Per avviarlo è sufficiente lanciare il comando: kubectl apply -f mysql-pod.yaml
  • Per verificarne lo stato: kubectl get pods
  • Per ottenere tutti i dettagli: kubectl describe pods some-mysql
  • Se volessimo cancellarlo: kubectl delete -f mysql-pod.yaml

Per oggi è tutto a tra poco dove parleremo di Accesso al POD, come copiare files e tanto altro ancora.

A presto

Kubernetes: Pods

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

PODs are the aggregation of multiple containers .

A service is the aggregation of several PODs .

The image in figure 1 shows the concept just explained.

Figure 1

 

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

Communication between containers within the same HOST occurs through POSIX or System V IPCs

Now imagine you want to provide the ” the-gable-svc ” service, built with two images (containers): a Database and a Front-End.

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

Figure 2

Figure 3

To answer accurately, you need to understand which application needs the most scalability and flexibility.

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

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

Note 1: CPU & RAM resources are allocated during POD creation.

Is it always better to create more PODs?

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

To resolve the demise, there is a good rule :

If the service works fine even though the PODs are spread across multiple hosts, then it is better to use multiple PODs (Figure 2).

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

Figure 4

Let’s see the basic POD management syntax:

  • To start it just 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 where we will talk about Access to the POD, how to copy files and much more.

Soon

Parabola Ecologica: Due uomini in Barca

by S. Invernizzi

Sdraiato e semi assopito sul bordo di un cabinato, il dottor S. veleggiava sospinto da una lieve brezza pomeridiana; all’improvviso un rombo di tuono ruppe il ritmico fruscio del vento e dell’acqua, facendo sobbalzare il nostro che scrutò il cielo alla ricerca di un Jet militare a bassa quota.

Un’onda inattesa lo colse impreparato, il tuffo nelle fresche acque suggellò il brusco risveglio; dal pelo dell’acqua riuscì a distinguere un mostro galleggiante che rapidamente si allontanava ruggendo in una nuvola nerastra provocata dai gas di scarico.

Dalla plancia un sogghigno sardonico e una voce tagliente che sembrava provenire dalle profondità degli inferi: “Eh, eh,eh ti sei scordato dell’inquinamento acustico?”

Una bella scarica di decibel ripetuta nel tempo è il viatico ideale per una sordità percettiva; ma anche i rumori costanti del traffico cittadino (i motorini sono al top) possono provocare disturbi più subdoli sull’attenzione, sul sonno, sul carattere, talora vertigini, extrasistole e ipertensione arteriosa”.

Risalendo attonito sulla barca, il dottor S. riconobbe il perfido individuo compagno di precedenti dialoghi.

Il diavolo riattaccò “Gas di scarico … Nimbus lo aveva profetizzato dieci anni fa!”. “Chi è Nimbus?”. “E’ un satellite lanciato dalla Nasa adibito a selezionare le informazioni sulla biosfera, come il buco dell’ozono e l’effetto serra.

Il riscaldamento del pianeta, causato dall’anidride carbonica e altri gas che l’uomo produce bruciando petrolio, carbone, foreste, porterà effetti catastrofici nell’arco di trenta anni (desertificazioni, innalzamento degli oceani, cambiamenti climatici).

Per ricucire il buco dell’ozono, tu che fai?”. Il dottor S. si fece subito coinvolgere “Ho cambiato la marca della schiuma da barba!”. “Un po’ banale … Bisogna intervenire sul ciclo del carbonio, cambiare il modello industriale, non basta mettere un tappo ecologico alle industrie più inquinanti; qualunque combustione produce CO2: schiacciando l’acceleratore dell’utilitaria, andando a Ischia sul motoscafo o sul traghetto, salendo su un aereo, accendendo la televisione o la luce in casa.

Dimezzare la produzione di questi gas-effetto-serra significa una modifica radicale dei sistemi produttivi della società del ‘benessere’; l’alternativa è la distruzione di molti ecosistemi che non sarebbero in grado di modificarsi abbastanza in fretta. La tecnologia e l’evoluzione non hanno lo stesso passo, sono come la lepre e la tartaruga! Insomma bisogna rinsavire subito, anche se gli effetti benefici si avvertiranno con molto ritardo”.

Diabolicamente concettoso” ribatte il dottor S.
“Preferisci qualche dato numerico? Eccoteli. In Italia sono in circolazione 26 milioni (dato 1986) di autovetture e ogni anno aumentano di un milione, pur tenendo conto di quelle in rottamazione.

Ciò vuol dire che le nostre auto messe in fila formano una colonna di 100.000 chilometri e raggruppate coprono una superficie di 160 milioni di metri quadrati ovvero 16.000 ettari, corrispondente a un grande parco automobilistico, vero e proprio totem tecnologico di lamiera e plastica.

Tutto ciò ha altissimi costi di acquisto e di gestione: 210 mila miliardi (in vecchie lire)per l’acquisto a cui vanno aggiunti 100 mila miliardi l’anno per garantirsi la mobilità individuale. Alla faccia del risparmio e della lotta all’inquinamento!”.

Un senso improvviso di arsura colse alla gola il dottor S. che allungò una mano verso la bottiglia d’acqua nel tentativo di tracannarne un sorso.
“Vedo che bevi acqua minerale …”.

Stop! Me ne hai già parlato un’altra volta …. Quello che gli ecologi chiamano, onorandoti, un ciclo infernale.

Piuttosto gradisci una tartina al salmone o un agone affumicato?”.”Proteine nobili per una sparuta schiera di fortunati che si alimentano più del necessario … Se oggi i paesi super alimentati, toccati dall’utopia della fratellanza umana, decidessero di ripartire equamente il cibo tra tutti i 5 miliardi di abitanti della terra (rif 1989), sai quale sarebbe il risultato?”.

“Un enorme convitto self-service” esclamò ironicamente il dottor. S.

“No, piomberemmo tutti in condizioni di sottoalimentazione”; al banchetto della vita non c’è da mangiare a sufficienza per tutti.

Bisognerebbe cambiare radicalmente le abitudini alimentari, mangiare più vegetali e meno animali, perché salendo la catena alimentare, dall’erba alla proteina della carne, si attua una perdita impressionante di energia.

Secondo alcuni ecologi mille tonnellate d’erba servono per nutrire 27 milioni di cavallette che a loro volta sono sufficienti a soddisfare l’appetito di 90.000 rane;

Questa schiera di anfibi consente a 300 salmoni di diventare adulti; le proteine di 300 salmoni possono alimentare per un anno un solo uomo! Se venisse confezionato un pranzo con le rane gli invitati al desco sarebbero già qualche decina; ancor più, come i cuochi arabi, se preparassimo spiedini di cavallette si potrebbe allestire una vera e propria mensa popolare!”.

“E che bisogno c’è?” rispose il dottor S. che cominciava a accusare un peso allo stomaco, scambiato nobilmente per rimorso.
“In questa ora di dialogo la popolazione mondiale è aumentata di ottomila individui”.
“Allora saremo davvero dieci miliardi nel 2050!”.

“Esatto!”. “Ed io che c’entro?” gridò sbigottito il laureato.
“Al liceo non hai forse letto qualche scritto di Bergson?”. “Bergson?”. “Si, Bergson, ha scritto che gli errori di Venere spesso li rimedia Marte”.

Ecological Parable: Two Men in a Boat

by S. Invernizzi

Lying and half asleep on the edge of a cabin cruiser, Dr. S. sailed under a light afternoon breeze; suddenly a roar of thunder broke the rhythmic rustle of the wind and water, causing our man to jump as he scanned the sky in search of a low- flying military jet.

An unexpected wave caught him unprepared, the dip in the cool waters sealed the rude awakening ; from the surface of the water he could make out a floating monster swiftly roaring away in a black cloud caused by the exhaust gases.

From the bridge a sardonic grin and a sharp voice that seemed to come from the depths of the underworld: “Eh, eh, eh have you forgotten about the noise pollution ?”

A beautiful discharge of decibels repeated over time is the ideal viaticum for perceptive deafness; but also the constant noises of city traffic (the mopeds are at the top) can cause more subtle disturbances on attention, sleep, character, sometimes dizziness, extrasystole, and arterial hypertension ”.

Going back on the boat, astonished, Dr. S. recognized the perfidious individual companion of previous dialogues.

The devil hung up “Exhaust gas … Nimbus prophesied it ten years ago!” “Who is Nimbus?”. “It is a satellite launched by NASA used to select information on the biosphere , such as the ozone hole and the greenhouse effect.

Global warming, caused by carbon dioxide and other gases that man produces by burning oil , coal, forests, will bring catastrophic effects over thirty years ( desertification, rising oceans, climate change ).

To mend the ozone hole, what are you doing? “. Doctor S. immediately got involved “I changed the brand of the shaving lock !”. “A bit mundane … We need to intervene in the carbon cycle, change the industrial model, it is not enough to put an ecological cap on the most polluting industries; any combustion produces CO2: pressing the accelerator of the small car, going to Ischia on the motorboat or on the ferry, getting on a plane, turning on the television or the light in the house.

Halving the production of these greenhouse gases means a radical modification of the production systems of the ‘ well-being ‘ society; the alternative is the destruction of many ecosystems that would not be able to change quickly enough. Technology and evolution do not have the same pace , they are like the hare and the tortoise! In short, we need to come to our senses immediately, even if the beneficial effects will be felt very late ”.

Diabolically conceptual” retorts Dr. S.
“Do you prefer some numerical data? Here you are. In Italy, there are 26 million (1986 figure) cars in circulation and each year they increase by one million , even taking into account those in scrapping.

This means that our cars lined up form a column of 100,000 kilometers and grouped together cover an area of 160 million square meters or 16,000 hectares, corresponding to a large car park, a veritable technological totem made of sheet metal and plastic.

All this has very high purchase and management costs: 210 thousand billion (the old lire ) for the purchase to which 100 thousand billion a year must be added to guarantee individual mobility. In the face of savings and the fight against pollution ! “.

A sudden sense of heat seized Dr. S. in the throat, who reached out to the bottle of water in an attempt to gulp down a sip.
“I see you drink mineral water …”.

Stop! You already told me about it another time …. What ecologists call, honoring you , a hellish cycle.

Would you rather like a salmon tart or a smoked agone ? “.” Noble proteins for a small group of lucky people who eat more than necessary … If today the over-fed countries, touched by the utopia of human brotherhood, decided to share food equally among all 5 billion inhabitants of the earth (ref 1989 ), do you know what the result would be? “.

“A huge self-service boarding school,” the doctor exclaimed ironically. S.

“No, we would all fall into undernourishment conditions “; at the banquet of life, there is not enough to eat for everyone.

Eating habits should be radically changed, eating more vegetables and fewer animals, because going up the food chain, from grass to meat protein, there is an impressive loss of energy.

According to some ecologists, one thousand tons of grass are used to feed 27 million grasshoppers which in turn are sufficient to satisfy the appetite of 90,000 frogs ;

This array of amphibians allows a 300 salmon to become adults; 300 salmon proteins can feed for one year one man! If a lunch with the frogs the guests at the table would be already a few dozen ; even more, like i Arab cooks , if we prepared grasshopper skewers we could set up a real one cafeteria popular!”.

“And what need is there?” replied Doctor S. who was beginning to feel a burden in his stomach, nobly mistaken for remorse .
“In this hour of dialogue, the world population has increased by eight thousand individuals”.
“Then we will really be ten billion in 2050 !”.

“Exactly!”. “ And what do I have to do with it? The graduate shouted in amazement.
“Didn’t you read some of Bergson’s writings in high school?” “Bergson?” “Yes, Bergson, wrote that the errors of Venus often remedy them, Mars”.