In this post, I’d like to share some impressions and perspective from the author of the book DevOps for Serverless Application, Shashikant Bangera.
He’s a DevOps, with 18 years of experience in IT, and presents the Serverless world taking principally AWS, Azure, Google, and OpenWhisk as cloud consumption reference for the examples.
The moment we hear the word Serverless it sounds like magic, a world without servers, a world without infrastructure management or the hassles of upgrading and configuring servers. A world without server failure alerts at midnights and early morning hours. We just deploy the code and it works, scales and descales by itself. Yes, that’s what serverless is, but servers do exist under the hood and they are managed by service providers like AWS, Google and Azure; all the heavy lifting is managed by these service providers. You must have heard about AWS Lambda, it is the most popular serverless architecture.
However, there are many other providers too, Google, Azure, Openwhiz and kubeless—some are proprietary and some are open source. As the popularity of the architecture grows, the adoption widens and then arises the chaos of testing, deployment, logging, and monitoring and that’s how DevOps saves the day.
When we talk about DevOps or Continuous integration the first thing that comes to our mind is Jenkins. That is because Jenkins is quite a popular tool in the DevOps world. There is an estimation that there are 1,000,000+ users of Jenkins, which is why it is considered a very popular tool. It has a huge support forum and a good number of plugins. There are various ways to deploy serverless functions like AWS Lambda, through aws cli, cloud formation and there is also a Jenkins plugin for lambda deployment.
Likewise, there is one more popular tool or framework to efficiently build and deploy lambda functions—the Serverless Framework. It is a cli tool that allows the user to build and deploy auto-scaling, pay-per-execution, event-driven function. It supports quite a lot of service providers like Google, Azure, open whiz, Oracle fn, and Kubeless. It supports canary deployment and many other features. It is pretty easy to install configure and setup deployment.
123456789 # The command below will install serverless framework cli and pre-requite to install serverless is Nodejs.$ npm install serverless -g# The command below will help to log into serveless platforms like AWS, Google or Azure$ serverless login# The command below will deploy the function into the provider cloud.$ serverless deploy
More details about the Serverless can be found on https://serverless.com/
But then how do we use it along with Jenkins, there are multiple ways to do it and it also depends on how our Jenkins slaves are configured. If Jenkins slaves are on the VM, then we can install and configure Node.JS, and then install Serverless Framework and configure it to run as Jenkins. We can install and configure the serverless framework on the Jenkins slave VM through the following command as root user.
1234567891011 $ curl --silent --location https://deb.nodesource.com/setup_8.x | bash -$ apt-get install --yes nodejs$ apt-get install --yes build-essential$ npm i -g npm$ npm install serverless -g$ npm config set prefix ‘~/.npm-global'$ export PATH=~/.npm-global/bin:$PATH
And if you are using immutable slaves as docker container, then you can create docker slave through the Dockerfile below with the serverless framework command line tool installed and configured on the slave.
12345678910111213141516171819 FROM jenkins/slaveUSER root# Install Node.jsRUN apt-get update -yRUN apt-get install -y apt-utilsRUN apt-get install -y sudoRUN apt-get install --yes curlRUN curl --silent --location https://deb.nodesource.com/setup_8.x | bash -RUN apt-get install --yes nodejsRUN apt-get install --yes build-essentialRUN npm i -g npmRUN npm install serverless -gRUN npm config set prefix '~/.npm-global'RUN export PATH=~/.npm-global/bin:$PATHUSER jenkins
We can use this slave to setup build, develop and test serverless functions. Likewise we can setup pipeline.
This is a little taste of what the book is made of, and the giving a read I found this book really useful for who are approaching the serverless world with clear concepts and practical examples.
You can find this and other useful concepts and example here: DevOps for Serverless Applications. Happy reading.