Code Monkey home page Code Monkey logo

serverless-kubeless's Introduction

Kubeless Serverless Plugin

This plugin brings Kubeless support within the Serverless Framework.

Kubeless is a Kubernetes-native Serverless solution.

Pre requisites

Make sure you have a kubernetes endpoint running and kubeless installed:

$ kubectl version
$ brew install kubeless/tap/kubeless
$ KUBELESS_VERSION=0.1.0
$ kubectl create ns kubeless
$ curl -sL https://github.com/kubeless/kubeless/releases/download/v$KUBELESS_VERSION/kubeless-v$KUBELESS_VERSION.yaml | kubectl create -f -

Then install serverless

$ npm install serverless -g

Try out the example

Clone this repo and check the example function

$ git clone https://github.com/serverless/serverless-kubeless
$ cd examples/get-python
$ cat serverless.yml
service: hello

provider:
  name: kubeless
  runtime: python2.7

plugins:
  - serverless-kubeless

functions:
  hello:
    description: 'Hello function'
    handler: handler.hello

Download dependencies

$ npm install

Deploy function.

$ serverless deploy
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Deploying function hello...
Serverless: Function hello succesfully deployed

The function will be deployed to k8s via kubeless.

$ kubectl get function
NAME      KIND
hello     Function.v1.k8s.io

$ kubectl get po
NAME                     READY     STATUS    RESTARTS   AGE
hello-1815473417-1ttt7   1/1       Running   0          1m

Now you will be able to call the function:

$ serverless invoke -f hello -l
Serverless: Calling function: hello...
--------------------------------------------------------------------
hello world

You can also check the logs for the function:

$ serverless logs -f hello
172.17.0.1 - - [12/Jul/2017:09:47:18 +0000] "GET /healthz HTTP/1.1" 200 2 "" "Go-http-client/1.1" 0/118
172.17.0.1 - - [12/Jul/2017:09:47:21 +0000] "GET /healthz HTTP/1.1" 200 2 "" "Go-http-client/1.1" 0/93
172.17.0.1 - - [12/Jul/2017:09:47:24 +0000] "GET /healthz HTTP/1.1" 200 2 "" "Go-http-client/1.1" 0/108
172.17.0.1 - - [12/Jul/2017:09:47:25 +0000] "GET / HTTP/1.1" 200 11 "" "" 0/316

Or you can obtain the function information:

$ serverless info
Service Information "hello"
Cluster IP:  10.0.0.51
Type:  NodePort
Ports:
  Protocol:  TCP
  Port:  8080
  Target Port:  8080
  Node Port:  30018
Function Info
Description: Hello function
Handler:  handler.hello
Runtime:  python2.7
Trigger: HTTP
Dependencies:

If you are using minikube you can call directly the function through HTTP and the Node Port in which the function is running:

$ curl  http://192.168.99.100:30018
hello world

You can access the function through its HTTP interface as well using kubectl proxy and accessing:

$ curl http://127.0.0.1:8001/api/v1/namespaces/default/services/hello/proxy/
hello world

If you have a change in your function and you want to redeploy it you can run:

$ serverless deploy function -f hello
Serverless: Redeploying hello...
Serverless: Function hello succesfully deployed

Finally you can remove the function.

$ serverless remove
Serverless: Removing function: hello...
Serverless: Function hello succesfully deleted

serverless-kubeless's People

Contributors

andresmgot avatar sebgoa avatar ngtuna avatar jbianquetti-nami avatar

Stargazers

Roy avatar

Watchers

Julian Pistorius avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.