Kubernetes 101: Beginners Guide to Kubernetes

redswitches-blog

Introduction

Kubernetes is a powerful, open-source container-orchestration system. It is used for scaling, automating application deployment, and management. It was originally developed by Google Inc. but is now maintained by the Cloud Native Computing Foundation (CNCF). It was designed for maintaining containerized applications in a clustered system. It aims to implement better ways of managing and distributing components and services across the diverse infrastructure.

In this blog post, we’ll discuss some basic Kubernetes’ concepts, with an attempt to give a high-level overview of the essential components and how they fit together.

What is Kubernetes?

The word Kubernetes arises from Greek; it means helmsman or a pilot. In 2014, Google Inc. open-sourced the Kubernetes project. This project was developed upon a decade of experience that Google brings with running production workloads on a large scale. Along with a combination of the best-of-breed ideas and practices from the Google community.

Kubernetes is an open-source portable and extensible platform used for running containerized services and workloads, that promotes both declarative automation and configuration. Kubernetes services and tools are a vast, rapidly growing ecosystem and are widely available for use.

At its basic level, the Kubernetes system is utilized for running and regulating containerized applications over a group of multiple machines. It is a program designed to fully manage the life cycle of containerized applications and its services by using tools and methods that offer high scalability, predictability, and high availability.

Kubernetes provides composable platform primitives and interfaces, and that allows the users to define and manage their applications with high levels of flexibility, scalability, and reliability.

Kubernetes Concepts

Making use of Kubernetes requires an understanding of the different abstractions that it employs to represent the state of the system.

Such as pods, services, volumes, namespaces, and deployments.

  • Pod 
    Pod commonly refers to one or more containers that should be controlled and managed as a single application. A pod encapsulates storage resources, application containers, a unique network ID, and other configurations on how to run the containers.
  • Service 
    Service pods are volatile; which means, Kubernetes does not ensure for a given physical pod to be kept active (for example, the replication controller can remove and start a new set of pods). Instead, a service denotes a coherent set of pods that acts as a gateway to allow client pods to send requests to the service without requiring to keep track of which physical pods make up the service.
  • Volume 
    A Kubernetes volume refers to a whole pod and is mounted on every container in the pod. Volume is similar to a container volume in Docker. Kubernetes guarantees for data to be preserved across container restarts. The volume will be discharged only when the pod gets destroyed. Also, a pod can have multiple volumes of different types associated with it
  • Namespace
    The namespace is a virtual cluster that can run a single physical cluster or multiple virtual ones which are intended for environments with many users across multiple projects or teams, for its privacy concerns. Resources inside a namespace cannot access resources in a different namespace and must be unique. Also, a namespace can be allotted to reserve resources to avoid using more than its share of the physical clusters from the overall resources.
  • Deployment
    In a YAML file, Deployment represents the desired state of a replica set or a pod. The deployment controller then updates the environment, for example, eliminating or creating replicas until the current state matches the desired state that is specified in the deployment file. For instance, if two replica models are defined in a YAML file for a pod, but only one is currently running, an additional one will get created. Note that replicas controlled by a deployment should not be managed directly, but only via new Deployment.

Kubernetes Architecture

Kubernetes Architecture has two main components:

  • Master nodes
  • Worker/Slave nodes

We are going to discuss both the components in details
Initially let us begin with understanding the Master Node Component

Master nodes

The management of the Kubernetes cluster is done by the master node. It is mainly responsible as an entry point for all administrative tasks. The master node is responsible for exposing the API, scheduling the deployments, and maintaining the overall cluster. There can be multiple master nodes in the cluster to examine the fault tolerance.

kubernetes-chart

The master node has various components like Scheduler, API Server, Controller Manager, and ETCD.

  • Scheduler: The scheduler records and maintains the tasks to slave nodes. It files the information on resource usage for each slave node.
  • API Server: All of the REST commands used to control the cluster is managed through the API server.
  • Controller Manager: It is a component that controls the Kubernetes cluster and also manages different non-terminating control loops.
  • ETCD: It is a simple, shared, and a consistent key-value store component. It is mainly utilized for service discovery and shared configuration.

Worker/Slave nodes

Worker nodes incorporate all the required tools to manage the networking between the containers. Such as communication with the master node and assigning of resources to the other scheduled containers.

The worker node has various components like Pods, Docker Container, Kubelet, and Kube-proxy.

  • Pods: A pod is a single or multiple containers that logically operate together on nodes.
  • Docker Container: Docker operates on each of the worker nodes and runs the configured pods
  • Kubelet: Kubelet receives the configuration of a Pod from the API server and secures the described containers that are up and running.
  • Kube-proxy: Kube-proxy works as a load balancer and a network proxy for a service operating on a single worker node.

Kubernetes Design Principles

Kubernetes was built to promote the features required by highly available distributed systems, such as auto-scaling, portability, high availability, and security.

Scalability

Based on CPU utilization, Kubernetes provides horizontal scaling of pods. Though the limit for CPU usage is configurable, Kubernetes will automatically start new pods if it reaches the limit. In case, the limit is 70% for CPU usage, but the application is using up to 220%, then eventually three more pods will be deployed and used to bring back average CPU utilization to under 70%. If there are many pods for a specific application, then Kubernetes presents the load balancing capacity across multiple pods. It also promotes horizontal scaling of stateful pods, including RDBMS and NoSQL databases through Stateful sets. The concept of a Stateful set is similar to Deployment, but it assures stable and persistent storage, even when a pod is removed.

High Availability

Kubernetes provides high availability at both levels i.e., at the infrastructure level and application level. Replica sets ensure that the minimum number of required replicas for a given application of a stateless pod is running. Stateful sets perform the same function for stateful pods as well. Kubernetes supports various distributed storage backends at the infrastructure level. Such as NFS, Azure Disk, AWS EBS, Google Persistent Disk, and more. Adding a secure, accessible storage layer to Kubernetes guarantees the high availability of stateful workloads. Additionally, all of the master components can be configured for multi-master replication to provide more extended availability.

Security

Kubernetes positions security at multiple levels such as at cluster level, application level, and network level. The endpoints of API remain secured through the transport security layer. Only verified users, such as service account users or regular users can execute operations on the cluster via API requests. Kubernetes secrets can store sensitive information at the application level. Secrets such as passwords or tokens via a virtual cluster if using physical namespaces. Note that in a single cluster, secrets remain accessible from any pod. Network policies to access the pods can be defined in a deployment. A network policy sets how pods are authorized to communicate with other network endpoints and with each other.

Portability

Kubernetes portability manifests in terms of the choices of its operating system. For example, a cluster can run on any mainstream Linux distribution, processor architectures with either virtual machines or bare-metal, cloud providers such as the AWS, Azure or Google Cloud Platform, and new container runtimes besides Docker can also be added. Kubernetes can also maintain workloads across hybrid i.e., private and public cloud environments and multi-cloud environments, through the concept of federation. This concept also supports availability-zone-fault-tolerance in a single cloud provider.

Kubernetes Features and why you need them

Containers are an outstanding system to bundle and run applications. You need to maintain the containers that run the applications in a production environment to ensure that there is no downtime. For example, if a container fails, another container needs to start running. Wouldn’t it be easier if a system managed this response?

Here’s where Kubernetes comes to the rescue, by providing you with a framework structure to effortlessly run distributed systems. It takes care of your deployment models, scaling needs, failover, and more. For example, Kubernetes can easily manage and carry deployment for your system.

The features of Kubernetes are as follows:

Automatic Scheduling

Kubernetes allows the advanced scheduler to launch a container on cluster nodes based on their resource requirements and other constraints, without compromising on availability.Self Healing Capabilities

Kubernetes allows us to reschedule and replaces containers when nodes fail. It also eliminates containers, restarts containers that fail, replaces, and kills containers that don’t respond to user-defined status checks, and also doesn’t display these containers to clients unless they are ready to serve.

Automatic rollback & rollouts

Kubernetes can change the actual state to the desired state at a controlled rate if the desired state for your deployed containers is described. Kubernetes rollouts can change the application or its configuration while monitoring application status to ensure it doesn’t eliminate all your cases at the same time. If something goes wrong in the application, with Kubernetes, you can roll back the change.

Horizontal Scaling

Kubernetes can scale down and scale up the application as per the requirements with a simple command, or by using a UI or automatically based on usage of CPU.

Load Balancing & Service discovery

Kubernetes can expose a container using its IP address and the DNS name. If there’s high traffic to a container, Kubernetes can distribute the network traffic and load balance so that the deployment is stable.

Storage orchestration

Kubernetes permits you to automatically mount a system of your choice for storage, such as public cloud providers, local storage, and more.

Automatic container packing

Kubernetes lets you specify how much CPU and RAM each container bin requires. When bins have specified resource requests, Kubernetes can make more reliable decisions to manage the resources for containers.

Confidential configuration management

Kubernetes allows you to manage and store sensitive information, such as passwords, SSH keys, and Authorization tokens. You can update and deploy secrets and application configuration without disclosing secrets in your stack configuration and without rebuilding your container image.

What can Kubernetes do for you?

Kubernetes is an open-source, production-ready platform outlined with best-of-breed ideas from the community and accumulated with Google’s experience in containerization.Container orchestration helps package software applications to be updated and released in a fast and easy way without any downtime. Kubernetes allows you to make sure those containerized applications run whenever and wherever you want. Kubernetes also helps them find the tools and resources they need for processing. With automated web services, users demand applications to be available 24/7, and developers intend to deploy updated versions of these applications several times a day.

Conclusion

Kubernetes is an impressive open-source container-orchestration project that allows users to run highly available and scalable containerized workloads on a highly preoccupied platform. Kubernetes has been structured with more than a decade of experience in driving containerized applications of the system at Google. This system is already utilized by several significant technology providers and public cloud vendors. It is also currently being adopted by most of the enterprises and software vendors. Kubernetes was originally designed by Google but is now maintained by the Cloud Native Computing Foundation. Kubernetes was the first project to graduate under CNCF in the year 2015. It began to streamline the container ecosystem together along with other container-related projects such as Prometheus, CNI, Linkerd, Fluentd, Containers, Envoy, gRPC, Vitess, Jagger, and Rkt.

While Kubernetes’ internal architecture components and set of design structures can at first appear daunting, their flexibility, power, and robust features are set unparalleled in the open-source world. The main reasons for its hype to be endorsed at such a level and for its rising popularity might be because of its flawless design and collaborations with industry leaders. With an open-source system, it has always been open to new ideas and contributions. By learning how the basic building blocks fit together, businesses can start to customize their systems that will fully leverage the capabilities of the platform to manage and run business workloads at scale.

Excited to learn more about how Kubernetes can help you grow your business? Get in touch with our experts today!