Giter Club home page Giter Club logo

faas-cli's Introduction

faas-cli

Build Status Go Report Card License: MIT OpenFaaS

faas-cli is the official CLI for OpenFaaS

Run a demo with faas-cli --help

The CLI can be used to build and deploy functions to OpenFaaS. You can build OpenFaaS functions from a set of supported language templates (such as Node.js, Python, CSharp and Ruby). That means you just write a handler file such as (handler.py/handler.js) and the CLI does the rest to create a Docker image.

New user? See how it works: Morning coffee with the faas-cli Already an OpenFaaS user? Try 5 tips and tricks for the OpenFaaS CLI

Get started: Install the CLI

You can install the CLI with a curl utility script, brew or by downloading the binary from the releases page. Once installed you'll get the faas-cli command and faas alias.

Utility script with curl:

$ curl -sSL https://cli.openfaas.com | sudo sh

Non-root with curl (requires further actions as advised after downloading):

$ curl -sSL https://cli.openfaas.com | sh

Via brew:

$ brew install faas-cli

Note: The brew release may not run the latest minor release but is updated regularly.

Via npm (coming soon):

$ npm install --global @openfaas/faas-cli

Note: See npm specific installation instructions and usage in the npm README.md

Windows

To install the faas-cli on Windows go to Releases and download the latest faas-cli.exe.

Or in PowerShell:

$version = (Invoke-WebRequest "https://api.github.com/repos/openfaas/faas-cli/releases/latest" | ConvertFrom-Json)[0].tag_name
(New-Object System.Net.WebClient).DownloadFile("https://github.com/openfaas/faas-cli/releases/download/$version/faas-cli.exe", "faas-cli.exe")

Build from source

The contributing guide has instructions for building from source and for configuring a Golang development environment.

Run the CLI

The main commands supported by the CLI are:

  • faas-cli new - creates a new function via a template in the current directory

  • faas-cli login - stores basic auth credentials for OpenFaaS gateway (supports multiple gateways)

  • faas-cli logout - removes basic auth credentials for a given gateway

  • faas-cli up - a combination of build/push and deploy

  • faas-cli build - builds Docker images from the supported language types

  • faas-cli push - pushes Docker images into a registry

  • faas-cli deploy - deploys the functions into a local or remote OpenFaaS gateway

  • faas-cli publish - build and push multi-arch images for CI and release artifacts

  • faas-cli remove - removes the functions from a local or remote OpenFaaS gateway

  • faas-cli invoke - invokes the functions and reads from STDIN for the body of the request

  • faas-cli store - allows browsing and deploying OpenFaaS store functions

  • faas-cli secret - manage secrets for your functions

  • faas-cli pro auth - initiates an OAuth2 authorization flow to obtain a token

  • faas-cli registry-login - generate registry auth file in correct format by providing username and password for docker/ecr/self hosted registry

The default gateway URL of 127.0.0.1:8080 can be overridden in three places including an environmental variable.

  • 1st priority --gateway flag
  • 2nd priority --yaml / -f flag or stack.yml if in current directory
  • 3rd priority OPENFAAS_URL environmental variable

For Kubernetes users you may want to set this in your .bash_rc file:

export OPENFAAS_URL=http://127.0.0.1:31112

Did you know? By setting FAAS_DEBUG=1, the CLI will print out the HTTP request that it's making to the OpenFaaS Gateway.

Advanced commands:

The default template URL of https://github.com/openfaas/templates.git can be overridden in two places including an environmental variable

  • 1st priority CLI input
  • 2nd priority OPENFAAS_TEMPLATE_URL environmental variable

Help for all of the commands supported by the CLI can be found by running:

  • faas-cli help or faas-cli [command] --help

You can chose between using a programming language template where you only need to provide a handler file, or a Docker that you can build yourself.

faas-cli pro auth

The auth command is only licensed for OpenFaaS Pro customers.

Use the auth command to obtain a JWT to use as a Bearer token.

code grant - default

Use this flow to obtain a token for interactive use from your workstation.

The code grant flow uses the PKCE extension.

At this time the token cannot be saved or retained in your OpenFaaS config file. You can pass the token using a CLI flag of --token=$TOKEN.

Example:

faas-cli pro auth \
  --auth-url https://tenant0.eu.auth0.com/authorize \
  --token-url https://tenant0.eu.auth0.com/oauth/token \
  --audience http://gw.example.com \
  --client-id "${OAUTH_CLIENT_ID}"
client_credentials grant

Use this flow for machine to machine communication such as when you want to deploy a function to a gateway that uses OAuth2 / OIDC.

Example:

