11 minutes read

Container deployments are an increasingly popular way to package applications and deploy them to various environments. They offer several benefits, such as improved scalability, portability, and security. Here, we look at Kubernetes—a system that manages containerized applications.

What is Kubernetes?

Kubernetes (K8s) is an open-source platform for deploying, managing, and scaling containerized applications. Kubernetes does all of this through features such as auto-deployment, auto-scaling, self-healing, and resource optimization. These features not only make it very capable but also make it an easy platform to use when deploying applications in any environment. Here's the Kubernetes logo:

Kubernetes logo

Google initially developed Kubernetes and released it in 2014. The company later donated it to the Cloud Native Computing Foundation, where an international team of programmers now maintains and supports it.

Core terminology

As noted, Kubernetes deploys and manages containerized applications. Everything in Kubernetes is an object, defined in JSON or YAML. You define the desired state in YAML files, for example, “3 copies of the Nginx web server”, and various control loops ensure the current state matches the desired state.

The applications themselves run inside worker nodes. A Node can be a physical or a virtual worker machine. It has access to a set of resources, such as CPU, memory, and storage. Inside nodes, the containerized application runs in sets called Pods. A Pod can run one or more containers, each running an application or supporting service.

To manage groups of Pods, you can create Deployments, which, in turn, manage ReplicaSets. A ReplicaSet is a group of pods that share the same specification. For one-off or recurring tasks, Kubernetes uses Job and CronJob objects. If you’d like a copy of a Pod on every node, DaemonSets provide that functionality. For workloads requiring persistent data, StatefulSets are used. We'll deploy workloads with each of these primitives throughout the course.

In Kubernetes, Pods are ephemeral and can be removed at any time. Using labels avoids the need to keep track of individual names or UIDs and makes object selection easier. Services make communication in your cluster straightforward. With namespaces, related resources can be grouped for easy management.

The Kubernetes cluster

A Kubernetes cluster consists of a control plane and one or more worker nodes:

Kubernetes cluster components

Control plane components manage the cluster's overall state. We'll take a closer look at these control-plane components later on, but here is a brief overview of them:

  • kube-apiserver — exposes the Kubernetes HTTP API. All components interact via this component.

  • kube-scheduler — assigns pods to suitable nodes.

  • etcd — stores all data.

  • kube-controller-manager — runs various controllers that ensure the cluster's state is closer to the desired state.

  • cloud-controller-manager — interfaces with a cloud provider.

Node components run on every node, providing the runtime environment for Kubernetes:

  • kubelet — ensures that Pods are running. It handles all commands coming from the control plane.

  • kube-proxy — maintains network rules for communication.

  • The container runtime manages the entire container lifecycle.

  • Add-on components to provide features not included out of the box or to improve existing ones.

You interact with a Kubernetes cluster by sending requests to the Kubernetes HTTP API. You can do this through kubectl — a command-line tool, a web-based dashboard, or language-specific SDKs. They allow you to deploy and manage applications, view resource utilization, and take any required actions.

Benefits of using Kubernetes

Here are some benefits of Kubernetes:

  • Deployment management — you specify the desired state, such as 10 containers always running, and Kubernetes works to meet those requirements. With Kubernetes, it's easy to roll back and roll out deployments and set up canary and blue-green deployments.

  • Self-healing systems — Kubernetes creates, destroys, restarts, and replaces containers that don't respond to configured health and readiness checks, all without manual intervention.

  • Storage — with Kubernetes' storage subsystem, you can automatically mount a storage system of your choice, either local or from cloud providers.

  • Extensibility — you can add a feature to your cluster by creating an add-on while benefiting from the core features Kubernetes already provides.

  • Configs & secrets — you can easily store and manage sensitive information, such as database passwords, OAuth tokens, and application configuration data, without needing to rebuild the image or expose them in your code.

  • Resource efficiency — when creating manifests, you can tell Kubernetes how many resources (CPU & RAM) your containers need, and Kubernetes fits them onto your nodes to make the best use of your resources.

Conclusion

In this topic, you learned the basics of Kubernetes:

  • The history of Kubernetes.

  • The architecture of a Kubernetes cluster.

  • How you can interact with a Kubernetes cluster.

  • Benefits of Kubernetes.

18 learners liked this piece of theory. 1 didn't like it. What about you?
Report a typo