GithubHelp home page GithubHelp logo

rosiemarry / faas-o6s Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hydpublic/faas-o6s

1.0 0.0 0.0 26.43 MB

Kubernetes CRD & Controller for OpenFaaS

License: MIT License

Shell 1.33% Go 98.43% Makefile 0.24%

faas-o6s's Introduction

faas-o6s

Go Report Card Build Status GoDoc License: MIT OpenFaaS

OpenFaaS Kubernetes CRD Controller

Deploy

Deploy OpenFaaS with faas-netes:

git clone https://github.com/openfaas/faas-netes
cd faas-netes
kubectl apply -f ./namespaces.yml,./yaml

Deploy the Gateway with faas-o6s sidecar in openfaas namespace:

# CRD
kubectl apply -f artifacts/o6s-crd.yaml
# RBAC
kubectl apply -f artifacts/o6s-rbac.yaml
# Deployment (use o6s-armhf.yaml for faas-netes/yaml_armhf)
kubectl apply -f artifacts/o6s-amd64.yaml
# Delete faas-netes
kubectl -n openfaas delete deployment faas-netesd
kubectl -n openfaas delete svc faas-netesd

Deploy a function with kubectl:

kubectl -n openfaas-fn apply -f ./artifacts/nodeinfo.yaml

On armhf use:

kubectl -n openfaas-fn apply -f ./artifacts/figlet-armhf.yaml

List functions, services, deployments and pods:

kubectl -n openfaas-fn get functions
kubectl -n openfaas-fn get all

Deploy a function with secrets:

kubectl -n openfaas-fn create secret generic faas-token --from-literal=faas-token=token
kubectl -n openfaas-fn create secret generic faas-key --from-literal=faas-key=key
kubectl -n openfaas-fn apply -f ./artifacts/gofast.yaml

Test that secrets are available inside the gofast pod:

kubectl -n openfaas-fn exec -it gofast-84fd464784-sd5ml -- sh

~ $ cat /run/secrets/faas-key 
key

~ $ cat /run/secrets/faas-token 
token

Test that node selectors work on GKE by adding the following to gofast.yaml:

  constraints:
    - "cloud.google.com/gke-nodepool=default-pool"

Apply the function and check the deployment specs with:

kubectl -n openfaas-fn describe deployment gofast

Local run

Create OpenFaaS CRD:

$ kubectl apply -f artifacts/o6s-crd.yaml

Start OpenFaaS controller (assumes you have a working kubeconfig on the machine):

$ go build \
  && ./faas-o6s -kubeconfig=$HOME/.kube/config -logtostderr=true -v=4

With go run

$ go run *.go -kubeconfig=$HOME/.kube/config -logtostderr=true

To use an alternative port set the port environmental variable to another value.

Create a function:

$ kubectl apply -f artifacts/nodeinfo.yaml

Check if nodeinfo deployment and service were created through the CRD:

$ kubectl get deployment nodeinfo
$ kubectl get service nodeinfo

Test if nodeinfo service can access the pods:

$ kubectl run -it --rm --restart=Never curl --image=byrnedo/alpine-curl --command -- sh
/ # curl -d 'verbose' http://nodeinfo.default:8080

Delete nodeinfo function:

kubectl delete -f artifacts/nodeinfo.yaml 

Check if nodeinfo pods, rc, deployment and service were removed:

kubectl get all

API calls

Create or update a function:

curl -d '{"service":"nodeinfo","image":"functions/nodeinfo:burner","envProcess":"node main.js","labels":{"com.openfaas.scale.min":"2","com.openfaas.scale.max":"15"},"environment":{"output":"verbose","debug":"true"}}' -X POST  http://localhost:8081/system/functions

List functions:

curl -s http://localhost:8081/system/functions | jq .

Scale PODs up/down:

curl -d '{"serviceName":"nodeinfo", "replicas": 3}' -X POST http://localhost:8081/system/scale-function/nodeinfo

Get available replicas:

curl -s http://localhost:8081/system/function/nodeinfo | jq .availableReplicas

Remove function:

curl -d '{"functionName":"nodeinfo"}' -X DELETE http://localhost:8081/system/functions

Logging

Verbosity levels:

  • -v=0 CRUD actions via API and Controller including errors
  • -v=2 function call duration (Proxy API)
  • -v=4 Kubernetes informers events (highly verbose)

Instrumentation

Prometheus route:

curl http://localhost:8081/metrics

Profiling is disabled by default, to enable it set pprof environment variable to true.

Pprof web UI can be access at http://localhost:8081/debug/pprof/. The goroutine, heap and threadcreate profilers are enabled along with the full goroutine stack dump.

Run the heap profiler:

go tool pprof goprofex http://localhost:8081/debug/pprof/heap

Run the goroutine profiler:

go tool pprof goprofex http://localhost:8081/debug/pprof/goroutine

faas-o6s's People

Contributors

stefanprodan avatar alexellis avatar

Stargazers

rosiemarry 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.