faas-cli pro auth \
  --grant client_credentials \
  --auth-url https://tenant0.eu.auth0.com/oauth/token \
  --client-id "${OAUTH_CLIENT_ID}" \
  --client-secret "${OAUTH_CLIENT_SECRET}"\
  --audience http://gw.example.com
Environment variable substitution

The CLI supports the use of envsubst-style templates. This means that you can have a single file with multiple configuration options such as for different user accounts, versions or environments.

Here is an example use-case, in your project there is an official and a development Docker Hub username/account. For the CI server images are always pushed to exampleco, but in development you may want to push to your own account such as alexellis2.

functions:
  url-ping:
    lang: python
    handler: ./sample/url-ping
    image: ${DOCKER_USER:-exampleco}/faas-url-ping:0.2

Use the default:

$ faas-cli build
$ DOCKER_USER="" faas-cli build

Override with "alexellis2":

$ DOCKER_USER="alexellis2" faas-cli build

See also: envsubst package from Drone.

Build templates

Command: faas-cli new FUNCTION_NAME --lang python/node/go/ruby/Dockerfile/etc

In your YAML you can also specify lang: node/python/go/csharp/ruby

  • Supports common languages

  • Quick and easy - just write one file

  • Specify dependencies on Gemfile / requirements.txt or package.json etc

  • Customise the provided templates

Perhaps you need to have gcc or another dependency in your Python template? That's not a problem.

You can customise the Dockerfile or code for any of the templates. Just create a new directory and copy in the templates folder from this repository. The templates in your current working directory are always used for builds.

See also: faas-cli new --help

Third-party community templates

Templates created and maintained by a third-party can be added to your local system using the faas-cli template pull command.

Read more on community templates here.

Templates store

The template store is a great way to find official, incubator and third-party templates.

Find templates with: faas-cli template store list

Note: You can set your own custom store location with --url flag or set OPENFAAS_TEMPLATE_STORE_URL environmental variable

To pull templates from the store just write the name of the template you want faas-cli template store pull go or the repository and name faas-cli template store pull openfaas/go

To get more detail on a template just use the template store describe command and pick a template of your choice, example with go would look like this faas-cli template store describe go

Note: This feature is still in experimental stage and in the future the CLI verbs might be changed

HMAC

It is possible to sign a faas-cli invoke request using a sha1 HMAC. To do this, the name of a header to hold the code during transmission should be specified using the --sign flag, and the shared secret used to hash the message should be provided through --key. E.g.

$ echo -n OpenFaaS | faas-cli invoke env --sign X-Hub-Signature --key yoursecret

Results in the following header being added:

Http_X_Hub_Signature=sha1=2fc4758f8755f57f6e1a59799b56f8a6cf33b13f

Docker image as a function

Specify lang: Dockerfile if you want the faas-cli to execute a build or skip_build: true for pre-built images.

  • Ultimate versatility and control
  • Package anything
  • If you are using a stack file add the skip_build: true attribute
  • Use one of the samples as a basis

Read the blog post/tutorial: Turn Any CLI into a Function with OpenFaaS

faas-cli registry-login

This command allows to generate the registry auth file in the correct format in the location ./credentials/config.json

Prepare your Docker registry (if not using AWS ECR)

If you are using Dockerhub you only need to supply your --username and --password-stdin (or --password, but this leaves the password in history).

faas-cli registry-login --username <your-registry-username> --password-stdin
(then enter your password and use ctrl+d to finish input)

You could also have you password in a file, or environment variable and echo/cat this instead of entering interactively If you are using a different registry (that is not ECR) then also provide a --server as well.

Prepare your Docker registry (if using AWS ECR)

faas-cli registry-login --ecr --region <your-aws-region> --account-id <your-account-id>

Private registries

Use faas-cli in CI environments

If you're running faas-cli in a CI environment like Github Actions, CircleCI, or Travis, chances are you get the env var CI set to true.

If the CI env var is set to true or 1, faas-cli change the location of the OpenFaaS config from the default ~/.openfaas/config.yml to .openfaas/config.yml with elevated permissions for the config.yml and the shrinkwrapped build dir (if there is one).

This is really useful when running faas-cli as a container image. The recommended image type to use in a CI environment is the root variant, tagged with -root suffix. CI environments like Github Actions require you to use Docker images having a root user. Learn more about it here.

Use a YAML stack file

Read the YAML reference guide in the OpenFaaS docs.

Quick guide

A YAML stack file groups functions together and also saves on typing.

You can define individual functions or a set of them within a YAML file. This makes the CLI easier to use and means you can use this file to deploy to your OpenFaaS instance. By default the faas-cli will attempt to load stack.yaml from the current directory.

