Kubernetes - before you start
I've been looking for an accessible summary of what Kubernetes is, but so far I've only been able to find explanations of what Kubernetes does, or many even jump directly into how to use it to profit. In this article, I'll take a step back and focus on the basics, explain the core design, and finish with some higher level implications and further reading.
Kubernetes was born from Google's experience of running a humongous fleet of containerized applications, and having to keep them running on a humungous estate of generic hardware. It implements the patterns that they have discovered over many years, using a clean and extensible architecture, and is a good match to the problem of running sprawling microservices on a humongous estate of generic cloud resources. This is a common problem today, but not necessarily a good one to have.
The Cluster is a database
An installation of Kubernetes is called "a cluster". At the core of the cluster sits a document database (etcd). For those of you thinking about MySQL and Oracle, it is nothing like that - the Kubernetes database is good for very few things:
Each document stored in the Kubernetes database needs to have a "kind" specified, and depending on its kind we expect certain structure of the actual data in the document (some of us would call it a "schema").
The API server controls the updates to the database
Doing anything in Kubernetes means creating, updating and deleting documents in the Kubernetes database. This is done through a web service called the API Server - normally we use a tool such as kubectl or Helm to access the API server, but in a pinch it is not too difficult to do with curl either. In the end all we are doing is creating, updating and deleting text documents.
So far so good - we have a database and we can keep data in it, but how does that help us orchestrate software?
Controllers do things
The meat of Kubernetes lies in its controllers - small processes that monitor the database, and when a document of a specific "kind" is updated, they do something fancy.
A good example of a controller would be the Pods controller - it guarantees for every document in the database that has specified 'kind: Pod', it will run a container in a way specified in that document. It will also watch over the containers it started, and update the database with the actual state it observes. For example:
There are a few other controllers that control networks, storage and other physical resources. These form the core of Kubernetes.
Controllers controlling controllers
Being able to provision applications and resources by updating database state makes it easier to implement higher-level functionalities. For example, if you need load-balanced set of services, you can create a document with kind: ReplicaSet, describing how you want the load-balancing and scaling to work.
The ReplicaSet controller will not have to know how to run containers or monitor them - it will instead reach out to the database and create documents of 'kind: Pod' and monitor and respond to changes in the pod state.
领英推荐
In essence, what used to be a heavy system programming task has been reduced to arranging JSON documents in a database.
We can have one controller respond to multiple "kinds", or one "kind" handled by multiple controllers - this is uncommon, as it makes it difficult to reason about the system.
Operators
Often we would find ourselves automating the same sequence of state manipulations repeatedly (i.e. rolling update of container versions would require the update of many ReplicaSets or Pods).
Once we have discovered a good recipe that works well, we can make it part of Kubernetes, by adding a new "kind" describing the recipe parameters, and then creating a process that monitors the Kubernetes database, and performs the lower level database updates for us. For the rolling update scenario, this has actually happened - the corresponding kind is called Deployment.
The advantage of having the compound operation described as a new kind, and managed by controller process is that it becomes easily observable and reusable (i.e. more abstractions can be built on it). It also improves the performance and reduces the chance of scripts failing half-way through because we lost network connectivity.
The combination of new "kind" definition and the process reacting to that kind is called "operator" pattern. Most of Kubernetes is written in operators, because they are easy to reason about.
So, what did we learn?
By starting with a description of our desired state in a database (some may also call it "whiteboard"), and having detached controllers react on it and further update the database or the external world, we achieved a number of nice characteristics:
Of course it is not all roses, for all the good things, we also get:
With all that said
Kubernetes is impressive! While it is still very young compared to established cluster schedulers, with Google's resources and wide indistry backing, it has achieved high degree of usability and functionality. Being widely adopted also means that it is getting easier to hire people with experience, and that its design choices are becoming canonical (similar to Linux kernel).
The biggest risk for Kubernets is the complexity and immaturity of tooling. Many vendors are trying to provide simpler experience by preconfiguring, and complementing with custom services, but eventually someone will find a way to provide 90% of the functionality that everyone needs, with 10% of the complexity and this is going to be a game changer. Not everything is destined to scale dramatically and unexpectedly.
Now you know - this is what Kubernetes is. If you are still interested in doing things with it, go ahead and read some of the other tutorials. Kubernetes The Hard Way is my favorite.
SMBC Nikko Securities Inc. - プロジェクトマネージャー
8 个月this is the text which i have been looking for to unserstand the complex text about it. thanks!
thanks Dimitar - even I understand it ??
MS MIS'25@University at Buffalo | Ex-Lead DevOps Engineer@Accenture | Actively seeking full-time opportunities in DevOps and Cloud Engineering.
8 个月The more you read about and understand the magic under the hood, the more impressive it gets!
Director, UBS | Ex-JPMC, Ex-BofA, Ex-Nomura | People Leadership | Engineering Manager | Capital Markets | Investment Banking | Equity and Fixed Income Derivatives | Adv. Diploma in Business Finance
8 个月Very good introduction Dimitar. Thanks ????