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

Help needed with constraints #406

Closed
gilkotton opened this issue Apr 6, 2019 · 9 comments
Closed

Help needed with constraints #406

gilkotton opened this issue Apr 6, 2019 · 9 comments

Comments

@gilkotton
Copy link

gilkotton commented Apr 6, 2019

Contraints don't end up in the deployment.

Expected Behaviour

When specified constrains with faas-cli, either in the function yaml or in the command line flag, it should end up in the deployment yaml, but it doesn't and hence doesn't deploy.

Current Behaviour

The constraints don't have an effect on the deployment.
I tried having my function deploy to a specific CPU type. I labeled my node, and specified the constraint through the faas-cli.
Preliminary checks, I see a sign of the constraint arriving at the faas-netes pod, but don't see any sign in the deployment, the deployment yaml has neither a nodeSelector nor a labelSelector.

Possible Solution

Steps to Reproduce (for bugs)

Steps to Reproduce (for bugs)

Add a constraints statement to the openfaas function yaml, something like:
constraints:

  • "devtype == pc"

(where devtype is a label I labeled the nodes)

Or use a built-in node label, such as:

constraints:

  • "beta.kubernetes.io/arch == amd64"

Deploy and check to which node the image was deployed. Was it subsequent pods deployed only to specified node types?

Check the deployment yaml to see if a nodeSelector or equivalent statement exists.

Context

This is a follow-up on my previous issue in faas-cli issue #616 after some preliminary debugging.

openfaas/faas-cli#616

Your Environment
I have a small cluster with openfaas on K3S, the master node is an amd64 PC, with two arm rpi nodes as slaves. I want my openfaas function to deploy to its appropriate node by architecture. Tried specifying a function constraint with a node label. The pod didn't deploy to a specific architecture node.

Docker version ( Full output from: docker version ):

Are you using Docker Swarm (FaaS-swarm ) or Kubernetes (FaaS-netes)?
K3s + FaaS-netes according to @AlexEllisUK great blogs.

Operating System and version (e.g. Linux, Windows, MacOS):
Lubuntu on the arm64 and raspbian on the arm.

Link to your project or a code example to reproduce issue:
Tried it with the hello-python demo. With the contraints statement added to the hello-python.yaml file in the function section

@alexellis
Copy link
Member

Please fill out the whole template, this is there because we need the information.

@alexellis
Copy link
Member

https://github.com/openfaas/faas-netes/blob/master/.github/ISSUE_TEMPLATE.md

You'll also need to state if you're using the operator or not.

@alexellis
Copy link
Member

Derek set title: Help needed with constraints

@derek derek bot changed the title Constraints don't deploy Help needed with constraints Apr 6, 2019
@alexellis
Copy link
Member

Derek close: inactivity

@alexellis
Copy link
Member

I'm going to close this, but feel free to keep commenting.

@mytracks
Copy link

I am having exactly the same problem in my cluster which consists of both Linux and Windows nodes. I would like this bug to be fixed. How can I help with this? What kind of information is missing?

@Snapple49
Copy link

I am also experiencing this issue. Looking at the documentation, the only example of constraints is for docker swarm, but it remains unclear how to format constraints for k8s environments (I'm not so familiar with swarm so maybe it is essentially the same).

I'm trying to provide a nodeselector constraint, both via the stack yaml and via cli flags, in this case the node has the label "acceleration=gpu". But I cannot see this anywhere in the deployment and the scheduler disregards this completely.

@alexellis
Copy link
Member

So the constraint supported at present corresponds to a nodeSelector. So apply a label to one or more nodes and then you can specify that constraint in your stack.yaml.

Hope this helps, if you're still struggling, jump on Slack #kubernetes channel

@Snapple49
Copy link

Thanks for clarifying! Now I got it to work, but I still find it a bit strange that it didn't work when I tried via the CLI:

faas deploy -f prediction-test.yml --constraint "acceleration=gpu"

while now it works when adding this in the stack yaml:

    constraints:
      - acceleration=gpu

Also, as I mentioned the documentation only shows a swarm example, where the key and value are separated by == and this is what I tried first, but it seems that was the issue. Perhaps providing a k8s constraint example as well would better clarify the usage in this context, or mentioning that for k8s it is translated directly to a nodeSelector.

robertgroh added a commit to robertgroh/docs that referenced this issue Mar 12, 2021
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
robertgroh pushed a commit to robertgroh/docs that referenced this issue Mar 12, 2021
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>
robertgroh pushed a commit to robertgroh/docs that referenced this issue May 6, 2021
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>
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

4 participants