The concept of “going Serverless” is not a new one, and if you’re reading this you’ve heard or are interested in learning about one of the topics mentioned in the article title, as they have all become increasingly popular topics over the past few years. If you’re working in the tech industry but aren’t a “techie” and want to keep up to date, or plan to work in an area of technology — you should invest some time in learning about containers, Docker, Kubernetes and Serverless. This article is for someone wanting to know more about these essential pieces of software.
There are two terms you need to know about here: A container image and a container. The image is a package with a piece of software that includes everything you need to run it such as your run time environment specifications. The container itself is an active instance of this image. They allow you to deploy and run applications regardless of their environment.
Lets say you are collaborating on a project with someone in a different department. You’re writing a database using MySQL, and your colleague is creating a game GUI in Python. Can you imagine trying to deploy one single working environment with all the dependencies for both circumstances? In this situation, we could simply use a container with an image of both run time environments for a more efficient project collaboration.
The main reason for containerization is to have a lightweight solution to package applications without having to deal with virtual machines which use up your computers valuable resources.
Docker is a platform which provides a set of tools to help developers build, ship and run their applications in the containers mentioned above. It originated as an open source project which has become the most popular container platform at present. Docker offers an image-based distribution model. This makes it easy to share an application and it’s dependencies across many environments.
But where does Docker live? As mentioned before, containers offer a lightweight alternative to virtual machines. Below are two systems. You can see how the one running Docker is a lot more simplified. It eliminates the need for heavy guest virtual operating systems sitting on your host.
There’s plenty of documentation out there to help you build a “Dockerfile” The Dockerfile will be a base image for your future containers. However, one thing you should consider before starting with Docker is your operating system. I didn’t realize how much this impacts your productivity if you’re only starting out — Linux or a distribution of Linux (eg. Ubuntu 18.04)) would work best. Please, for your own sake, don’t start out with Docker on a Windows machine if you’re a beginner — the configurations are soul destroying.
Dividing up a large application into separate containers can also have security benefits: if one container is compromised the others remain unaffected. Developers use Docker to test and develop environments locally — similar to a live server where they can update code instantly. This leads us onto our next topic.
Kubernetes (or K8s) is one of the fastest, open source growing projects on GitHub. It ***provides tooling to manage a large number of containers. **Kubernetes can be run on-premise or using a cloud service. Kubernetes schedules “pods” on different servers*. **A pod is a group of one or more containers that share the same IP address, so they can talk to each other via localhost. A really great way to understand Kubernetes is by watching this creative video called “Kubernetes for Kids”.
The name is slightly ambiguous, because of course there are servers running your applications somewhere, but you don’t need to worry about them as they are not user defined*. **The idea is, developers don’t need to worry about the scalability of their programs — which means less time to market. **They deploy their code as functions (FaaS, Functions As A Service)*. **The functions can be accessed at any time, anywhere. The user pays-per-execution, and the functions are stateless (meaning short lived).
An example of a serverless platform is the fnproject, which supports every programming language.
- Less Ops management
Serverless architectures allow developers to focus on writing code, the responsibility lies with your cloud provider, and the functions as a service they are offering are managed solely by them.
Serverless functions (your applications) are always invoked by an event (like an HTTP request), and are scaled on demand. This has the potential to be a very cost efficient service as you pay per execution.
- Badly behaved code will become obvious
Some say this will change the way developers write software.
You now have the basis for gaining a better understanding of containerization and serverless architecture. You might not understand how they all tie together right now, but the more you read about these topics, the clearer this will become.
To get started here’s a simple tutorial on how to deploy WordPress to Docker containers.
This article and those that follow are for beginners with an interest in development - like me. Any future posts will consist of my own learning experiences.
I'm also participating in the #100daysofcode challenge👨💻 Feel free to connect with me on Twitter, I'd appreciate hearing stories of fellow coders taking part!