Closed alexellis closed 5 years ago
Derek assign: me
I will directly post one large PR with the changes in all the commands
Happy for you to run with this, thank you.
Hi, it seems that this option, i.e. --namespace
or -n
is not working when using a yaml file in command deploy
.
I use this command:
faas-cli deploy -f some-config.yaml -n some-ns
With no namespace declearing in some-config.yaml
, the option -n
is not sent to the gateway.
but when i use this command, every thing works well:
faas-cli deploy --name some-func-name --image some-func-image -n some-ns
Extracting the two parameters for function name and function image from some-config.yaml to command line, it works. 🤔
I am wondering there is a bug. I am trying to read the source code for more info.
For YAML files I think we need to extend the schema. Kubernetes AFAIK won't allow this either using its CLI.
The YAML file should allow for a namespace to be specified. @LucasRoesler @martindekov
Yes this can be easily added to the schema I believe 👍 I can add the change in the weekend that comes. This issue covered the CLI, not the schema, I can open another one which can address this problem?
Hi, it seems that this option, i.e.
--namespace
or-n
is not working when using a yaml file in commanddeploy
.I use this command:
faas-cli deploy -f some-config.yaml -n some-ns
With no namespace declearing in
some-config.yaml
, the option-n
is not sent to the gateway.
I tried also and today its still not working
Hey @sperolsUNIV, thanks for the feedback on this, what is the version of the CLI which you use?
@martindekov i remember bringing up this same issue several months back (I can't find the thread where I raised it).
Ultimately, nothing was done because the reasoning is that this behave almost the same as how kubectl apply -f
behaves. If you template already has a namespace, then it is not overridden. I think our behavior is slightly different though because the flag sets the variable functionNamespace
and this seems to only be used when defining the function via flags, ie not using a stack file.
I don't think this behavior is obvious for most users, I would be glad to see this change to behave like the other flags: merge/replace the flag value into the stack file. I think it would be a relatively small change here
Just add this before line 276
if functionNamespace != "" {
function.Namespace = functionNamespace
}
and the flag will then override the value from the yaml file.
Trying my hand at this and submitting a PR. I think your idea is sound @LucasRoesler.
@nickgerace you are always welcome to submit a PR, buy I think we need some input from @alexellis before we know if it will be accepted and merged.
Can we come up with some specific scenarios? Like examples of the stack yml and flags passed along with the desired outcome?
The use case my data science team has is that they want to deploy their models to a DEV, STG, and default namespace as part of the development flow.
The desired workflow is that
master
would run faas-cli up --namespace DEV --env db=...
master
would run faas-cli up --namespace STG --env db=...
faas-cli up --namespace PROD --env db=...
We worked around this by using env substitution, but it caused and still causes a lot of confusion to the ops and data science team. Every other flag seems to override the stack file except this one flag. It honestly wasted a day of effort because the team thought they were messing something up and spent a day trying to debug before asking me about it.
Our workaround looks like this
master
run namespace=DEV faas-cli up --env db=...
master
run namespace=STG faas-cli up --env db=...
namespace=PROD faas-cli up --env db=...
Where we added namespace: ${namespace:-DEV}
into the stack files. But this was only implemented because I told them that it was possible.
Description
Add
--namespace
/-n
flag to function commands so that users can access functions in any valid namespace.Possible Solution
Start with a number of small PRs, or one larger PR covering:
faas-cli list
faas-cli deploy
faas-cli remove
Then add support to:
faas-cli describe
faas-cli store deploy
The namespace flag must be optional and will be added to the HTTP path as a query string i.e.
GET /system/functions?namespace=staging
Tracking issue: https://github.com/openfaas/faas-netes/issues/511