Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Red Hat Summit: Functions as a Service with OpenWhisk and OpenShift

May 16, 2018
Doug Tidwell
Related topics:
KubernetesServerless
Related products:
Red Hat OpenShift Container PlatformRed Hat OpenShift

Share:

    Serverless computing (often called Functions-as-a-Service, or FaaS) is one of the hottest emerging technologies today. The OpenWhisk project, currently in incubation at Apache, is an open-source implementation of FaaS that lets you create functions that are invoked in response to events. Our own Brendan McAdams gave a presentation and demo that explained the basics of serverless, how the OpenWhisk project works, and how to run OpenWhisk in OpenShift.

    Brendan outlined the three properties of a serverless / FaaS platform:

    1. It responds to events by invoking functions
    2. Functions are loaded and executed on demand
    3. Functions can be chained together with triggered events from outside the FaaS platform itself.

    Before we go on, a terminology note. "Functions as a Service" and "Serverless" are normally used interchangeably. Lately, however, people are also using the word "serverless" to mean "anything that doesn't require you to fire up and manage a VM1." To be clear, what we're talking about here is FaaS.

    It's useful to quote the official definition of OpenWhisk from the project's website:

    ...[A] serverless, open source cloud platform that executes functions in response to events at any scale.

    The event-driven nature of OpenWhisk is powerful, but its ability to scale makes certain applications economically feasible for the first time. Without a FaaS platform, you'd have to provision the necessary resources to handle whatever loads the world might throw at your application. With FaaS, you don't provision anything. You simply tell the system, "Here are some things that might happen, and here's the code you should run when they do." The architecture of your app is defined declaratively, and the FaaS provider has to deliver the resources to handle the events.

    Another part of the power of FaaS is that the events can come from anywhere, including sources outside the FaaS platform. For example, a change to a database might generate an event. OpenWhisk allows you to create your own events as well. Red Hat is working on an AMQP event provider, and others have built code that generates events from things like git commits or posts to a Slack channel. Finally, because all functions in OpenWhisk have a REST API, they can also be invoked directly by another piece of code or from the wsk command-line tool. Brendan's demos used the command line extensively.

    A trigger is a class of events, such as all of the changes that are made to a database. Once a trigger is defined, you can create rules to determine which function(s) should be invoked when an event occurs. In OpenWhisk terminology, a function is called an action. All of the terminology is explained in a discussion of the high-level programming model on the project's website. For simplicity's sake, we'll continue to call a function a function.

    The universal data format in the world of OpenWhisk is JSON and the most commonly supported languages are Java, Node.js, and Python. For those three languages you'll use the GSON library, native JSON, and Python dictionaries respectively. As you would expect, support for other languages is actively being developed, including Swift and PHP.

    It's important to remember is that your functions are stateless. They are given some data generated by an event, and then they process that data and return the results. If you call the function again, it has no knowledge of what happened before. If many copies of the same function are running at the same time, they have no knowledge of each other.

    If you're familiar with Unix pipes, you'll grasp the significance of sequences right away. You can create a new function by composing a sequence of functions that should be invoked in response to an event. The output of the first function becomes the input to the second, the output of the second becomes the input to the third, and so on. In Brendan's example, the first function took a name ({"name": "Brandon McAdams"}) and returned a reversed version of that name ({"name": "McAdams, Brandon"}). That JSON was then passed to a Hello World function that returned a greeting with the reversed name returned by the first function ({"greeting": "Hello, McAdams, Brandon"}). Keep in mind that each function in a sequence needs to understand the JSON from the previous one. If you added a third function to the example sequence, it would need to look for a parameter named greeting.

    The entire programming model is very flexible. In response to an event, the system can a single function, a sequence of functions, or multiple functions.

    As you'd expect from the title of the session, Brandon discussed how to run OpenWhisk inside OpenShift. We have a GitHub repo that contains the templates and Docker images you need to deploy OpenWhisk to your OpenShift project. Follow the instructions and you should be up and running with your very own FaaS platform.

    Learning how to build useful applications with a set of serverless functions is a crucial skill for any modern developer. Take a look at our GitHub repo and get started today!


    1 To cite a specific example from the world of containers, imagine a Kubernetes environment in which one of the nodes is in fact a cloud that provisions and deprovisions VMs automatically to host pods in the cluster. You can argue the words "serverless computing" describe that scenario because you're not working with the VMs, but that's not what we're talking about. We're firmly and fundamentally focused on functions here.

    Last updated: September 3, 2019

    Recent Posts

    • Meet the Red Hat Node.js team at PowerUP 2025

    • How to use pipelines for AI/ML automation at the edge

    • What's new in network observability 1.8

    • LLM Compressor: Optimize LLMs for low-latency deployments

    • How to set up NVIDIA NIM on Red Hat OpenShift AI

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue