goless

command module
v0.0.0-...-af31481 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

README

Goless

Goless is a serverless framework for Go functions on Kubernetes.

Deployment

You can use the Makefile, however if you have a recent version of kubectl it will be easier.

CRD setup

kubectl kustomize config/crd | kubectl apply -f -

Controller Deployment

kubectl kustomize config/default | kubectl apply -f -

Function Deployment

A sample function is in config/samples/sample.yaml

A Goless function looks like this:

apiVersion: goless.io/v1beta1
kind: Function
metadata:
  name: function-example
spec:
  service: "example"
  serverPort: 9000
  replicas: 1
  function: |
    package handlers
    import (
      "net/http"
    )
    func Handler(w http.ResponseWriter, r *http.Request) {
      w.Write([]byte("Hey this example works!"))
    }

Since this is the default Go HTTP package we can include middleware as well:

apiVersion: goless.io/v1beta1
kind: Function
metadata:
  name: function-example
spec:
  service: "example"
  serverPort: 9000
  replicas: 1
  function: |
    package handlers
    import (
      "net/http"
    )

    func Handler(w http.ResponseWriter, r *http.Request) {
      w.Header().Add("foo", "bar")

      Foo().ServeHTTP(w, r)

    }

    func Foo() http.HandlerFunc {
      return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
        w.Write([]byte("in handler"))
      })
    }
Metrics

Out of the box, Goless returns Prometheus metrics at /metrics with the number of function invocations, the number of requests per method, and number of errors per HTTP type.

Removal

CRDs

kubectl kustomize config/crd | kubectl delete -f -

Operator

kubectl kustomize config/default | kubectl delete -f -

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
api
v1beta1
Package v1beta1 contains API Schema definitions for the function v1beta1 API group +kubebuilder:object:generate=true +groupName=goless.io
Package v1beta1 contains API Schema definitions for the function v1beta1 API group +kubebuilder:object:generate=true +groupName=goless.io

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL