Docker for Serverless Applications

Book description

Build applications and infrastructures that leverage Function-as-a-Service and Docker

About This Book
  • Implement containerization in Serverless/FaaS environments
  • Utilize Docker as a functional unit of work for Serverless/FaaS platforms
  • Use Docker as a portable infrastructure for Serverless Applications
Who This Book Is For

If you are a Developer, a Docker Engineer, a DevOps Engineer, or any stakeholder interested in learning the use of Docker on Serverless environments then this book is for you.

What You Will Learn
  • Learn what Serverless and FaaS applications are
  • Get acquainted with the architectures of three major serverless systems
  • Explore how Docker technologies can help develop Serverless applications
  • Create and maintain FaaS infrastructures
  • Set up Docker infrastructures to serve as on-premises FaaS infrastructures
  • Define functions for Serverless applications with Docker containers
In Detail

Serverless applications have gained a lot of popularity among developers and are currently the buzzwords in the tech market. Docker and serverless are two terms that go hand-in-hand.

This book will start by explaining serverless and Function-as-a-Service (FaaS) concepts, and why they are important. Then, it will introduce the concepts of containerization and how Docker fits into the Serverless ideology. It will explore the architectures and components of three major Docker-based FaaS platforms, how to deploy and how to use their CLI. Then, this book will discuss how to set up and operate a production-grade Docker cluster. We will cover all concepts of FaaS frameworks with practical use cases, followed by deploying and orchestrating these serverless systems using Docker. Finally, we will also explore advanced topics and prototypes for FaaS architectures in the last chapter.

By the end of this book, you will be in a position to build and deploy your own FaaS platform using Docker.

Style and approach

A practical guide that offers a simple way to easily understand Serverless Applications utilizing Docker as the development environment.

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Docker for Serverless Applications
  3. Packt Upsell
    1. Why subscribe?
  4. Contributors
    1. About the author
    2. About the reviewer
    3. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Conventions used
    4. Get in touch
      1. Reviews
  6. Serverless and Docker
    1. What is serverless?
      1. The relationship between serverless and FaaS
      2. The disadvantages of serverless FaaS
      3. Docker to the rescue
    2. Common architecture of a serverless FaaS
      1. System layers
      2. FaaS layers
    3. Serverless/FaaS use cases
    4. Hello world, the FaaS/Docker way
      1. Hello OpenFaas
      2. Hello OpenWhisk
      3. Say hello to the Fn project
    5. Exercise
    6. Summary
  7. Docker and Swarm Clusters
    1. What is a container?
    2. What is Docker?
      1. Installing Docker
      2. Building a container image
      3. Shipping an image
      4. Running a container
    3. Docker Swarm clusters
      1. Setting up a cluster
      2. Masters and workers
      3. Services and tasks
      4. Docker and serverless
    4. Exercises
    5. Summary
  8. Serverless Frameworks
    1. AWS Lambda
      1. Limitations
      2. Lambda termination
      3. Container reuse
      4. Native executables
    2. Azure Functions
      1. Scaling
      2. Limitations
      3. Durable functions
    3. Google Cloud Functions
      1. Overview
      2. Execution model
      3. Statelessness
      4. Timeout
      5. Execution guarantees
    4. IBM Cloud Functions
    5. The Serverless Framework
    6. Exercise
    7. Summary
  9. OpenFaaS on Docker
    1. What is OpenFaaS?
    2. Architecture
    3. OpenFaaS components
      1. Function watchdog
      2. Command-line interface
      3. API gateway
    4. Installing OpenFaaS
    5. Preparing a function
      1. Packing a C program
      2. Defining and invoking a function with the UI
    6. Using the OpenFaaS CLI
      1. Defining a new function
      2. Building and pushing
      3. Deploying and invoking
      4. Templates
    7. The OpenFaaS dashboard
    8. Exercises
    9. Summary
  10. The Fn Project
    1. The Fn Project
    2. Fn's architecture
    3. Using Fn CLI
    4. Let's deploy a local function
      1. Trying again with Golang
      2. Examining call logs and errors
    5. Deploying Fn on Docker Swarm
      1. Monitoring with Fn UI
      2. Viewing call logs with MyAdmin
    6. Exercise
    7. Summary
  11. OpenWhisk on Docker
    1. What is OpenWhisk?
      1. Installing OpenWhisk
      2. Using the wsk client
    2. Components and architecture
      1. Architecture
      2. Components
        1. API gateway
        2. Controller
        3. Database
        4. Kafka
        5. Invoker
        6. Action runtime
    3. Function preparation
      1. OpenWhisk Docker SDK
      2. Preparing a Go function
    4. Invoking functions
      1. Invocation flows
      2. Action invoke
      3. Obtaining activation results
    5. User interface
    6. Exercises
    7. Summary
  12. Operating FaaS Clusters
    1. Stabilizing the configuration
      1. Choosing the right network plugin
      2. New ingress and routing
      3. Tracing component
    2. Retry and circuit breaker
      1. Retry
      2. Circuit breaker
    3. Preparing a production cluster
      1. Cost savings with Spot instances
      2. Using EC2 Spot instances
      3. Let's start
      4. Workers on Spot instances
      5. Working with the network plugin
      6. Creating a network
      7. Creating an operational control plane
      8. Service balancer operator
    4. Logging
    5. Scripting Docker with Golang
      1. Preparing the tool
      2. Making Go scriptable
      3. Simple Docker script
      4. Script reacting to Docker events
    6. Exercises
    7. Summary
  13. Putting Them All Together
    1. A mobile payment scenario
    2. A Parse platform as a backend
      1. Preparation
      2. Defining a transfer entity
      3. WebHook
    3. Preparing a WebHook in Fn
    4. An event state machine with a blockchain
      1. How the WebHook uses the blockchain
    5. Wrapping a legacy with a function
    6. A function as a Glue
    7. A stream processor
    8. Inter-FaaS platform networking
    9. Exercises
    10. Summary
  14. The Future of Serverless
    1. FaaS and Docker reviews
    2. Runtime for function containers
      1. Meet RunF
      2. Within a Docker network
      3. What's next?
    3. LinuxKit – immutable infrastructure for FaaS
    4. Beyond serverless
    5. Declarative containers
    6. Exercises
    7. Summary
    8. References
  15. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Docker for Serverless Applications
  • Author(s): Chanwit Kaewkasi
  • Release date: April 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781788835268