All Projects β†’ alexellis β†’ Faas Containerd

alexellis / Faas Containerd

Licence: mit
containerd and CNI provider for OpenFaaS

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Faas Containerd

Frontendmasters Serverless
Source code for the Serverless workshop on Frontend Masters.
Stars: ✭ 54 (-10%)
Mutual labels:  serverless
Yinyue
πŸ–Version Of Progressive Web App ( Serverless )
Stars: ✭ 57 (-5%)
Mutual labels:  serverless
Apex
Old apex/apex
Stars: ✭ 20 (-66.67%)
Mutual labels:  serverless
Examples
Infrastructure, containers, and serverless apps to AWS, Azure, GCP, and Kubernetes... all deployed with Pulumi
Stars: ✭ 1,085 (+1708.33%)
Mutual labels:  serverless
Openwhisk Apigateway
Apache OpenWhisk API Gateway service for exposing actions as REST interfaces.
Stars: ✭ 56 (-6.67%)
Mutual labels:  serverless
Building A Serverless Rest Api With Nodejs
A quick and easy guide of how to hook up a single Serverless service with basic MongoDB connection and CRUD interaction.
Stars: ✭ 57 (-5%)
Mutual labels:  serverless
Node Typescript Boilerplate
Minimalistic project template to jump start a Node.js back-end application in TypeScript. ESLint, Jest and type definitions included.
Stars: ✭ 1,061 (+1668.33%)
Mutual labels:  serverless
Serverless Reqvalidator Plugin
Serverless plugin to attach AWS API Gateway Basic Request Validation https://rafpe.ninja/2017/12/18/serverless-own-plugin-to-attach-aws-api-gateway-basic-request-validation/
Stars: ✭ 59 (-1.67%)
Mutual labels:  serverless
Haveibeenpwned Zxcvbn Lambda Api
Deploy your own secure API to estimate password strength and check haveibeenpwned for known matches - HTTPS by force, server not required, fire and brimstone sold separately πŸ”₯
Stars: ✭ 57 (-5%)
Mutual labels:  serverless
Pulumi
Pulumi - Developer-First Infrastructure as Code. Your Cloud, Your Language, Your Way πŸš€
Stars: ✭ 10,887 (+18045%)
Mutual labels:  serverless
Performance Dashboard On Aws
A simple cost-effective web application to build and publish dashboards.
Stars: ✭ 56 (-6.67%)
Mutual labels:  serverless
Hexa
Hexa: The ultimate companion for Azure. Setup and deploy in seconds
Stars: ✭ 56 (-6.67%)
Mutual labels:  serverless
Checkout Netlify Serverless
Sell products on the Jamstack with Netlify Functions and Stripe Checkout!
Stars: ✭ 58 (-3.33%)
Mutual labels:  serverless
Bootcamp 2021
Fusing Serverless Cloud Computing, Infrastructure as Code, Graph Databases, AI, and IoT Technologies and preparing for Operation Unicorn Startups
Stars: ✭ 55 (-8.33%)
Mutual labels:  serverless
Up
Up focuses on deploying "vanilla" HTTP servers so there's nothing new to learn, just develop with your favorite existing frameworks such as Express, Koa, Django, Golang net/http or others.
Stars: ✭ 8,439 (+13965%)
Mutual labels:  serverless
Lambda Audio
Run Sound eXchange (SoX), the Swiss Army knife of audio manipulation, with Lame on AWS Lambda
Stars: ✭ 53 (-11.67%)
Mutual labels:  serverless
Openfaas On Digitalocean
Ansible playbook to create a Digital Ocean droplet and deploy OpenFaaS onto it.
Stars: ✭ 57 (-5%)
Mutual labels:  serverless
Graphql Serverless
Example boilerplates for GraphQL backends hosted on serverless platforms
Stars: ✭ 60 (+0%)
Mutual labels:  serverless
Community Cluster
OpenFaaS Cloud Cluster for Community
Stars: ✭ 59 (-1.67%)
Mutual labels:  serverless
Alagarr
🦍 Alagarr is a request-response helper library that removes the boilerplate from your Node.js (AWS Lambda) serverless functions and helps make your code portable.
Stars: ✭ 58 (-3.33%)
Mutual labels:  serverless

