DEV Community

Cover image for Kubernetes for front-end developers
Napptive
Napptive

Posted on • Originally published at napptive.com

Kubernetes for front-end developers

If you’re a front-end developer, you may have heard about using Kubernetes in your organization. We get it! You’ve got more than enough with the technologies you’re already using. But fret not, we’re about to answer all your burning questions, like what the heck is Kubernetes, why would a frontend developer use Kubernetes, why Kubernetes for front-end developers anyway, how are you supposed to use it, and more!

What is Kubernetes anyway?

Kubernetes, also known as K8s, is the most popular container orchestration tool. This kind of tool becomes a must when a business leaves behind the monolithic application model, or even the backend-frontend one, and adopts a microservice model. What once was an enormous application becomes a series of loosely coupled microservices. Each one of these microservices runs in a container, which is a technology that enables a lightweight isolation environment. Multiple replicas – of multiple microservices – are then scheduled in a series of machines on the cloud to ensure availability at all times. Some containers crash over time, some of them must be destroyed, and some of them must start. The only way to efficiently manage such a large number of services is by using a tool that automates the operations – like Kubernetes.

Why would a front-end developer use Kubernetes?

The adoption of the microservice model may happen for several reasons. For example, leveraging the power of the cloud, or the ability to scale up and down according to demand. One of the most important reasons, though, is accelerating development. As microservices are loosely coupled, teams become much more independent, because they can make decisions more freely. Updates on a single microservice can be rolled out as soon as they’re ready, as they don’t depend anymore on the rest of the application to be reassembled. And more advantages that we already listed in this blog post.

Once the application undergoes the change of paradigm, the front end inevitably becomes part of this new architecture. Even more, just as the back end is split into microservices, the front end may also be split into micro frontends to enjoy the same benefits.

So why would a front-end developer use Kubernetes? Well, they certainly can choose not to learn anything new and focus on HTML, CSS, JS, and so on… But being aware of how the overall application works on Kubernetes can bring opportunities for improvement. Having the ability to define how the application is deployed on Kubernetes, front-end developers become a part of the release journey of their project, can optimize the configuration and make it more scalable, and even detect and fix crucial micro performance issues.

Why Kubernetes for front-end developers?

Web applications are perfectly fitted to be containerized and orchestrated with Kubernetes. Airbnb is an example of this – They started with a monolith, but over time the modules became too tightly coupled. In 2015, it would be blocked an average of 15 hours per week (!!) due to reverts and rollbacks. So they decided to shift to a microservice-oriented architecture and have been using Kubernetes since 2017.

Ok, so what is…? Super fast glossary!

If you are this far into the article, we’re going to assume that you’re interested in learning about K8s. Here you have a super fast glossary so that you can get an understanding in a glimpse.

  • Container – technology that makes it possible to run an application and its dependencies in a lightweight isolated environment. Docker is the most well-known container runtime.
  • Image – all the binaries, dependencies, scripts, etc. that a microservice needs to run. A running instance is called a container.
  • Pod – smallest deployable unit in Kubernetes. It usually wraps a single container, sometimes more than one.
  • Node – machine in a cluster, probably virtual. In Kubernetes, there are two kinds of nodes – master nodes that run the control plane, and worker nodes that run the containers in pods.
  • Cluster – a group of working nodes and a master node (and usually a replica of the master for backup).
  • Container orchestrator – a tool that manages the containers’ lifecycles and schedules them according to the declared desired state. The most prevalent is Kubernetes, but there are more, like Docker Swarm, Apache Mesos, and others.
  • Container repository – registry where container images are stored for usage.
  • Docker – platform to build, share and run containerized applications.
  • Namespace – a mechanism for isolating groups of resources within a single cluster.
  • Deployment – in Kubernetes, a deployment is an object where the desired state of an application is declared, so that K8s knows how to create or modify the pods.
  • Service – in Kubernetes, a service is a way of exposing a logical group of pods, so that they can be accessed by other pods or from outside the cluster.
  • Ingress – an API object that manages external access to the services in a Kubernetes cluster, typically HTTP.

How do I use it?

Now, you probably want to know how a frontend is deployed and connected to a backend in Kubernetes (and we wholeheartedly encourage you to do it). In that case, you have an excellent resource in the Kubernetes online documentation: Connect a Frontend to a Backend Using Services.

The linked article teaches you how to:

  1. Create and run a sample hello backend microservice using a Deployment object,
  2. Use a Service object to send traffic to the backend microservice’s multiple replicas,
  3. Create and run an nginx frontend microservice, also using a Deployment object,
  4. Configure the frontend microservice to send traffic to the backend microservice, and
  5. Use a Service object of type=LoadBalancer to expose the frontend microservice outside the cluster.

Do you want to know more about Platform Engineering? Why not try our playground? It’s free, simply sign up and get started!

Top comments (0)