Kubernetes Lab-Suresh

What are the 10 feature of Kubernetes?

Kubernetes can schedule and run application containers on clusters of physical or virtual machines. Kubernetes provides the infrastructure to build a truly container-centric development environment.

Kubernetes can speed up the development process by making easy, automated deployments, updates (rolling-update) and by managing our apps and services with almost zero downtime. It also provides self-healing. Kubernetes can detect and restart services when a process crashes inside the container. Kubernetes is originally developed by Google, it is open-sourced since its launch and managed by a large community of contributors.

Kubernetes satisfies number of common needs of application running in production , such as :

  1. Co-locating helper process , facilitating composite application and preserving the one application per container model
  2. Mounting storage systems
  3. Distributing secrets
  4. Checking application health
  5. Replicating application health
  6. Using Horizontal Pod Autoscaling
  7. Balancing loads
  8. Monitoring resource
  9. Debugging application
  10. Providing authentication and authorization.

How kubernetes works?

Kubernetes the most prominent technology in modern microservices. It is designed to make managing microservices clusters of containerized applications simpler and more automated. Beneath this simple notion is a world of complexity. 

One helpful way to think about Kubernetes is as a distributed operating system for containers. It provides the tools and commands necessary for orchestrating the interaction and scaling of containers (most commonly Docker Containers) and the infrastructure containers run on. A general tool designed to work for a wide range of scenarios, Kubernetes is a very flexible system—and very complex.

Kubernetes Works Like an Operating System:

Kubernetes is an example of a well-architected distributed system. It treats all the machines in a cluster as a single pool of resources. It takes up the role of a distributed operating system by effectively managing the scheduling, allocating the resources, monitoring the health of the infrastructure, and even maintaining the desired state of infrastructure and workloads. Kubernetes is an operating system capable of running modern applications across multiple clusters and infrastructures on cloud services and private data center environments.

Like any other mature distributed system, Kubernetes has two layers consisting of the head nodes and worker nodes. The head nodes typically run the control plane responsible for scheduling and managing the life cycle of workloads. The worker nodes act as the workhorses that run applications. The collection of head nodes and worker nodes becomes a cluster.

Kubernetes architecture diagram

What are the components of Master? explain in one line sentense?

Master Server Components

API Server

The API server exposes a REST interface to the Kubernetes cluster. All operations against pods, services, and so forth, are executed programmatically by communicating with the endpoints provided by it.

Scheduler

The scheduler is responsible for assigning work to the various nodes. It keeps watch over the resource capacity and ensures that a worker node’s performance is within an appropriate threshold.

Controller-Manager

The controller-manager is responsible for making sure that the shared state of the cluster is operating as expected. More accurately, the controller manager oversees various controllers which respond to events (e.g., if a node goes down).

etcd

etcd is a distributed key-value store that Kubernetes uses to share information about the overall state of a cluster. Additionally, nodes can refer to the global configuration data stored there to set themselves up whenever they are regenerated.

What are the components of Worker? explain in one line sentense?

Worker Node Components

Kubelet

A Kubelet tracks the state of a pod to ensure that all the containers are running. It provides a heartbeat message every few seconds to the master server. If a replication controller does not receive that message, the node is marked as unhealthy.

Kube Proxy

The Kube proxy routes traffic coming into a node from the service. It forwards requests for work to the correct containers.

etcd

etcd is a distributed key-value store that Kubernetes uses to share information about the overall state of a cluster. Additionally, nodes can refer to the global configuration data stored there to set themselves up whenever they are regenerated.

kubernetes worker node 02

What are the components of Workstation? explain in one line sentence?

A Kubernetes cluster consists of a set of worker machines, called nodes that run containerized applications. Every cluster has at least one worker node.

The worker node(s) host the  Pods that are the components of the application workload. The  Control plane manages the worker nodes and the Pods in the cluster. In production environments, the control plane usually runs across multiple computers and a cluster usually runs multiple nodes, providing fault-tolerance and high availability.

There are two aspects to Kubernetes: the worker nodes and the control plane. The worker nodes are where the actual containerized applications exist along with the necessary Kubernetes tooling. The control plane is where the tools for managing this cluster lives.

Components of Kubernetes

What is POD?

Pods are the smallest execution unit in a Kubernetes cluster. In Kubernetes, containers do not run directly on cluster nodes; instead one or more containers are encased in a pod. All applications in a pod share the same resources and local network, easing communications between applications in a pod. Pods utilize an agent on each node called a kubelet to communicate with the Kubernetes API and the rest of the cluster. Although developers need API access, management of pods is transitioning to the domain of DevOps.

As the load on a pod increases, Kubernetes can automatically replicate the pod to achieve desired scalability. Thus it is important to design a pod to be lean as possible. Pods should contain a single main process along with any help or ‘side-car’ containers necessary for their execution.

What is the difference between containers vs. pods?

Containers encompass the code required to execute a specific process or function. Before Kubernetes, organizations would run containers directly on a physical or virtual server, but without the scalability and flexibility offered by a kubernetes cluster.

Pods offer another level of abstraction for containers. One or more application can be wrapped into a pod (think peas in a pod), and the pod is the smallest unit of execution in a Kubernetes cluster. For example, pods can contain initialization containers that prepare the environment for the containerized application code and then terminate before the application container begins execution. Pods are the smallest unit of replication in a cluster, so all containers in a pod will scale up or down together.

Pods include persistent storage volumes as well as containers, if access to persistent storage is necessary for the application.

  • A Pod can host multiple containers and storage volumes.
  • Pods are instances of Deployments
  • One Deployment can have multiple pods.
  • With Horizontal Pod Autoscaling, Pods of a Deployment can be automatically started and halted based on CPU usage.
  • Containers within the same pod have access to shared volumes.
  • Each Pod has its unique IP Address within the cluster.
  • Pods are up and running until someone (or a controller) destroys them.
  • Any data saved inside the Pod will disappear without a persistent storage.
alt text