alexellis / faas-containerd

containerd and CNI provider for OpenFaaS
https://blog.alexellis.io/faas-containerd-serverless-without-kubernetes/
MIT License
61 stars 10 forks source link

Add labels to the containers from the function spec #19

Open alexellis opened 4 years ago

alexellis commented 4 years ago

Add labels to the containers from the function spec

Expected Behaviour

If you create a function with a label, that label should be added to the container definition, then read back later in the list endpoint.

Current Behaviour

They are ignored

Possible Solution

I'm OK if we only store the label and don't read it back for the first PR.

Update https://github.com/alexellis/faas-containerd/blob/master/handlers/update.go and https://github.com/alexellis/faas-containerd/blob/master/handlers/deploy.go

The types.FunctionDeployment struct already contains labels.

Steps to Reproduce (for bugs)

  1. faas-cli store deploy figlet --label has=label
  2. faas-cli describe figlet

The above on faas-netes / K8s will show the labels, on faas-containerd it won't

utsavanand2 commented 4 years ago

I'll take this up

utsavanand2 commented 4 years ago

@alexellis Sir do we also want to put the labels from the types.FunctionDeployment by default in addition to the custom ones we apply from the cli flag?

alexellis commented 4 years ago

It'd be anything that is in the struct received over HTTP

alexellis commented 4 years ago

@utsavanand2 I think your PR should be a little easier now that we have merged changes for #20, here's an example of the test command, right now the labels are ignored, after your PR, they should show up here. cc @carlosedp

> faas-cli store deploy figlet --label test=true
WARNING! Communication is not secure, please consider using HTTPS. Letsencrypt.org offers free SSL/TLS certificates.
Function figlet already exists, attempting rolling-update.

Deployed. 200 OK.
URL: http://127.0.0.1:8080/function/figlet

> faas-cli describe figlet
Name:                figlet
Status:              Ready
Replicas:            1
Available replicas:  1
Invocations:         0
Image:               
Function process:    
URL:                 http://127.0.0.1:8080/function/figlet
Async URL:           http://127.0.0.1:8080/async-function/figlet
carlosedp commented 4 years ago

@utsavanand2 I'd look here: https://godoc.org/github.com/containerd/containerd#WithContainerLabels

and here: https://github.com/alexellis/faas-containerd/blob/4aba01635d7da2a7dcc4cc9cc71e238a785c8100/handlers/deploy.go#L86

:)

utsavanand2 commented 4 years ago

Thanks for the help @alexellis and @carlosedp !! 😄