Here is an example file using the stack.yml file included in the repository.

provider:
  name: openfaas
  gateway: http://127.0.0.1:8080

functions:
  url-ping:
    lang: python
    handler: ./sample/url-ping
    image: alexellis2/faas-urlping

This url-ping function is defined in the sample/url-ping folder makes use of Python. All we had to do was to write a handler.py file and then to list off any Python modules in requirements.txt.

  • Build the files in the .yml file:
$ faas-cli build

-f specifies the file or URL to download your YAML file from. The long version of the -f flag is: --yaml.

You can also download over HTTP(s):

$ faas-cli build -f https://raw.githubusercontent.com/openfaas/faas-cli/master/stack.yml

Docker along with a Python template will be used to build an image named alexellis2/faas-urlping.

  • Deploy your function

Now you can use the following command to deploy your function(s):

$ faas-cli deploy

Access functions with curl

You can initiate a HTTP POST via curl:

  • with the -d flag i.e. -d "my data here"
  • or with --data-binary @filename.txt to send a whole file including newlines
  • if you want to pass input from STDIN then use --data-binary @-
$ curl -d '{"hello": "world"}' http://127.0.0.1:8080/function/nodejs-echo
{ nodeVersion: 'v6.9.1', input: '{"hello": "world"}' }

$ curl --data-binary @README.md http://127.0.0.1:8080/function/nodejs-echo

$ uname -a | curl http://127.0.0.1:8080/function/nodejs-echo--data-binary @-

For further instructions on the manual CLI flags (without using a YAML file) read manual_cli.md

Environment variable overrides

  • OPENFAAS_TEMPLATE_URL - to set the default URL to pull templates from
  • OPENFAAS_PREFIX - for use with faas-cli new - this can act in place of --prefix
  • OPENFAAS_URL - to override the default gateway URL
  • OPENFAAS_CONFIG - to override the location of the configuration folder, which contains auth configuration.
  • CI - to override the location of the configuration folder, when true, the configuration folder is .openfaas in the current working directory. This value is ignored if OPENFAAS_CONFIG is set.

Contributing

See contributing guide.

License

Portions of this project are licensed under the OpenFaaS Pro EULA.

The remaining source unless annotated is licensed under the MIT License.

faas-cli's People

Contributors

abhayvatoo avatar alexellis avatar amirkarimi avatar austinfrey avatar burtonr avatar dependabot[bot] avatar developius avatar doowb avatar ericstoekl avatar ewilde avatar imumesh18 avatar itscaro avatar ivanayov avatar johnmccabe avatar kenfdev avatar leodido avatar lucasroesler avatar martindekov avatar nenadilic84 avatar nicholasjackson avatar nikhilsharmawe avatar nitishkumar71 avatar rgee0 avatar stefanprodan avatar tommysolsen avatar utsavanand2 avatar viveksyngh avatar waterdrips avatar welteki avatar yankeexe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

faas-cli's Issues

Proposal: Wrap 'docker service' commands for the OpenFaaS CLI

Expected Behaviour

Currently to look at deployed OpenFaaS commands we have to use things like:

  • docker service ls
  • docker service ps <function_name>
  • docker service logs <function_name>

While this is fine if you understand the underlying technologies, it adds another barrier of entry for new users, and another difference in usability between backends.

Wrapping this functionality in a common way into the faas-cli would simplify this, and make it more 'directly discoverable' without having to go and look up additional documentation:

  • faas-cli ls (or faas-cli ls -f stack.yml)
  • faas-cli ps <function_name> (or faas-cli ps -f stack.yml <function_name>)
  • faas-cli logs <function_name> (or faas-cli logs -f stack.yml <function_name>)

Ideally, these commands would largely mirror their docker alternatives, but remove any 'extraneous' stuff that can be hidden away by OpenFaaS (in a similar way to how docker compose hides away extra details that could be manually specified with the raw docker equivalent)

Proposal: Add init/new/create commands to the CLI

It would be nice if all of the required 'knowledge' for creating a new function/etc was built into the command line, with something akin to faas-cli init funcName

Expected Behaviour

Be able to create a new function/etc with ease from the command line

Current Behaviour

Need to read through a lot of different places to understand how to create a new function.

Possible Solution

Add init/new/create commands to the CLI that walk a new user through creating a new function, or setting up a stack. Ideally this would allow parameters to be passed directly on the command line, and if they are missing, to 'guide' the user through the process. eg

faas-cli new function

Name []: foo-func
Language [python]: golang 
etc

The available 'templates' would be those currently usable, with optional support for pulling remote repos (such as a 3rd party template on github)

Additionally, it would be good to be able to setup a FaaS gateway stack as easy as we can do docker swarm init.

Steps to Reproduce (for bugs)

N/A

Context

When starting a new OpenFaaS based project, there are numerous steps to getting started, that currently seem to require reading a bunch of README's, samples, and blog posts. Minimising this to as few 'built in' steps would ease the onboarding requirement for new users.

Your Environment

  • Docker version docker version (e.g. Docker 17.0.05 ): 17.06.1-ce

  • Are you using Docker Swarm or Kubernetes (FaaS-netes)? Swarm

  • Operating System and version (e.g. Linux, Windows, MacOS): MacOS

  • Link to your project or a code example to reproduce issue: N/A

Swarm - deploy prefers remote registry image over local one

Expected Behaviour

If I edit the sample url-ping python handler in sample/url-ping/handler.py, run faas-cli build -f ./samples.yml I can see a new latest image is created alexellis/faas-url-ping:latest.

I would expect that running faas-cli deploy -f ./samples.yml would use the local alexellis/faas-url-ping:latest image.

Current Behaviour

What appears to happen is that the local images are removed and latest is pulled from Docker hub.

Possible Solution

Steps to Reproduce (for bugs)

  1. Edit sample/url-ping/handler.py, add a new print statement
  2. Remove any existing function faas-cli remove url-ping
  3. Build the samples faas-cli build -f ./samples.yml
  4. Check the image contains your updates docker run -ti --rm alexellis/faas-url-ping sh
  5. Deploy the samples faas-cli build -f ./samples.yml
  6. Hit the url-ping end point and see that your changes aren't applied, check the images and see that the newly build image has been replaced with the latest from the hub docker images | grep ping.

Context

This behaviour is counter-intuitive when developing and complicates dev when updating functions that have been pushed to the hub.

Your Environment

  • Docker version docker version (e.g. Docker 17.0.05 ):
    17.06.1-ce
  • Are you using Docker Swarm or Kubernetes (FaaS-netes)?
    Swarm
  • Operating System and version (e.g. Linux, Windows, MacOS):
    MacOS
  • Link to your project or a code example to reproduce issue:
    Using the samples from faas-cli

Docs using ./faas-cli instead of faas-cli

Simple documentation fix in Readme.md to change it from ./faas-cli to faas-cli so it doesn't confuse beginners.

Context

Your Environment

  • Docker version docker version (e.g. Docker 17.0.05 ):

  • Are you using Docker Swarm or Kubernetes (FaaS-netes)?

  • Operating System and version (e.g. Linux, Windows, MacOS):

  • Link to your project or a code example to reproduce issue:

Proposal - filter functions in stacks

Expected Behaviour

If a stack has 10 functions but I only want to build one (by name) - then I should be able to do this:

$ faas-cli build -f stack.yml --filter "payroll"

Applies to:

  • delete, build, deploy, push

Issue - function sub-folders are not copied recursively

Expected Behaviour

All / any assets such as a "src" or "samples" folder should be copied into the final image.

Current Behaviour

Only files in the root directory are copied in

Possible Solution

Seems as simple as setting a flag to "true" in the builder.

Proposal: use Makefile to run shell scripts

Use Makefile instead of shell scripts

Expected Behaviour

Tasks are organized in makefiles folder along with the main Makefile at root.
Current scripts will call the corresponding makefile rule in order to maintain backward compatibility.

build.sh calls make build
build_redist.sh calls make build_redist
test/version.sh calls make test_version
deploy_samples calls make deploy_samples

make test runs go test in docker image to test against a specific version of Go

on faas-cli -action deploy: dial tcp 127.0.0.1:8080: getsockopt: connection refused

When attempting to deploy a function with faas-cli -action deploy -f ./urlping.yaml I get the following error message:

~/github/faas-cli$ sudo ./faas-cli -action deploy -f ./urlping.yaml 
Deploying: url_ping.
Error removing existing function: Delete http://localhost:8080/system/functions: dial tcp 127.0.0.1:8080: getsockopt: connection refused, gateway=http://localhost:8080, functionName=url_ping
Is FaaS deployed? Do you need to specify the -gateway flag?
Post http://localhost:8080/system/functions: dial tcp 127.0.0.1:8080: getsockopt: connection refused

The file, urlping.yaml, is as described in the README.md example file.

This happens with both the faas-cli downloaded from https://cli.openfaas.com, or one which I have compiled from this repo.

Expected Behaviour

Deploys function

Current Behaviour

