Asking questions is one of the best ways to understand a new topic. It is like you are preparing tiny rooms in your brain to fill with new information.
Here are some questions I asked myself while studying Kubernetes. The responses are brief, not enough to understand Kubernetes, but useful to test yourself and recall the concepts.
What is Kubernetes?
K8s is an Open Source container orchestrator for deploying containerized applications.
What are the functionalities of a container orchestrator?
- Deploying services that span multiple containers
- Scheduling containers across a cluster
- Scaling the containers
- Managing containers' health over time
Who created it?
Google created K8s in 2014 and later donated it to the Cloud Native Computing Foundation (CNCF).
What are the advantages of using Kubernetes?
Velocity, scaling applications, scaling Dev Team, abstraction and efficiency:
K8s allows you to ship more updates than a traditional deployment - which uses ad hoc scripts - while maintaining a highly available service.
It allows you to scale an application service by just changing a number in a configuration file.
Scaling Dev Teams is simpler. With service-oriented teams, each team can work on a single Microservice.
The K8s abstraction is not infrastructure-oriented but application-oriented based. That is why transferring your application between clusters will be painless. There are many K8s plug-ins that support the cloud platforms (AWS, GCP, Azure, …).
K8s exploits its resources efficiently. It automates the distribution of applications across a cluster of machines, ensuring a high utilization level.
What are the two main parts of a Kubernetes cluster?
- A set of machines called worker nodes. They run containerized applications.
- The control plane (master). It manages the worker nodes and the Pods (hosted inside the nodes).
What are the main parts of the control plane?
- kube-apiserver: it allows you to communicate with the cluster. It exposes a restful HTTP interface. Every time you query the cluster with kubectl, underneath, you are making an API call to the kube-apiserver.
- etcd: It is a key-value store, contains the records of intent, and is the only stateful component in the control plane.
scheduler: its job is to find the best nodes to run the workloads.
For example, let's say you want to deploy a Web app, and you want three running instances: the scheduler will find the nodes with the right resources to run the three web servers.background control loops: it continuously checks that the status of the cluster is the same as the one stated in the records of intent.
How can you interact with the Kubernetes Cluster?
There are three ways:
- by the command line client
kubectl
- by direct access to the REST API with an HTTP client
- by programmatic access to the API (Golang, Python, Java, ...)
What is kubectl?
It is the command-line interface, which allows you to query or tweak the cluster. It talks with the cluster via API calls to kube-apiserver.
To update the cluster, you should create the manifest files and apply them with the command:
kubectl apply -f my_manifest.yaml
What is a manifest file?
A file manifest is a YAML file containing the description of the objects passed in the K8s API. K8s relies on declarative configuration, and the manifest files describe the desired state.
Can you create a Pod object without using a manifest?
Yes, you can create a Pod, or other objects, via the imperative kubectl run command. But, the preferred way is to use a manifest since you can treat it as source code.
What is an object in Kubernetes?
A Kubernetes object is a record of intent. Once you create the object, the K8s controllers will constantly monitor it to ensure its requirements are met.
Some examples of objects are Pods, ReplicaSet and Deployments.
Can you run a Kubernetes cluster on your laptop?
Yes, by using a platform called Minikube.
What is Minikube?
Minikube is a lightweight Kubernetes implementation that creates a virtual machine on your laptop and deploys a simple cluster.
Minikube has a limitation: its cluster has only one node.
In which platform can you deploy a K8s cluster?
- on your local machine by using Minikube
- on bare metal servers
- on many cloud platforms
What is a Pod?
- A Pod is a set of containers running in the same execution environment.
- As a best practice, a Pod should only have (run) a container.
- A Pod is the smallest unit of a Kubernetes application.
Which resources do application containers share within a single Pod?
- IP address
- port space (network namespace)
- hostname
- interprocess communication channels
Does the Pods persist data in the filesystem?
No, Pods are stateless. When you restart a Pod, all data in the container's filesystem is deleted.
How can you persist data in a Pod?
Pods can persist data by using Volumes.
Resources
Here is a book and two courses I used to learn Kubernetes:
- Book: Up and Running: Dive Into the Future of Infrastructure
- Course on udemy: Kubernetes 101 - by Nigel Poulton
- Course on Manning: Kubernetes Microservices - by Richard Chesterwood
- Kubernetes Tutorial for Beginner (by Nana)
And, last but not least, the official documentation
This article is a WIP and as soon as I practice more with K8s and grasp more knowledge I will expand it with more questions.
Please, feel free to suggest more questions or report any errors.
Updated on 1th Feb 2023