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

Support annotations in function schema #682

Closed
alexellis opened this issue May 11, 2018 · 15 comments
Closed

Support annotations in function schema #682

alexellis opened this issue May 11, 2018 · 15 comments

Comments

@alexellis
Copy link
Member

alexellis commented May 11, 2018

Description

We should consider adding annotations to the schema or using them to store labels with Kubernetes

Example

"label": {"value-with-json-meta": "data"}
Swarm: valid
Kubernetes: invalid

"Git-Deploy": "03/03/2018 10:10:00"
Swarm: valid
Kubernetes: invalid

"valid-for-both": "anything-that-123-looks-like-a.domain"
Swarm: valid
Kubernetes: valid

Problem/Issue

Kubernetes uses annotations to configure metadata for objects like Pods. With Docker Swarm we use labels which support almost any string - but the label schema for Kubernetes is very restrictive only allowing a value which is a valid DNS entry.

OpenFaaS Cloud and the event connectors make use of metadata for filtering so for a rich experience with Kubernetes we need to think about how to start accommodating this metadata.

For Swarm labels work well - for Kubernetes we may need to make use of annotations in addition to labels.

Proposal

Add new field to function schema named "annotations"

Format: map[string]string (same as label)

Kubernetes: implemented as annotations in deployment and CRD

Swarm: implemented as label with special name

This is a vertical slice going all the way from the CLI through to the gateway to the providers and into the container orchestration system. The work will require (copy/paste/rename) of where labels are mentioned, but the work will have to be tested (manual end-to-end testing) and well co-ordinated with project lead.

Acceptance

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

functions:
  slack-responder:
    lang: go
    handler: ./slack-responder
    image: alexellis2/slack-responder:0.1.0
    labels:
      source: git
   annotations:
      git: https://github.com/alexellis/super-pancake-fn.git
      topics: "arn:aws:sns:us-west-2:111122223333:MyTopic,arn:aws:sns:us-west-2:111122223333:My-Second-Topic"

Previously the above would not be supported in Kubernetes - storing complex metadata in the function, but this would have been supported in Swarm.

Labels vs Annotations in K8s:

Labels: allows for only a-z, (-) and (.) character
Annotations: any value.

@stefanprodan
Copy link
Contributor

For Kubernetes we could use annotations instead of labels. This change only affects faas-netes and o6s.

@alexellis
Copy link
Member Author

alexellis commented May 11, 2018

What about where people have used labels for node-selectors?

@stefanprodan
Copy link
Contributor

The stack file has a dedicated field for node selectors, how would people use labels to target nodes in k8s?

@alexellis alexellis changed the title Rich metadata - consider use of annotations in function schema Move labels into annotations for Kubernetes Jun 16, 2018
@stantonxu
Copy link
Contributor

Hi @alexellis @stefanprodan , do you mean label like below is invalid for Kubernetes? I got it from one of the yaml files of the faas-netes.

  labels:
    app: {{ template "openfaas.name" . }}

If we just simply move these labels to annotations, will that cause problem for label selector? Though I don't see any label selector in all the yaml files of faas-netes.

@alexellis
Copy link
Member Author

No this is about where we store the labels for OpenFaaS functions when we create/update functions. It's not about the helm chart.

Look at the faas-netesd controller code where we store the labels from the request.

@stantonxu
Copy link
Contributor

@alexellis , sorry just get time to look back at this thread. Do you mean the code under handlers in the faas-netes project? Or could you help me point out where the code is? I am still trying to get familiar with the code.

@alexellis
Copy link
Member Author

Yes search for the word label and exclude the vendor folder. You'll see it then.

@alexellis alexellis changed the title Move labels into annotations for Kubernetes Support annotations in function schema Jul 13, 2018
@alexellis
Copy link
Member Author

@ewilde I've updated this issue with more details.

@ewilde
Copy link
Contributor

ewilde commented Jul 13, 2018

@alexellis thanks for updating the issue description, seems clear, will begin working on this

@alexellis
Copy link
Member Author

Great, thank you for the update.

@ewilde
Copy link
Contributor

ewilde commented Jul 16, 2018

@alexellis i'm guessing we are adding the annotations support so that functions themselves can access this new meta-data? If so, how does the function access the meta-data?

@ewilde
Copy link
Contributor

ewilde commented Jul 16, 2018

@alexellis I guess what i'm asking for is how to position annotations in the documentation / code comments? Currently labels are described as:

