Kubernetes Overview for MariaDB Users
Kubernetes, or K8s, is a software to orchestrate containers. It is released under the terms of an open source license, Apache License 2.0.
Kubernetes was originally developed by Google. Currently it is maintained by the Cloud Native Computing Foundation (CNCF), with the status of Graduated Project.
Contents
Architecture
Kubernetes runs in a cluster. A Kubernetes cluster consists of the following components:
- Nodes run containers with the servers needed by out applications.
- Controllersconstantly check the cluster nodes current state, and compares it with the desired state.
- A Control Plane is a set of different components that store the cluster desired state and take decisions about the nodes. The Control Plane provides an API that is used by the controllers.
Nodes
A node is a system that is responsible to run one or more pods. A pod is a set of containers that run Kubernetes workload or part of it. All containers that run in the same pod are also located on the same node. Usually identical pods run on different nodes for fault tolerance.
For more details, see Nodes in the Kubernetes documentation.
Every node must necessarily have the following components:
- kubelet
- kube-proxy
- A container runtime
kubelet
kubelet has a set of PodSpecs, which describe the desired state of pods. It checks that the current state of the pods matches the desired state. It especially takes care that containers don't crash.
kube-proxy
In a typical Kubernetes cluster, several containers located in different pods need to connect to other containers, located in the same pods (for performance and fault tolerance reasons). Therefore, when we develop and deploy an application, we can't know in advance the IPs of the containers it will have to connect. For example, an application server may need to connect to MariaDB, but MariaDB IP will be different for every pod.
The main purpose of kube-proxy is to implement the concept of Kubernetes services. When an application needs to connect to MariaDB, it will connect to the MariaDB service. kube-proxy will receive the request and will redirect it to a running MariaDB container in the same pod.
Container Runtime
Kubernetes manages the containers in a pod via a container runtime, or container manager, that supports Kubernetes Container Runtime Interface (CRI). Container runtimes that meet this requisite are listed in the Container runtimes page in Kubernetes documentation. More information about the Container Runtime Interface can be found on GitHub.
Originally, Kubernetes used Docker as a container runtime. This was later deprecated, but Docker images can still be used using any container runtime.
Controllers
Controllers constantly check if there are differences between the pods current state and their desired state. When differences are found, controllers try to fix them. Each node type controls one or more resource types. Several types of controllers are needed to run a cluster.
Most of the actions taken by the controllers user the API server in the Control Plane. However, this is not necessarily true for custom controllers. Also, some actions cannot be performed via the Control Plane. For example, if some nodes crashed, adding new nodes involves taking actions outside of the Kubernetes cluster, and controllers will have to do this themselves.
Control Planes
Ansible Resources and References
- Kubernetes website
- Kubernetes on Wikipedia
- Kubernetes organization on GitHub
- Forum
- (video) MariaDB database clusters on Kubernetes, by Pengfei Ma, at MariaDB Server Fest 2020
Content initially contributed by Vettabase Ltd.