Produces output pasted above

Possible Solution

Steps to Reproduce (for bugs)

  1. Follow readme until faas-cli -action deploy -f ./urlping.yaml
  2. run faas-cli -action deploy -f ./urlping.yaml

Context

Your Environment

  • Docker version docker version (e.g. Docker 17.0.05 ):
    17.06.1-ce
  • Are you using Docker Swarm or Kubernetes (FaaS-netes)?
    no
  • Operating System and version (e.g. Linux, Windows, MacOS):
    ubuntu 16.04
  • Link to your project or a code example to reproduce issue:

Proposal: Add template for golang functions

Expected Behaviour

Currently there are templates for: csharp, node, python, ruby. It would be great to have a go template as well.

There is a golang base function in the main FaaS repository that can be used as a base. Though this could be improved even more using Docker multi-stage build syntax, and separating the golang compilation environment from the run environment (eg. static compilation)

The faas-cli new command would also need to be updated to include this new template.

Should have - "Custom" template type

Expected Behaviour

It should be possible to "build" a function which isn't using one of the known / supported template types. An example would be the shrink_image example in the repo.

Snippet:

  shrink-image:
    lang: Dockerfile
    handler: ./samples/image-magick
    image: functions/resizer
    fprocess: "convert - -resize 50% fd:1"

The context is whatever is in the handler folder and the Dockerfile in the root of the directory will be used for the build.

Current Behaviour

Build manually and remove the lang element then mark the item as skip_build

Possible Solution

When setting the language to custom then a docker build is invoked in the handler folder directly.

Context

This will add versatility - especially for languages which don't suit dynamic templating like Golang.

Enhancement - CLI should support function deletion

Issue

It is not possible to delete functions via the FaaS CLI.

Proposed fix

Extend faas-cli with the ability to delete a specified function.

Suggest we do do after #17 has been implemented and do so via the faas-cli delete <fn> verb based approach.

Proposal: third-party templates via GitHub

Expected Behaviour

Anyone should be able to download a community-supported 3rd party template for Perl, PHP, Kotlin etc.

Current Behaviour

PRs to main project.

Possible Solution

I'm open to input on this too.

$ faas-cli add-template https://github.com/alexellis/kotlin-template

Downloading https://github.com/alexellis/kotlin-template/master/blob/master.zip
Expanding kotlin/Dockerfile to template/kotlin/Dockerfile
...

Repo structure:

./template/kotlin/Dockerfile
./template/kotlin/handler.java
./README.md

Initial version of this can be a "dumb" shortcut to download a zip file and unzip into a directory.

Out of scope for v1:

  • Listing templates installed locally
  • Online directory of templates

Mentions: @johnmccabe and others for the suggestion. @nicholasjackson how does Hashicorp do this?

Other files which need changes:
#82 (comment)

fprocess needs to come out of the Golang code and sit in a template.yml file within i.e. ./template/kotlin/template.yml

language: kotlin
fprocess: kotlin handler.kotlin

Add Clojure as supported language

Hi, as Clojure is a great functional language (of the lisp family, you know with lot of parenthesis), I was thinking of adding a template for it in OpenFaaS.

Some of the benefits of Clojure:

  • based on Lisp
  • relies on the standard JVM platform
  • use JVM but do not have to write Java code :)
  • real functional language with immutable data structures
  • designed for concurrency
  • more at https://clojure.org/about/rationale

When building an application, the project.clj file defines the dependencies. It contains metadata and deps. For instance:

(defproject clojure-echo "0.1.0-SNAPSHOT"
  :description "echo function"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.7.0"]]
  :main ^:skip-aot clojure-echo.core
  :target-path "target/%s"
  :profiles {:uberjar {:aot :all}})

Those dependencies are installed with 'lein deps'.

To benefit from the cache when building the image, the deps can be downloaded and installed beforehand. The application can then be built and run as a jar.

build action template download/extraction fails on Windows

Expected Behaviour

Build should "just work"

Current Behaviour

Fails with:

C:\Users\alex\Desktop\faas\sample-functions\ipconfig>.\faas-cli.exe build -f stack.yml
2017/09/12 05:57:49 No templates found in current directory.
2017/09/12 05:57:49 HTTP GET https://github.com/alexellis/faas-cli/archive/master.zip
2017/09/12 05:57:51 Writing 200Kb to master.zip
2017/09/12 05:57:51 Attempting to expand templates from master.zip
Found template/.
Writing 0 bytes to template/.
2017/09/12 05:57:51 Unable to download templates from Github.
2017/09/12 05:57:51 Could not pull templates for OpenFaaS. open template/: is a directory

Note this has been around for a while, reproduced on current release and old 0.4.8

Possible Solution

Steps to Reproduce (for bugs)

  1. Build a sample function on windows

Context

User experience on Windows is compromised

Your Environment

  • Docker version docker version (e.g. Docker 17.0.05 ):
    Docker 17.06.1-ce

  • Are you using Docker Swarm or Kubernetes (FaaS-netes)?
    Swarm

  • Operating System and version (e.g. Linux, Windows, MacOS):
    Windows 10

Docker Swarm issue - Address in use (upstream issue)

When re-deploying a function (aka Docker Swarm Service) we can get an error "Address in use - unable to allocate container" or similar.

I've raised the issue upstream but it's been open 30 days already. I don't believe the issue occurs when using Kubernetes as a back-end.

moby/moby#34163

The Docker swarm work-around appears to be to deploy again after a few seconds or to use docker service rm via the Docker CLI first.

I think this might also be fixed with a restart policy of > 1.

https://github.com/alexellis/faas/blob/master/gateway/handlers/functionshandler.go#L189

Calling function created with `csharp` template results in error

When I try to call a function created with the C# template, I get the following result:

$ curl http://localhost:8080/function/csharp-hello-app -d "stuff"
exit status 145
Did you mean to run dotnet SDK commands? Please install dotnet SDK from: 
  http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409

