GithubHelp home page GithubHelp logo

danbev / js-function-operator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from openshift-cloud-functions/js-function-operator

0.0 2.0 0.0 27.79 MB

R&P for an operator to deploy and execute Node.js functions as Knative Services on Kubernetes

License: MIT License

Dockerfile 0.66% Shell 5.47% Go 93.86%

js-function-operator's Introduction

JSFunction Operator

A Kubernetes Operator for JavaScript functions

This project provides a Kubernetes Operator for managing a JSFunction custom resource. A JSFunction accepts a JavaScript function inline, as well as an optional inline pakcage.json.

When a JSFunction resource is applied to a cluster, the controller takes the following steps during reconciliation.

  • Check to see if a Knative Service for this function exists. If not, create one.
  • Create a ConfigMap containing with the user supplied data (index.js/package.json)
  • Create a TaskRun, installing any dependencies and building a runtime image using lanceball/js-runtime
  • Create a PodSpec for the Service specifying the runtime image just created
  • Wires up knative eventing, if events is set to true in a JSFunction custom resource. Knative Eventing objects Subscription and Channel are created and acts as a sink for the function. Events sent to the Channel are passed to the function.

This is still in early stages of development and may change rapidly.

Running the operator

This project has been developed using OpenShift 4.x - both on an AWS cluster, as well as with Code Ready Containers. To run it in your environment, you can either use operator-sdk up local for testing, or deploy using operator.yaml.

Operator dependencies

The project uses Knative Serving and Eventing, as well as OpenShift Pipelines. Be sure you have these installed in your namespace.

Deploy the operator

Be sure you are logged in to your cluster, then run the following commands.

./deploy/deploy.sh

This will set up a service account with appropriate roles, add the JSFunction type and a build Task for the function, and finally deploy the operator to the current namespace.

Note privileges for the service account

Among the things that happen when a new JSFunction is created, is that a build task involving the creation of runtime images runs. This requires permissions not available by default on OpenShift. These permissions are added to the js-function-operator service account with the following commands when you run ./deploy/deploy.sh.

oc adm policy add-role-to-user edit -z js-function-operator
oc adm policy add-scc-to-user privileged -z js-function-operator

To deploy a function, run

kubectl apply -f deploy/crds/faas_v1alpha1_jsfunction_cr.yaml

Testing the Knative Eventing wiring

Set events to true in a JSFunction custom resource and deploy this CR.

To emit events to the automatically created Channel, run command specified below. This will emit event every minute.

kubectl apply -f hack/cronjob-source.yaml

js-function-operator's People

Contributors

lance avatar zroubalik avatar slinkydeveloper avatar rhuss avatar

Watchers

James Cloos avatar  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.