Giter VIP home page Giter VIP logo

openfaas-go-fn's Introduction

openfaas-go-fn

Sample OpenFaaS Go Function (classic template) ready to run as a Docker Dev Environment.

(Part of the blog post https://felipecruz.es/making-a-docker-dev-environment-for-openfaas/)

Getting started

This repository is configured to run as a Docker Dev Environment using the base image specified here.

Once you create a Docker Dev Environment, you won't have to download any further tools or dependencies to play around with this example.

You will have all the developer tooling to develop, build, and push your OpenFaaS function, baked within the development container. Note that you can also use kind to create a Kubernetes cluster in Docker to provision the infrastructure where to install OpenFaaS.

Update the Kubernetes API server address to your host's in kind.yml. This is needed for the dev container to communicate with the KinD cluster. Otherwise, kubectl commands against the API server won't work.

Provision the Kubernetes cluster

Create the Kubernetes cluster in Docker

kind create cluster --config=kind.yml

Install OpenFaaS

arkade install openfaas

Forward the gateway to your machine

kubectl rollout status -n openfaas deploy/gateway
kubectl port-forward -n openfaas svc/gateway 8080:8080 &

Login to OpenFaaS Gateway

# If basic auth is enabled, you can now log into your gateway:
PASSWORD=$(kubectl get secret -n openfaas basic-auth -o jsonpath="{.data.basic-auth-password}" | base64 --decode; echo)
echo -n $PASSWORD | faas-cli login --username admin --password-stdin

Visit http://127.0.0.1:8080/ to see the OpenFaaS Gateway.

Build and deploy your function

Build the function

faas-cli build -f go-fn.yml

Push the function. Make sure you run docker login inside the development container and update the username and repository name in go-fn.yml to yours. Remember to set up authentication in KinD to pull images from your newly created DockerHub repository or, otherwise, make the DockerHub repository public.

faas-cli push -f go-fn.yml

Deploy the function to the OpenFaaS Gateway

faas-cli deploy -f go-fn.yml

openfaas-go-fn's People

Contributors

felipecruz91 avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

trojanku

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.