faas-containerd

Build Status

OpenFaaS provider for containerd - single node / edge workloads

What's the use-case?

OpenFaaS providers can be built for any backend, even for an in-memory datastore. Some users could benefit from a lightweight, single-node execution environment. Using containerd and bypassing Kubernetes or Docker should reduce the start-time for functions and allow for running in resource-constrained environments.

Pros:

  • Fast cold-start
  • containerd features available such as pause/snapshot
  • Super lightweight
  • Basic service-discovery and inter-service communication through /etc/hosts and bridge

Cons:

  • No clustering (yet)

Status

Proof of concept.

This project implements the faas-provider SDK.

Architecture

faas-provider conceptual architecture

See other examples:

Goals:

  • [x] Deploy container specified via PUT to /system/functions
  • [x] Serve HTTP traffic from deployed container via /function/NAME
  • [x] List running containers via GET on /system/functions
  • [ ] Clean-up containers on exit
  • [ ] Give configuration for running faas-containerd / OpenFaaS gateway and Prometheus via systemd unit files or similar

An update - Jan 2020

faas-containerd is now part of the faasd project, which adds additional orchestration to bring the whole OpenFaaS experience and ecosystem to containerd.

See my tutorial on how to get started with faasd. It is written for RPi users, but faasd is designed to be portable and also runs on x86_64 and ARM64:

Demo

Test it out

You need a Linux computer, VM, or bare-metal cloud host.

Get some build dependencies

I used Ubuntu 18.04 LTS on Packet.com using the c1.small.x86 host. You can use multipass.run to get an Ubuntu host on any OS - Windows, MacOS, or Linux.

sudo apt update && \
  sudo apt install -qy runc \
  	bridge-utils \
	tmux git \
  	build-essential \
	libbtrfs-dev libseccomp-dev

Install Go 1.12 (x86_64)

curl -SLsf https://dl.google.com/go/go1.12.14.linux-amd64.tar.gz > go.tgz
sudo rm -rf /usr/local/go/
sudo mkdir -p /usr/local/go/
sudo tar -xvf go.tgz -C /usr/local/go/ --strip-components=1

export GOPATH=$HOME/go/
export PATH=$PATH:/usr/local/go/bin/

go version

Or on Raspberry Pi (armhf)

curl -SLsf https://dl.google.com/go/go1.12.14.linux-armv6l.tar.gz > go.tgz
sudo rm -rf /usr/local/go/
sudo mkdir -p /usr/local/go/
sudo tar -xvf go.tgz -C /usr/local/go/ --strip-components=1

export GOPATH=$HOME/go/
export PATH=$PATH:/usr/local/go/bin/

go version

Get containerd

  • Install containerd (or build from source)

Note: This can only be run on x86_64

export VER=1.3.2
curl -sLSf https://github.com/containerd/containerd/releases/download/v$VER/containerd-$VER.linux-amd64.tar.gz > /tmp/containerd.tar.gz \
  && sudo tar -xvf /tmp/containerd.tar.gz -C /usr/local/bin/ --strip-components=1

containerd -version
  • Or clone / build / install containerd from source:
export GOPATH=$HOME/go/
mkdir -p $GOPATH/src/github.com/containerd
cd $GOPATH/src/github.com/containerd
git clone https://github.com/containerd/containerd
cd containerd
git fetch origin --tags
git checkout v1.3.2

make
sudo make install

containerd --version

Kill any old containerd version:

# Kill any old version
sudo killall containerd
sudo systemctl disable containerd

Start containerd in a new terminal:

sudo containerd &

CNI Plugins

Install the CNI plugins like this:

export CNI_VERSION=v0.8.2

  • For PC run export ARCH=amd64
  • For RPi/armhf run export ARCH=arm
  • For arm64 run export ARCH=arm64

Then run:

mkdir -p /opt/cni/bin
curl -sSL https://github.com/containernetworking/plugins/releases/download/${CNI_VERSION}/cni-plugins-linux-${ARCH}-${CNI_VERSION}.tgz | tar -xz -C /opt/cni/bin

Check it worked:

/opt/cni/bin/bridge --help

