-
Notifications
You must be signed in to change notification settings - Fork 476
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
Node selector support via constraints #77
Conversation
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
7fdd0a9
to
a70689d
Compare
@johnmccabe @ericstoekl I'm looking to push this through. Would you be interested in getting involved testing? I know you may have multi-node clusters. |
Sure, I'll try this PR out. Can I add myself as a reviewer using Derek? |
@ericstoekl you should be able to start a review when commenting in the file changes |
@rayhero I think this could be useful for your image / opencv processing |
Eric would still appreciate a review & testing. |
Have spun this up locally for an initial sanity check (not reviewed code yet), on a two node cluster however so I've tainted master. My Kubernetes version is:
Created the following label on
I've deployed the function both with and without constraints and then put it under a simple load (curl in a while loop). Without constraint set
With constraint set
Also tried with one of the default labels.
|
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.
Just some minor comments, apart from that looks OK to me.
const WatchdogPort = 8080 | ||
|
||
// InitialReplicas how many replicas to start of creating for a function | ||
const InitialReplicas = 1 |
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.
Worth allowing the user to set the initial/min number of replicas when deploying a function?
Also does this actually need to be exported? its only used in this file.
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.
Number 1 is out of scope for PR, but can come under the scope of the issue in the faas repo around setting max replicas. I'll un-capitalize the watchdog port until needed in another package.
log.Println(constraints) | ||
if len(constraints) > 0 { | ||
for _, constraint := range constraints { | ||
parts := strings.Split(constraint, "=") |
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.
Sanity checked with a keyonly constraint here and it looked ok.
faas-cli.exe deploy --image johnmccabe/fn-env --name echo --gateway http://kube1.johnmccabe.infra:31112 --constraint "keyonlylabel="
@@ -22,6 +23,12 @@ import ( | |||
"k8s.io/client-go/kubernetes" | |||
) | |||
|
|||
// WatchdogPort for the OpenFaaS function watchdog | |||
const WatchdogPort = 8080 |
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.
Does this actually need to be exported? its only used in this file.
Perhaps pull this in from a package either in the watchdog or gateway so it gets defined in one location? (Was wondering if we'd ever need to change this.. say a user is packaging up a binary they can't change which binds to 8080.. bit of a contrived edge case tho so not worth it until its seen in the wild).
@alexellis can this move to done in the project |
Do you have access? |
Thanks for taking time to test and validate |
The Kubernetes operator `faas-netes` expects the constraints / nodeSelectors in the format <label-key>=<label-value>. References: - Pull Request ([Node selector support via constraints openfaas#77](openfaas/faas-netes#77)), which introduced the feature - the [source code for the createSelector function](https://github.com/openfaas/faas-netes/blame/master/pkg/handlers/deploy.go#L338), see how the key-value pair is split - an [issue](openfaas/faas-netes#406 (comment)) regarding the difference between constraints for Docker Swarm & Kubernetes also remove some erroneous whitespace in an URL, which broke the link and anchor
The Kubernetes operator `faas-netes` expects the constraints / nodeSelectors in the format <label-key>=<label-value>. references: - pull request ([Node selector support via constraints openfaas#77](openfaas/faas-netes#77)), which introduced the feature - the [source code for the createSelector function](https://github.com/openfaas/faas-netes/blame/master/pkg/handlers/deploy.go#L338), see how the key-value pair is split - an [issue](openfaas/faas-netes#406 (comment)) regarding the difference between constraints for Docker Swarm & Kubernetes Signed-off-by: Robert Groh <robert.groh@amity.group>
The Kubernetes operator `faas-netes` expects the constraints / nodeSelectors in the format <label-key>=<label-value>. references: - pull request ([Node selector support via constraints openfaas#77](openfaas/faas-netes#77)), which introduced the feature - the [source code for the createSelector function](https://github.com/openfaas/faas-netes/blame/master/pkg/handlers/deploy.go#L338), see how the key-value pair is split - an [issue](openfaas/faas-netes#406 (comment)) regarding the difference between constraints for Docker Swarm & Kubernetes also: - fix broken link/anchor by removing erroneous whitespace in the URL Signed-off-by: Robert Groh <robert.groh@amity.group>
Description
Brings parity with Docker Swarm implementation.
We can now pin a function to a specific node such as:
faas-cli
YAMLHow Has This Been Tested?
Test plan:
First label a node using
kubectl
:Next add a constraint to a function using the YAML example above and deploy.
You should see that the function is scheduled on the node. Now try removing the function and the constraint and schedule again.
Finally add a constraint that can never be matched and then reschedule the function, you should see it sitting at 0/1 replicas.
Next - do all of the above using the
--update=true --replace=false
flag tofaas-cli deploy
Types of changes
Checklist:
git commit -s