Just Enough Kubernetes: Architecture
TLDR
Kubernetes is a container orchestration tool in which you can use multiple machines/VM’s to create a cluster. When cluster is created, application deployed on it are distributed throughout the nodes and Kubernetes makes sure they are up and available depending on the provided configuration.
Architecture
Node: A physical machine or VM where our applications are run when deployed.
Cluster: A combination of nodes running together. It is best practice to have multiple nodes running at the same time to avoid a failure if any one of the nodes in the cluster stops working.
Master Node: A node selected in the cluster that is responsible for managing the cluster, keeping information about members of the cluster and other information. Monitoring workload and managing workloads during failures.
Worker Node: Physical machines/VM’s in which application pods are deployed.
Pod : A container or a group of container that is running your application.
Kubernetes Components:
-
Kube API server: Acts as a gateway for management in Kubernetes, users, cli tools all access the Kubernetes server via the API server. Every resource in the Kubernetes cluster is represented as a Kubernetes object and the API server provides a gateway for adding/managing and deleting these objects. CLI apps like kubectl or a GUI interface will interact with the API server.
-
etcd: A distributed key value store that stores all data and metadata relating to the cluster. Stores information of multiple nodes and masters in the cluster. Its in charge of maintain a lock so there is no clash in operation between the various master nodes.
-
Scheduler: Takes the task of distributing workloads across various nodes. Any changes done to objects via the API server is performed by the scheduler.
-
Controller: Controllers are basically control loops that monitor the state of the cluster. They make or change request if and when required depending on what the current state of the cluster is and the desired state.
Controller types:
- ReplicaSet : Used to maintain a desired number of replica pods at any given time. If a single pod is created and it fails. The failure is not handled natively by Kubernetes. By creating a replica set we tell kubernetes that N number of replicas for the pod should always be available.
- Deployment: A deployment resource makes it easier to update pods to a new version. When using replica set, when a pod is needed to scale up a new replica set needs to be created and the previous replica set needs to be scaled down. This is handled automatically by a deployment. A deployment is a higher level abstraction and makes it easier to work with deployments.
- StatefulSet : API object used to manage stateful workloads like databases and caches. It is needed for applications that needs to maintain a stable network addresses or uses stable persistent storage.
- DaemonSet: DaemonSet Controller comes in handy from a monitoring or a logging perspective where every node needs to have a single instance of a particular pod running, When new nodes are added to the cluster a daemonset pod is automatically deployed to the cluster.
- Job & CronJob: Used to create short lived that run carry out a given set of tasks and finish execution. Cron jobs are used to create jobs that run on a specific timeframe.
-
Container Runtime: Underlying software actually running the docker or any other type of containers. It is responsible for pulling and running container images.
-
Kubelet: Agent running on each node of the cluster, keeps track of whether all conatiners are up or running on that node.
-
KubeProxy: watches the API server for pods/services changes in order to maintain the network up to date. The kube-proxy process stands in between the network Kubernetes is attached to and the pods that are running on that particular node.