Pages

Tuesday, August 7, 2018

Kubernetes - Basics

K8 is an open source container management and orchestration tool based on go Language. This is lightweight and portable application.

Declarative vs imperative configuration
Many systems that are build now are based on declarative configuration. This is one of the main thing behind k8. What does this mean?

A declarative configuration defines how a system should be and the system will take care of that. If the user says “i want to have five replicas of my web container running all times”. The system in turn will not understand these hence we define them in a Json or a Yml format. K8 will then read this statement and will make sure to have five replicas of the web container running all the time. This also means that if 1 of the 5 is down, k8 will take care of starting that up again and makes sure that 5 are running all the time. This means the system will do the self-correcting and healing also.

In the Imperative configuration , the user will perform the actions which means starting the five replicas of the web container. These are plan “run as” statements.

Controllers - Controllers are another important back bone of k8. K8 is not based on central system in turn is works as decentralized. This means components in k8 work independently. Controllers or Reconciliation loops does the job for us. K8 is based on large number of controller each performing its own job. A Controller can be taught as a control loop that watches the state and make sure it is always in desired state. If not change it to desired state. Each controller will have its own job and is unaware of the other controllers and their role.Some of these controllers include replication ,endpoint, namespace etc etc.

All these controllers will be managed by kubernetes controller manager which  is a daemon that manages all these controllers.

Labeling - Labeling is another important back-bone of the K8 cluster. Take the above case as defining  “i want to have five replicas of my web container running all times” , now how does k8 make sure that 5 replicas are running. How can it identify that one of the web replica is down. These identifications are done by using the Labels. Each component will be identified with the label that is assigned to that. K8 follows the labeling model in a different way. Rather than saying “these are part of my label group” it says “label group can container these”.

In the second case ,we can add any number of components and still assign them to a group making the label dynamic with multiple components. These labels are defined in a key:value pair and are queried using the label queries or selectors.

Along with labels we have annotations. Label are defined to identify the component and annotations are defined with general metadata that cannot be queries. The meta data can be some time like an icon to display etc.

No comments :

Post a Comment