-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[WIP] Function label constraints #178
Conversation
The faas_function_filters environment variable can be used to specify service filters for the gateway. Only function services matching the filter conditions will be picked up by the gateway. Multiple filters can be specified as comma-separated values. Signed-off-by: King Chung Huang <kinghuang@mac.com>
Add a serviceLabelFilters argument to MakeFunctionReader. Any specified label filters will be added to the serviceFilter when getting the list of Docker services to check for functions. Signed-off-by: King Chung Huang <kinghuang@mac.com>
Pass the FunctionFilters config as the list of service label filters to MakeFunctionReader. Any specified filters will be used when getting the list of services in the Docker swarm for consideration as functions. Signed-off-by: King Chung Huang <kinghuang@mac.com>
Temporarily set faas_function_filters to hello=world on the gateway and add the corresponding label to hubstats to demonstrate the use of the label filter. Signed-off-by: King Chung Huang <kinghuang@mac.com>
Related: openfaas/faas-netes#20 |
@kinghuang - where are you with this? Btw we have merge conflicts and commits need squashing. |
@@ -5,11 +5,12 @@ services: | |||
- "/var/run/docker.sock:/var/run/docker.sock" | |||
ports: | |||
- 8080:8080 | |||
image: functions/gateway:0.6.3 | |||
image: functions/gateway:latest-dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line shouldn't have changed.
@kinghuang please see changes in latest release of the gateway and CLI to support labels. |
Closing as inactive. I believe we have this supported in the code now via other PRs. |
A WIP implementation of Option E from #175 to allow service label filters to be configured on the gateway.
Description
Add an environment config named
faas_function_filters
to the gateway. It is a comma-separated list of label filters used filter Docker services when reading the list of functions for the gateway. It is parsed into a string array and stored in a new field namedFunctionFilters
inGatewayConfig
.Motivation and Context
When multiple gateways are deployed on a swarm, there is no way to configure gateways to pick up only certain functions. As a result, functions from different stacks or different deployments of the same stack “leak” into each other. This is a WIP implementation of one of the possible options for configuring the gateway to read only certain function services.
This implementation is for Option E in proposal issue #175, and aims to solve issue #55.
How Has This Been Tested?
The
docker-compose.yml
file in this branch has been temporarily changed to filter forhello=world
, and thehubstats
function has been labeled to match. The gateway correctly picks up just that one function. If thefaas_function_filters
environment variable is removed, all the functions in the stack are read as before.This currently breaks adding a new function in the UI, because the created service lacks the labels specified in
faas_function_filters
.Also, this filtering is based on labels on services, not containers. It might be worth considering moving the
function
label to the service level for uniformity. However, that would be a breaking change.Types of changes
This becomes a breaking change if the
function
label is moved to the service level.Checklist:
git commit -s