This error code apparently indicates that the image that is built does not have the SDK installed. (https://stackoverflow.com/questions/42346498/dotnet-aspnetcore-docker-build-fails-with-a-145-error-code)

Are others seeing this issue? I'm deploying by adding the following to ./samples.yml:

  functions:
    csharp-hello-app:
      lang: csharp
      handler: ./sample/csharp-hello
      image: yourname/csharp-hello-app

Expected Behaviour

Csharp app echos input.

Current Behaviour

Returns exit status 145

Possible Solution

Steps to Reproduce (for bugs)

  1. Copy the following into the functions: block of your yaml file:
    csharp-hello-app:
      lang: csharp
      handler: ./sample/csharp-hello
      image: yourname/csharp-hello-app
  1. run faas-cli build -f <yourfile.yaml>
  2. run faas-cli deploy -f <yourfile.yaml>
  3. curl http://localhost:8080/function/csharp-hello-app -d "stuff"

Context

Your Environment

  • Docker version docker version (e.g. Docker 17.0.05 ):
    17.06.1-ce
  • Are you using Docker Swarm or Kubernetes (FaaS-netes)?
    swarm
  • Operating System and version (e.g. Linux, Windows, MacOS):
    ubuntu 16.04
  • Link to your project or a code example to reproduce issue:

cli hanging on deploy command

Running through the demo commands in the README. Install seemed to go fine as did build the sample functions with faas-cli -action build -f ./samples.yml

When deploy though, it seems to hang.
faas-cli -action deploy -f ./samples.yml
...hangs with Deploying: url_ping.

This is on x86 architecture and Docker 17.06.0-ce.

Research item: anonymous usage analytics

Expected Behaviour

Track usage of commands (verbs), parameters (used), build times and other anonymous data that can help us understand usage and improve the CLI.

Remit:

  • This would only cover the CLI usage - this would not instrument the back-end services.

  • Opt-in by default, opt-out of collection via environmental variable in a similar fashion to VSCode and Brew.

.bash_profile

export OPEN_FAAS_TELEMETRY=0
  • We must explain how data is used, how long it is kept for etc and make sure it's in keeping with data protection.

  • Data must be anonymised

Current Behaviour

Relying on unsolicited feedback / word of mouth

Possible Solution

Google Analytics (subject to costing out) - has a Golang library. https://github.com/google/google-api-go-client/blob/master/analytics/v3/analytics-gen.go

Initial work would only be a PoC

CLI can't successfully deploy to 'custom' named stack

Expected Behaviour

When I deploy a command to my custom named stack, it works (or gives me an error saying it can't)

Current Behaviour

The CLI claims to successfully deploy the command, but it doesn't work. There is an error in the logs of the gateway. The CLI appears to have hardcoded the name:

⇒  docker service logs openfaas_gateway
..snip..
openfaas_gateway.1.5v3xwo4u9mvb@moby    | 2017/09/14 00:19:43 Error response from daemon: network func_functions not found

https://github.com/alexellis/faas-cli/blob/3a2e81471c69275571d71f84c158bb787fb1ad7b/proxy/deploy.go#L44

There also seems to be a defaultNetwork defined that may not be used anywhere yet:

https://github.com/alexellis/faas-cli/blob/fa5668b52afea6fc90434d67cfe211572da03cbd/commands/faas.go#L12

Possible Solution

Allow the network to be specified in the CLI. Return a proper error when deploys fail. Investigate whether the gateway can determine the correct network itself, without relying on the CLI telling it.

Steps to Reproduce (for bugs)

  1. Create a new network stack, change the stack name and network name
  2. Try and deploy an image with the CLI
  3. Check the gateway logs

Context

Your Environment

⇒  docker --version
Docker version 17.06.2-ce, build cec0b72
⇒  faas-cli version
Git Commit: 118e3e904aa930cafdb64f0efd4538c76fb27088

Bump Golang version to 1.8.x

Expected Behaviour

We need to start moving the FaaS projects to 1.8.x. The CLI has the least complex dependency-set so let's start here.

Current Behaviour

We're using 1.7.x for x86 and ARM.

Possible Solution

  • Update Dockerfiles to best available 1.8.x version
  • Run unit tests
  • Do integration testing with Docker Swarm and K8s

GitCommit in commands package not being updated at build time

Expected Behaviour

This results in the following output for a brew installed CLI:

$ ./faas-cli version
Git Commit: thisisavalidsha

Current Behaviour

Following the merge of #50 and the move of the GitCommit variable from the old main package rather than commands package this commit SHA isn't getting populated.

This results in the following output:

$ ./faas-cli version
Git Commit:

Possible Solution

Steps to Reproduce (for bugs)

  1. Download the current 0.4.9 release, or build locally using build_redist.sh and run ./faas-cli version

Context

Your Environment

  • Docker version docker version (e.g. Docker 17.0.05 ):
    n/a

  • Are you using Docker Swarm or Kubernetes (FaaS-netes)?
    n/a

  • Operating System and version (e.g. Linux, Windows, MacOS):
    MacOS

  • Link to your project or a code example to reproduce issue:
    n/a

Proposal: Improve version command

Expected Behaviour

./faas-cli version
  ___                   _____           ____
 / _ \ _ __   ___ _ __ |  ___|_ _  __ _/ ___|
| | | | '_ \ / _ \ '_ \| |_ / _` |/ _` \___ \
| |_| | |_) |  __/ | | |  _| (_| | (_| |___) |
 \___/| .__/ \___|_| |_|_|  \__,_|\__,_|____/
      |_|

Version: dev-86370e8

./faas-cli version --short-version
dev-86370e8

./faas-cli version
  ___                   _____           ____
 / _ \ _ __   ___ _ __ |  ___|_ _  __ _/ ___|
| | | | '_ \ / _ \ '_ \| |_ / _` |/ _` \___ \
| |_| | |_) |  __/ | | |  _| (_| | (_| |___) |
 \___/| .__/ \___|_| |_|_|  \__,_|\__,_|____/
      |_|

Version: 0.4.14-alpha-8f2ae9c

./faas-cli version --short-version
Version: 0.4.14-alpha-8f2ae9c

Current Behaviour

Version contains only SHA1

Context

Provide a more human-readable version info, easier for people to report their version

Your Environment

go 1.8.3 linux/amd64
docker 17.06.2-ce

Proposal: Add support for PHP

Expected Behaviour

Add template for PHP in order to support built-in build for PHP

Your Environment

Docker Version: 17.06.1-ce
Go version: go1.8.3
OS/Arch: linux/amd64

Support overriding function's Dockerfile

Considering the below mxnet.yml file to build and deploy my function (code residing under a sample/mxnet folder):

provider:
  name: faas
  gateway: http://localhost:8080
  network: "func_functions" # this is optional and defaults to func_functions

functions:
  mxnet:
    lang: python
    handler: ./sample/mxnet
    image: jmkhael/faas-mxnet

I would like to have a way to tell faas-cli to use a specific Dockerfile (e.g. under sample/mxnet) instead of the default lang template one.

faas-cli -action build -f ./sample/mxnet/mxnet.yml

Cli: open ./template/python: no such file or directory error

I'm trying to build a python example using the tutorial https://blog.alexellis.io/first-faas-python-function/ and the moment I call:

$ faas-cli -action build -f ./stack.yml

I get:

open ./template/python: no such file or directory error

is there anything that I miss?

Expected Behaviour

$ faas-cli -action build -f ./stack.yml
...

Successfully tagged faas-hello-python:latest  
Image: faas-hello-python built.  

Current Behaviour

➜  functions cat stack.yml
provider:
  name: faas
  gateway: http://localhost:8080

functions:
  hello-python:
    lang: python
    handler: ./hello-python
    image: faas-hello-python
➜  functions cat hello-python/handler.py
def handle(req):
    print("Hello! You said: " + req)
    %
➜  functions faas-cli -action build -f ./stack.yml
Building: hello-python.
Clearing temporary build folder: ./build/hello-python/
Preparing ./hello-python/ ./build/hello-python/function
2017/09/14 08:57:26 open ./template/python: no such file or directory

Possible Solution

Steps to Reproduce (for bugs)

Context

I was trying to follow the tutorial steps from here:
https://blog.alexellis.io/first-faas-python-function/

Your Environment

  • Docker version docker version (e.g. Docker 17.0.05 ):
➜  functions docker version
Client:
 Version:      17.06.2-ce
 API version:  1.30
 Go version:   go1.8.3
 Git commit:   cec0b72
 Built:        Tue Sep  5 20:12:06 2017
 OS/Arch:      darwin/amd64

Server:
 Version:      17.06.2-ce
 API version:  1.30 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   cec0b72
 Built:        Tue Sep  5 19:59:19 2017
 OS/Arch:      linux/amd64
 Experimental: true
  • Are you using Docker Swarm or Kubernetes (FaaS-netes)?
    Docker swarm
  • Operating System and version (e.g. Linux, Windows, MacOS):
➜  functions uname -a
Darwin C02SG3FQFVH6 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64
  • Link to your project or a code example to reproduce issue:

faas-cli push made it so that I couldn't update my container

I am working on the faas-and-furious/youtube-dl function. My workflow was:

  1. Push docker image to docker hub with faas-cli push -f <yaml>
  2. Update function entry.sh file
  3. Retry faas-cli build -f <yaml>; faas-cli deploy -f <yaml>, and the function is not updated!

My current version of the code: https://github.com/faas-and-furious/youtube-dl

The only way I can get my image to reflect the new state of the youtube-dl function is to name the image something different in the YAML file.

I tried build with --no-cache and it doesn't work either.

Also, If I do faas-cli push -f <YAML>, it will show Layer already exists for every line.

The yaml file is:

provider:
  name: faas
  gateway: http://localhost:8080

functions:
  youtube-dl:
    lang: Dockerfile
    handler: ./youtube-dl
    image: ems5311/youtube-dl:latest

Expected Behaviour

Current Behaviour

Possible Solution

Steps to Reproduce (for bugs)

Context

Your Environment

  • Docker version docker version (e.g. Docker 17.0.05 ):

  • Are you using Docker Swarm or Kubernetes (FaaS-netes)?

  • Operating System and version (e.g. Linux, Windows, MacOS):

  • Link to your project or a code example to reproduce issue:

Proposal: Mock HTTP client for testing

Update - I have found a much better way of doing this, now available at #66

I have created a mock HTTP mode for the faas-cli build command, that swaps out the real http client Do() method for a fake version when it is called in fetch_templates.go, for the purpose of downloading the master.zip file. Please check out this change at my forked branch:

ericstoekl@16585bc

What this change does is creates an interface called HttpClient, which the fetchMasterZip() function will use to get the zip file from github. When the --mock-http flag is passed in, then the ClientMock type will be used for the HttpClient, which implements a fake version of the Do() method. When you run fetchMasterZip(), it will then fetch the fake master.zip file.

The builder.BuildImage() call in commands/build.go will be skipped when the --mock-http flag is set.

This is just a PoC. A potentially better way to do this is to create a mock server with httptest, then use a handler function for both real and fake http calls.

Thanks,
Erich

Should have - templates for other platforms like armv7/armv8

Maybe the FaaS CLI should look at the uname on a local machine to decide whether to use the armv7 or armv8 templates.

i.e.

templates/armv6/node
templates/armv8/python

The main part of a template that needs to change is the line that picks up the watchdog binary and the base Docker image.

Proposal: Default to a 'well-known' named stack file

Expected Behaviour

In a similar vein to docker compose it would be nice if faas-cli defaulted to a well-known, named yaml file (eg openfaas.yml or similar) If it did, it wouldn't be a requirement to specify -f foo.yaml on each CLI command.

Proposal: Support multiple template versions - i.e. Python 2 + 3 separately

I have started to work on providing a PHP template and I'd like to ensure support for PHP 5 and 7 (This proposal is also relevant for Python 2/3)

I'd like to propose that we add an additional parameter, either version or language_version

I considered having a template for each and avoiding additional changes, but as very little would be different across the templates, I think it's better to provide the additional parameter.

As the template library grows, the version parameter would also allow keen developers to benchmark / test / dabble with newer, but potentially breaking, versions of their run-time.

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.