Labels are metadata for functions which may be used by the back-end for making scheduling or routing decisions

@alexellis
Copy link
Member Author

The functions will not have access to the annotations, it will be used to manage and orchestrate them with things like automation, eventing and build.

ewilde added a commit to ewilde/faas that referenced this issue Jul 19, 2018
Annotation attributes are metadata for functions which may be used by
the back-end for making scheduling or routing decisions.

Relates to openfaas#682

Signed-off-by: Edward Wilde <ewilde@gmail.com>
@alexellis
Copy link
Member Author

Derek set milestone: 0.8.7

@derek derek bot added this to the 0.8.7 milestone Jul 21, 2018
ewilde added a commit to ewilde/faas-cli that referenced this issue Jul 23, 2018
Relates to openfaas/faas#682

Signed-off-by: Edward Wilde <ewilde@gmail.com>
ewilde added a commit to ewilde/faas-cli that referenced this issue Jul 23, 2018
Relates to openfaas/faas#682

Signed-off-by: Edward Wilde <ewilde@gmail.com>
alexellis pushed a commit to openfaas/faas-cli that referenced this issue Jul 24, 2018
Relates to openfaas/faas#682

Signed-off-by: Edward Wilde <ewilde@gmail.com>
ewilde added a commit to ewilde/faas-netes that referenced this issue Jul 24, 2018
Store stack.yml annotation meta data in deployment, pod, service and
replicaset

Relates to openfaas/faas#682

Signed-off-by: Edward Wilde <ewilde@gmail.com>
ewilde added a commit to ewilde/faas-netes that referenced this issue Jul 24, 2018
Store stack.yml annotation meta data in deployment, pod, service and
replicaset

Relates to openfaas/faas#682

Signed-off-by: Edward Wilde <ewilde@gmail.com>
ewilde added a commit to ewilde/faas-swarm that referenced this issue Jul 25, 2018
Store stack.yml annotation meta data in deploy, update and read
handlers

Relates to openfaas/faas#682

Signed-off-by: Edward Wilde <ewilde@gmail.com>
ewilde added a commit to ewilde/faas-netes that referenced this issue Jul 25, 2018
Store stack.yml annotation meta data in deployment, pod, service and
replicaset

Relates to openfaas/faas#682

Signed-off-by: Edward Wilde <ewilde@gmail.com>
ewilde added a commit to ewilde/faas-swarm that referenced this issue Jul 26, 2018
Store stack.yml annotation meta data in deploy, update and read
handlers

Relates to openfaas/faas#682

Signed-off-by: Edward Wilde <ewilde@gmail.com>
ewilde added a commit to ewilde/faas-cli that referenced this issue Jul 27, 2018
Store stack.yml annotation meta data in deploy, update and read
handlers

Relates to openfaas/faas#682

Signed-off-by: Edward Wilde <ewilde@gmail.com>
ewilde added a commit to ewilde/faas-swarm that referenced this issue Jul 27, 2018
Store stack.yml annotation meta data in deploy, update and read
handlers

Relates to openfaas/faas#682

Signed-off-by: Edward Wilde <ewilde@gmail.com>
alexellis pushed a commit to openfaas/faas-netes that referenced this issue Jul 31, 2018
Store stack.yml annotation meta data in deployment, pod, service and
replicaset

Relates to openfaas/faas#682

Signed-off-by: Edward Wilde <ewilde@gmail.com>
ewilde added a commit to ewilde/faas-swarm that referenced this issue Jul 31, 2018
Store stack.yml annotation meta data in deploy, update and read
handlers

Relates to openfaas/faas#682

Signed-off-by: Edward Wilde <ewilde@gmail.com>
ewilde added a commit to ewilde/faas-swarm that referenced this issue Jul 31, 2018
Store stack.yml annotation meta data in deploy, update and read
handlers

Relates to openfaas/faas#682

Signed-off-by: Edward Wilde <ewilde@gmail.com>
alexellis pushed a commit to openfaas/faas-swarm that referenced this issue Aug 1, 2018
Store stack.yml annotation meta data in deploy, update and read
handlers

Relates to openfaas/faas#682

Signed-off-by: Edward Wilde <ewilde@gmail.com>
ewilde added a commit to ewilde/openfaas-operator that referenced this issue Aug 6, 2018
Relates to openfaas/faas#682

Signed-off-by: Edward Wilde <ewilde@gmail.com>
@alexellis
Copy link
Member Author

Derek close: released

@derek derek bot closed this as completed Oct 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants