Reader small image

You're reading from  Modern DevOps Practices

Product typeBook
Published inSep 2021
PublisherPackt
ISBN-139781800562387
Edition1st Edition
Right arrow
Author (1)
Gaurav Agarwal
Gaurav Agarwal
author image
Gaurav Agarwal

Gaurav Agarwal is a Senior Cloud Engineer at ThoughtSpot with over a decade of experience as a seasoned Cloud and DevOps Engineer. Previously, Gaurav served as a Cloud Solutions Architect at Capgemini and Software Developer at TCS. With a distinguished list of certifications, including HashiCorp Certified Terraform Associate, Google Cloud Certified Professional Cloud Architect, Certified Kubernetes Administrator, and Security Specialist, he possesses an impressive technical profile. Gaurav's extensive background encompasses roles where he played pivotal roles in infrastructure setup, cloud management, and the implementation of CI/CD pipelines. His technical prowess extends to numerous technical blog posts and a published book, underscoring his commitment to advancing the field.
Read more about Gaurav Agarwal

Right arrow

Chapter 9: Containers as a Service (CaaS) and Serverless Computing for Containers

In the last three chapters, we have covered immutable infrastructure, configuration as code, and infrastructure as code and how to use Packer, Ansible, and Terraform to create one. These chapters introduced you to the era of modern DevOps, where everything is automated. We follow the same principles for building and deploying all kinds of infrastructure, be it containers or virtual machines.

Now, let's get back to the container world and look at other ways of automating and managing container deployments – Containers as a Service (CaaS) and Serverless computing for containers. CaaS provides container-based virtualization that abstracts away all management behind the scenes and helps you manage your containers, without worrying about the underlying infrastructure and orchestration. For simple deployments and less complex applications, CaaS can be a savior. Serverless computing is a broad...

Technical requirements

You will need an active AWS subscription for this chapter's exercises. Currently, AWS is offering a free tier for some products. You can sign up at https://aws.amazon.com/free. This chapter uses some paid services, but we will try to minimize how many we use as much as possible during the exercises.

You will also need to clone the following GitHub repository for some of the exercises:

https://github.com/PacktPublishing/Modern-DevOps-Practices.

Run the following command to clone the repository into your home directory. Then, cd into the ch9 directory to access the required resources:

$ git clone https://github.com/PacktPublishing/Modern-DevOps-\
Practices.git modern-devops $ cd modern-devops/ch9

As the repository contains files with placeholders, you will have to replace the <your_dockerhub_user> string with the your actual Docker Hub user. Use the following commands to substitute the placeholders.

$ find ./ -type f -exec sed -i -e...

The need for serverless offerings

So far, we've been spinning up and down compute instances such as virtual machines. Somehow, we were aware of and optimized the number of resources, machines, and all the infrastructure surrounding the applications we'd built. Still, you want your team to focus on what they do best – code development. Unless your organization wants to invest heavily in an expensive infrastructure team to do a lot of heavy lifting behind the scenes, you'd be better off concentrating on writing and building quality applications, rather than focusing on where and how to run them and how to optimize them.

Serverless offerings come as a reprieve for this problem. Instead of concentrating on how to host your infrastructure to run your applications, you can declare what you want to run, and the serverless offering manages it for you. This has come as a boon for small enterprises that do not have the budget to invest heavily in infrastructure and want...

Amazon ECS with EC2 and Fargate

Amazon Elastic Container Service (ECS) is a container orchestration platform that AWS offers. It is simple to use and manage, uses Docker behind the scenes, and can deploy your workloads to Amazon EC2, a virtual machine-based solution, or Amazon Fargate, a serverless solution.

It is a highly scalable solution that helps you host your containers in minutes. It makes it easy to host, run, stop, and start your containers. Similar to how Kubernetes offers pods, ECS offers tasks, which help you run your container workloads. A task can contain one or more containers, grouped according to a logical relationship. You can also group one or more tasks into services. Services are similar to Kubernetes controllers, which manage tasks and can ensure that the required number of replicas of your tasks are running in the right places at a time. ECS uses simple API calls to provide many functionalities, such as creating, updating, reading, and deleting tasks and services...

Other CaaS products

Amazon ECS provides a versatile way of managing your container workloads. It works great when you have a smaller, simpler architecture and don't want to add the additional overhead of using a complex container orchestration engine such as Kubernetes.

Tip

If you run exclusively on AWS and you don't have a need for a future multi-cloud or hybrid-cloud strategy, ECS is an excellent tool choice. Fargate makes it easier to deploy your containers and run them without worrying about the infrastructure behind the scenes.

ECS is tightly coupled with AWS and its architecture. To solve this problem, we can use managed services within AWS, such as the Elastic Kubernetes Service (EKS). It offers the Kubernetes API to schedule your workloads. This makes managing containers even more versatile as you can spin up a Kubernetes cluster with ease and use a standard, open source solution that you can install and run anywhere you like. This does not tie you to a particular...

Open source CaaS with Knative

As we've seen, there are several vendor-specific CaaS services available on the market. Still, the problem with most of them is that they are tied up to a single cloud provider. Our container deployment specification then becomes vendor-specific and results in vendor lock-in. As modern DevOps engineers, we also have to ensure that the solution we propose best fits the architecture's needs, and avoiding vendor lock-in is one of the most important ones.

However, Kubernetes in itself is not serverless. You have to have infrastructure defined, and daemon services should have at least a single instance running at a particular time. This makes managing microservices applications a pain and resource-intensive.

But wait! We said that microservices help optimize infrastructure consumption. Yes, that's correct, they do, but they do so within the container space. Imagine that you have a shared cluster of VMs where parts of the application scale...

Summary

This chapter covered CaaS and serverless CaaS services. These help us manage container applications with ease, without worrying about the underlying infrastructure and managing them. We used Amazon's ECS as an example and deep dived into it with an example. Then, we briefly discussed other solutions that are available on the market. Finally, we looked at Knative, an open source serverless solution for containers that runs on top of Kubernetes and uses many other open source CNCF projects.

In the next chapter, we will delve into continuous integration in the container world.

Questions

  1. ECS allows us to deploy to which of the following? (Multiple answers are possible)

    A. EC2

    B. AWS Lambda

    C. Fargate

    D. AWS Lightsail

  2. ECS uses Kubernetes in the background – True/False?
  3. We should always use services in ECS instead of tasks for batch jobs – True/False?
  4. We should always use Fargate for batch jobs as it runs for a short period, and we only pay for the resources that are consumed during that time – True/False?
  5. Which of the following are CaaS services that implement the Kubernetes API? (Multiple answers are possible)

    A. GKE

    B. AKS

    C. EKS

    D. ECS

  6. Google Cloud Run is a serverless offering that uses Knative behind the scenes – True/False?
  7. Which one of the following is offered as a Knative module? (Multiple answers are possible)

    A. Serving

    B. Eventing

    C. Computing

    D. Containers

Answers

  1. a, c
  2. False
  3. False
  4. True
  5. a, b, c
  6. True
  7. a, b
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Modern DevOps Practices
Published in: Sep 2021Publisher: PacktISBN-13: 9781800562387
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Gaurav Agarwal

Gaurav Agarwal is a Senior Cloud Engineer at ThoughtSpot with over a decade of experience as a seasoned Cloud and DevOps Engineer. Previously, Gaurav served as a Cloud Solutions Architect at Capgemini and Software Developer at TCS. With a distinguished list of certifications, including HashiCorp Certified Terraform Associate, Google Cloud Certified Professional Cloud Architect, Certified Kubernetes Administrator, and Security Specialist, he possesses an impressive technical profile. Gaurav's extensive background encompasses roles where he played pivotal roles in infrastructure setup, cloud management, and the implementation of CI/CD pipelines. His technical prowess extends to numerous technical blog posts and a published book, underscoring his commitment to advancing the field.
Read more about Gaurav Agarwal