This introduction to Kubernetes will explore the architecture, benefits, and potential problems with this powerful container orchestration platform. Kubernetes, often abbreviated to K8s (there are 8 letters between the K and the s), is a container orchestration system. It automates the deployment, scaling, and management of containerised applications. Originally designed by Google, Kubernetes was donated to the Cloud Native Computing Foundation as a seed technology. It supports a range of container technologies, including Docker. Kubernetes is also used as the core for a number of other solutions such as: Rancher Labs, RedHat OpenShift, CoreOS Tectonic and IBM Cloud for its container services.
Kubernetes is actually a complex application with very specialised functionality. As stated earlier, its entire purpose is to deploy, scale, and manage containers (such as Docker) that run components of your custom applications. It’s important to understand the overall architecture of Kubernetes if you plan on using it to manage your production applications.
An Introduction to Kubernetes Architecture
A Kubernetes instance is made up of a cluster of hosts, it can be a small as just one host, minikube is an example of a minimal install. At the other extreme, 1000 node clusters are possible.
Kubernetes consists of 2 main components:
- Master(s) – At least one is required, use multiple for resilience
- Node(s) – Can be run on the Master host, typically these are separate hosts
Master: The Kubernetes Master is the controller of the cluster and it consists of multiple services:
- API server: The API server is the service through which Kubernetes commands are issued and Kubernetes specific information is queried.
- Controller: The controller watches the state of the cluster and initiates changes in an attempt to comply with the desired state (desired state is defined to K8s by the K8s administrator and is typically stored in YAML files).
- Scheduler: The scheduler is responsible for deciding where to run the Pods (containers) based on the resources available on the Nodes.
- etcd: Configuration data and container state information is held in etcd.
Kubernetes Architecture – Wikipedia
Nodes: also known as Workers or Minions, are responsible for running multiple Kubernetes services. These services consist of:
- Kubelet: The Kubelet service is responsible for starting and stopping the containers and provides a heartbeat back to the Master.
- Kube-proxy: The Kube Proxy service is a network proxy and load balancer that is responsible for routing traffic to the appropriate container based on the incoming request IP and port number.
- Pod: The Pod is the basic unit of work, it runs the container image; think of it as a wrapper around the container. Pods can also run multiple containers and it wraps these together along with storage into one manageable unit.
- cAdvisor: cAdvisor is an agent (built into the Kubelet) that collects resource utilisation information which is used by the Kubernetes Master.
What’s Great About Kubernetes?
Kubernetes automates the deployment and operation of containerised applications. Deployment descriptions in the form of a YAML files are given to the Master via the API server and then the requested images are started on those Nodes with available capacity.
As an example, a deployment may ask for 6 NGINX images to be started. Kubernetes will pull the NGINX Docker image and start 6 containers wrapped in Pods with that image across available Nodes. It will continue to ensure that there are 6 running. If an image should stop running a new one will automatically be started to replace it. You don’t explicitly define where any of these images run, Kubernetes handles this automagically for you! Additionally the network routing and load balancing will be configured automatically and updated to reflect any changes to running containers. The scaling up/down of the number of instances may be managed manually or automatically based on resource utilisation. Managing rolling updates and running multiple versions are also all handled by Kubernetes.
Kubernetes automates a considerable amount of work when running containerised applications by taking care of many tasks and hiding complexity behind relatively simple command line interface and descriptor files. This level of automation facilitates increased velocity in the continuous deployment of modern applications.
What Are Some Problems With Kubernetes?
Increased automation and the hiding of complexity is a good thing while all is working as expected. The challenge is knowing what has broken or is misconfigured when things are not working as expected. The standard Kubernetes dashboard only provides limited information while the command line tool provides deep information but not in an easily digestible form.
Kubernetes Dashboard screenshot
This limited visibility can be both challenging and time consuming when troubleshooting a problem with an application environment. By default the containers are distributed across available Nodes with sufficient resources available, this can make monitoring the technology in those containers difficult because they can be running anywhere and could move if restarted.
This article is only an introduction to Kubernetes, more information is available on Kubernetes benefits and problems.
Introduction to Kubernetes – Hands-on Learning
If you really want to get familiar with Kubernetes you might want to consider installing it and running a test application. Instana has built a sample microservices application called Stan’s Robot Shop that you can deploy using Kubernetes.
Kubernetes is a great tool for orchestrating containerised applications. It automates the very complex task of dynamically scaling an application in real time. The problem with K8s is that it’s a complex system itself; this is an impairment when things are not working as expected. This introduction to Kubernetes has touched on some of the most important topics but there is much more to learn.
Monitoring both Kubernetes and the application environment(s) it is orchestrating is essential to ensure all is working as it should and the users of the application are receiving a prompt and error free service. The monitoring solution must provide an integrated view of both the Kubernetes cluster and the applications it supports. It must be able to continuously adapt to the ever changing environment as workloads are scheduled across multiple nodes. It must be able to ingest vast quantities of data: time series, events and request traces, then condense it into actionable information.
If you’re currently or are planning to use K8s to manage your production container based applications then you need to check out Instana. It was built to monitor the entire application stack including orchestration and containers.