Introduction to Kubernetes
Kubernetes is an open source container orchestration platform for scheduling and automating the deployment, management and scaling of applications in the system. Kubernetes cluster (Group of containers makes up a cluster) includes a container named as a master node that schedules workloads for the all of the containers or nodes in the cluster.
Kubernetes High Level Components
A Kubernetes cluster consists of one or more nodes managed by Kubernetes. Type of nodes are bare-metal servers, on-premises VMs, or VMs on a cloud provider. Every node contains a container runtime kubelet and kube-proxy.
A Kubernetes cluster also contains many master nodes that run the Kubernetes control plane. The control plane consists of different processes, such as an API server, scheduler controller manager and etc.
KUBERNETES BUILDING BLOCKS
Pod is the smallest unit that can be managed by Kubernetes. Pod is the logical group of one or more containers that share the same IP address and port number. Pod supports co-located processes like an application server and its local cache. Pod represents a logical host.
Label is a key or value pair that is attached to Kubernetes resource, for example, a pod. Labels can be attached to resources at deployment time, as well as added and modified at any later.
Label selector is used to manage Kubernetes resources that have labels. An equality-based selector defines a state for selecting resources that have the specified label value. A set-based selector defines a state for selecting resources that have a label value within the specified set of values.
Controller manages a set of pods and make sure that the cluster is in the specified state. Pod managed by a controller are automatically replaced if they got failed, deleted or terminated. Two types of controller’s are:
- REPLICATION CONTROLLER: Replication controller is responsible for running the specified number of pod replicas across the cluster.
- DEPLOYMENT CONTROLLER: Deployment controller defines a desired state for logical group of pods and replica sets. Deployment controller creates new resources or replaces the existing resources.
Replica set is the next-generation replication controller. Replication controller supports only equality-based selectors but a replica set supports set-based selectors.
Service uses a selector to define a logical group of pods and defines a policy to access the logical groups.
STORAGE BUILDING BLOCKS
Volume is defined at the pod level and is used to save data across container. Container file system is temporary, and if a container crashes, changes to its file system are lost. Volume can be used to share data between containers in a pod.
Persistent volume represents a network storage unit in a cluster. It supports different access modes, such as mounting as RW (Read-Write) by a single node, mounting as RO (Read-Only) by many nodes, and mounting as RW (Read-Write) by many nodes. Kubernetes supports different persistent volume which is implemented as plugins.
Different Components of Kubernetes Architecture
Kubernetes Architecture is divided into two nodes,
- Master Node
- Worker Node
Master and the Worker nodes have many built-in components within them. The master node has the kube-controller-manager, kube-apiserver, kube-scheduler, etc. and Worker node has kubelet and kube-proxy running on each node.
Installation of Kubernetes
- Install the kubectl
- Install the KVM driver.
- Install Minikube.
- Start the Minikube cluster.
- Check that the pod status is up and running.
- Check that the service works.
- Open the Kubernetes Dashboard in your web browser.
- Stop the cluster (shut down the virtual machine and preserve its state).
- Start the cluster again and restore it to the previous state.
- Delete the cluster (delete the virtual machine and its state).
There may be possible cases of failure in Kubernetes clusters due to pods, nodes, and master nodes. Pod failures can be handled by built-in Kubernetes features (crux here is to provide persistent storage if needed). Node failures can be handled by master nodes.
Features of Kubernetes
- Offers automated scheduling
- Self-Healing capabilities
- Automated rollouts & rollback
- Horizontal Scaling & Load Balancing
- Provides a higher density of resource utilization
- Offers enterprise-ready features
- Application-centric management
- Auto-scalable infrastructure
- Provides declarative configuration
- Deploy and update software at scale
- GUI is the Kubernetes Dashboard.
- Highly scalable and scales fast.
- Kubernetes can do auto-scaling.
- Manual load balance traffic between different containers and pods.
- Can be deployed rolling updates and does automatic rollbacks.
- Storage volumes shared only with the other containers in the same pod.
- In-built tools for logging and monitoring.
Advantages of Kubernetes
- Easy organization of service with pods.
- Largest community among container orchestration tools.
- Kubernetes offers a variety of storage options, including on-premises SANs and public clouds.
- Adheres to the principals of immutable infrastructure.
- Open source and modular.
- Runs well on any operating systems.
Disadvantages of Kubernetes
- Migrating to stateless requires substantial efforts.
- Highly complex Installation/configuration process.
- Laborious to install and configure.
- Kubernetes deployment can be extremely complex though Kubernetes as a service (KaaS) platforms.
- Requires separate administration tools.
Kubernetes is an open-source tool that is well supported in market. It allows application development to be completely infrastructure dependent and avoids vendor dependency.