CNI bridge plugin v0.8.2

Enable forwarding

This is required to allow containers in containerd to access the Internet via your computer's primary network interface.

sudo /sbin/sysctl -w net.ipv4.conf.all.forwarding=1

Make the setting permanent:

echo "net.ipv4.conf.all.forwarding=1" | sudo tee -a /etc/sysctl.conf

Build and run faas-containerd

  • Get a binary

     # For x86_64
     sudo curl -fSLs "https://github.com/alexellis/faas-containerd/releases/download/0.4.0/faas-containerd" \
       -o "/usr/local/bin/faas-containerd" \
       && sudo chmod a+x "/usr/local/bin/faas-containerd"
    
     # armhf
     sudo curl -fSLs "https://github.com/alexellis/faas-containerd/releases/download/0.4.0/faas-containerd-armhf" \
       -o "/usr/local/bin/faas-containerd" \
       && sudo chmod a+x "/usr/local/bin/faas-containerd"
    
     # arm64
     sudo curl -fSLs "https://github.com/alexellis/faas-containerd/releases/download/0.4.0/faas-containerd-arm64" \
       -o "/usr/local/bin/faas-containerd" \
       && sudo chmod a+x "/usr/local/bin/faas-containerd"
    
     # run faas-containerd
     sudo service_timeout=1m ./faas-containerd
    
  • Or build from source

     export GOPATH=$HOME/go/
    
     mkdir -p $GOPATH/src/github.com/alexellis/faas-containerd
     cd $GOPATH/src/github.com/alexellis/faas-containerd
     git clone https://github.com/alexellis/faas-containerd
     cd faas-containerd
    
     go build && sudo service_timeout=1m ./faas-containerd
    

Listens on port TCP/8081

Test out your faas-containerd

Get the OpenFaaS CLI:

curl -sLfS https://cli.openfaas.com | sudo sh

Deploy a function with a server

faas store deploy figlet -g 127.0.0.1:8081 --update=true --replace=false

Deploy a ping function with a server

faas-cli deploy --image alexellis2/ping:0.1 \
  -g 127.0.0.1:8081 --update=true --replace=false --name ping

Deploy nodeinfo function with a server

faas-cli store deploy nodeinfo \
  -g 127.0.0.1:8081 --update=true --replace=false

Try to list functions:

faas-cli list -g 127.0.0.1:8081

Get a function's status:

faas-cli describe nodeinfo -g 127.0.0.1:8081

Try to invoke a function:

echo "-c 1 8.8.8.8" | faas-cli invoke ping -g 127.0.0.1:8081

echo "verbose" | faas-cli invoke nodeinfo -g 127.0.0.1:8081

List containers with ctr:

sudo ctr --namespace openfaas-fn container list

Delete container, snapshot and task:

sudo ctr --namespace openfaas-fn task kill figlet
sudo ctr --namespace openfaas-fn task delete figlet
sudo ctr --namespace openfaas-fn container delete figlet
sudo ctr --namespace openfaas-fn snapshot remove figlet-snapshot

Enable Basic Auth

Basic auth requires three things: a username file, a password file, and an env variable.

First, create the username and password, make sure to pick a secure password for production deployments:

echo admin >> basic-auth-user
echo localdev >> basic-auth-password

Then set the basic_auth and secret_mount_path env variables when starting faas-containerd:

service_timeout=1m basic_auth=true secret_mount_path=`pwd` sudo ./bin/faas-containerd

The default value for secret_mount_path is /run/secrets/.

Once it is running, you can quickly verify that auth is being enforced by using the CLI:

$ faas-cli list -g 127.0.0.1:8081
Unauthorized access, run "faas-cli login" to setup authentication for this server

Now login:

cat basic-auth-password | faas-cli login -g 127.0.0.1:8081 --tls-no-verify -u admin --password-stdin

You can now deploy and invoke a function as before:

faas-cli deploy --image alexellis2/ping:0.1 \
  -g 127.0.0.1:8081 --update=true --replace=false --name ping
echo "-c 1 8.8.8.8" | faas-cli invoke ping -g 127.0.0.1:8081

The auth is saved in ~/.openfaas/config.yml.

Links

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].