Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

faas-flow-tower not monitoring the flows #47

Open
Abhishekghosh1998 opened this issue Oct 13, 2023 · 1 comment
Open

faas-flow-tower not monitoring the flows #47

Abhishekghosh1998 opened this issue Oct 13, 2023 · 1 comment

Comments

@Abhishekghosh1998
Copy link

Abhishekghosh1998 commented Oct 13, 2023

I am struggling to set up the faas-flow-tower utility.

Let's say what I tried...
I tried setting up a simple flow-test function as follows:

flow-test.yml:

version: 1.0
provider:
  name: openfaas
  gateway: http://127.0.0.1:9999
functions:
  flow-test:
    lang: faas-flow
    handler: ./flow-test
    image: localhost:5000/flow-test:latest
    labels:
      faas-flow: 1
    annotations:
      faas-flow-desc: "test flow to greet"
    environment_file:
      - flow.yml
    secrets:
      - s3-secret-key
      - s3-access-key

flow.yml:

environment:
  gateway: "gateway.openfaas:8080" # The address of OpenFaaS gateway
  enable_tracing: true # tracing allows to monitor requests
  trace_server: "jaeger-agent.faasflow:5775" # The address of jaeger tracing agent
  consul_url: "consul.faasflow:8500" # The address of consul
  s3_url: "minio.faasflow:9000" # The address of minio

flow-test/handler.go:

package function

import (
	faasflow "github.com/faasflow/lib/openfaas"
)

// Define provide definition of the workflow
func Define(flow *faasflow.Workflow, context *faasflow.Context) (err error) {
	flow.SyncNode().Modify(func(data []byte) ([]byte, error) {
		result := "Hello " + string(data)
		return []byte(result), nil
	})
	return nil
}

// OverrideStateStore provides the override of the default StateStore
func OverrideStateStore() (faasflow.StateStore, error) {
	// NOTE: By default FaaS-Flow use consul as a state-store,
	//       This can be overridden with other synchronous KV store (e.g. ETCD)
	return nil, nil
}

// OverrideDataStore provides the override of the default DataStore
func OverrideDataStore() (faasflow.DataStore, error) {
	// NOTE: By default FaaS-Flow use minio as a data-store,
	//       This can be overridden with other synchronous KV store
	return nil, nil
}
$ faas-cli up -f flow-test.yml
...
Deploying: flow-test.

Deployed. 202 Accepted.
URL: http://127.0.0.1:9999/function/flow-test
$ echo "Abhishek" | faas-cli invoke flow-test
Hello Abhishek

So far so good.


The problem happens when I try to use faas-flow-tower.

faas-flow-tower/conf.yml:

  environment:
  basic_auth: true
  gateway_public_uri: "http://localhost:9999"
  gateway_url: "http://gateway.openfaas:8080/"
  secret_mount_path: "/var/openfaas/secrets"
  trace_url: "http://jaeger-query.faasflow:16686/"

In the above file I made change to the gateway_public_uri

faas-flow-tower/stack.yml:

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

functions:
  # dashboard
  faas-flow-dashboard:
    lang: dockerfile
    handler: ./dashboard
    image: localhost:5000/faas-flow-dashboard:3.0.8
    environment:
      read_debug: true
      write_debug: true
      combine_output: false
    environment_file:
      - conf.yml
    secrets:
      - basic-auth
    labels:
      com.openfaas.scale.zero: "false"

  # list flow functions deployed in openfaas
  list-flow-functions:
    lang: go
    handler: ./list-flow-functions
    image: localhost:5000/list-flow-functions:1.0.1
    environment:
      read_debug: true
      write_debug: true
      combine_output: false
    environment_file:
      - conf.yml
    secrets:
      - basic-auth
    labels:
      com.openfaas.scale.zero: "false"

  # Generate dot graph for faas-flow
  dot-generator:
    lang: go
    handler: ./dot-generator
    image: localhost:5000/dot-generator:1.2.0
    environment_file:
      - conf.yml
    environment:
      read_timeout: 120
      read_debug: true
      write_timeout: 120
      write_debug: true
      combine_output: false
    labels:
      com.openfaas.scale.zero: "false"

  # Collect metrics for faas-flow
  metrics:
    lang: go
    handler: ./metrics
    image: localhost:5000/metrics:1.6.0
    environment_file:
      - conf.yml
    environment:
      read_debug: true
      read_timeout: 120
      write_timeout: 120
      write_debug: true
      combine_output: false
    labels:
      com.openfaas.scale.zero: "false"

Under faas-flow-dashboard I just changed lang: Dockerfile to lang: dockerfile, and added the image local to be saved in local registry.

Before deploying I created a basic-auth secret as follows (I doubt this basic-auth step which I did):

kubectl create secret generic basic-auth --from-literal=username=abhishek --from-literal=password=abhishek --namespace openfaas-fn

And then I deploy faas-flow-tower as:

$ faas-cli up -g http://127.0.0.1:9999
...
Deploying: dot-generator.                                                                                                                                                                                           

Deployed. 202 Accepted.
URL: http://127.0.0.1:9999/function/dot-generator

Deploying: metrics.

Deployed. 202 Accepted.
URL: http://127.0.0.1:9999/function/metrics

Deploying: faas-flow-dashboard.

Deployed. 202 Accepted.
URL: http://127.0.0.1:9999/function/faas-flow-dashboard

Deploying: list-flow-functions.

Deployed. 202 Accepted.
URL: http://127.0.0.1:9999/function/list-flow-functions

image

faas-flow-tower does not monitor anything. Where I am going wrong in my setup? Please can anyone help me?

@Abhishekghosh1998
Copy link
Author

The issue was with the basic-auth secret attachment step. So that the faas-flow-tower is able to use the function information, we need the credentials of openfaas. So,

$ kubectl get secrets --namespace openfaas
NAME                              TYPE                                  DATA   AGE
basic-auth                        Opaque                                2      4d1h
default-token-c6r6b               kubernetes.io/service-account-token   3      4d1h
openfaas-controller-token-426cl   kubernetes.io/service-account-token   3      4d1h
openfaas-prometheus-token-9fvd6   kubernetes.io/service-account-token   3      4d1h
sh.helm.release.v1.openfaas.v1    helm.sh/release.v1                    1      4d1h

The basic-auth mentioned in the first line is of interest to us. We shall try to create a copy of that in the openfaas-fn namespace.

$ kubectl get secret basic-auth -n openfaas -o yaml > secret.yml

secret.yml:

apiVersion: v1
data:
  basic-auth-password: ZW91Y2ZoMUJ3SzZW
  basic-auth-user: YWRtaW4=
kind: Secret
metadata:
  annotations:
    helm.sh/hook: pre-install
  creationTimestamp: "2023-10-09T04:56:15Z"
  labels:
    app: openfaas
    chart: openfaas-14.1.9
    component: gateway
    heritage: Helm
    release: openfaas
  name: basic-auth
  namespace: openfaas
  resourceVersion: "1414"
  uid: c87d81e5-5160-4624-8ec0-eb4c0d2515b6
type: Opaque

Edit the above yml file to:

apiVersion: v1
data:
  basic-auth-password: ZW91Y2ZoMUJ3SzZW
  basic-auth-user: YWRtaW4=
kind: Secret
metadata:
  name: basic-auth
  namespace: openfaas-fn
type: Opaque

And then create the secret:

$ kubectl create -f secret.yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant