Blog Detail

Kubernetes Tutorial - an Introduction to the Basics

Google created Kubernetes to help developers better manage their containerized applications across clusters. Although a beta version was released in 2014, the first stable release of Kubernetes was just made available in September 2018. The following Kubernetes tutorial will cover the basic architecture and uses for this popular new tool. The Need for Containerization Today’s internet users don’t tolerate downtime, so developers have had to find ways to perform maintenance and updates without interrupting their services.k

The Need for Containerization

oday’s internet users don’t tolerate downtime, so developers have had to find ways to perform maintenance and updates without interrupting their services. Containers, or isolated environments that include everything needed for an application to run, make it easy for developers to edit and deploy apps on the fly. Thus, containerization has become a preferred method for packaging, deploying and updating distributed web applications. Of course, managing such apps across more than one machine can get complicated very quickly. That’s why Google set out to develop an open source system that would simplify the “deployment, scaling and operations” of containerized applications across multiple hosts. The result was Kubernetes, which allows developers to create and manage “clusters” of physical and virtual machines in order to coordinate cooperation via a shared network.


The Benefits of Kubernetes

Kubernetes alleviates the burdens of manually managing your containers in a large scale production environment. If set up properly, Kubernetes can save developers time and money by automating infrastructure resource management. For example, when an instance fails, Kubernetes automatically re-creates it. The end result is a smoother user experience and less downtime for your apps. Using Kubernetes comes with a learning curve, but the rewards are well worth the effort.


Kubernetes Architecture

A Kubernetes cluster is a network of containers capable of communicating with each other. You can have a small cluster that runs on just one machine, or you can make massive clusters that operate across several machines. Machines in a cluster are assigned specific roles. A Kubernetes cluster typically consists of: The Master Server The master server is the primary machine responsible for facilitating communication between the cluster’s different components. The master server uses what’s called a declarative plan to run applications most efficiently using the available infrastructure. Nodes The other machines in a Kubernetes cluster act as nodes that perform workloads with the assistance of local and external resources. Nodes communicate with the master through an agent called a kubelet. Configuration data for each node is stored in a distributed key-value store known as etcd. A Container Runtime Each node must have a container runtime, such as Docker, to process instructions from the master server. Docker’s job, of course, is to create and manage containers. A Network Containers need a network and IP addresses to facilitate communication. Web developers have several Kubernetes networks to choose from. The Kubernetes API


What is Tree Shaking?

Tree shaking, also known as live code inclusion, is a technique for optimizing code written in ECMAScript dialects like JavaScript. As apps accumulate dependencies over time, some of them are likely to fall out of use. The result is bloat, or messy code that wastes resources and drags down your application’s performance. The aim of tree shaking is to remove unused JavaScript to ensure that only executable code gets sent to the user. If you think of your application as a tree trunk and its dead dependencies as dead limbs, the analogy is quite clear.


Why Perform Tree Shaking?

JavaScript is significantly more expensive to process than other web resources, such as images and HTML, because it must be parsed and compiled prior to execution. That’s why web developers should strive to trim down their JavaScript code as much as possible before bundling it up. For example, the image below shows the execution time between 170KB worth of JavaScript versus a JPEG image that is 170KB in size.