kubeless
kubeless copied to clipboard
Using module in zip file from subpath
Is this a BUG REPORT or FEATURE REQUEST?: Bug report / support
What happened: Using a zip file as the function from a downloaded gitlab repo, I cannot define a function as the module lies within a subfolder.
What you expected to happen: I can specify the module like "functionname-master/modulename.main"
How to reproduce it (as minimally and precisely as possible): Have a git repo with the following directory format
| .gitignore
| requirements.txt
| modulename/
-- | __init__.py
-- | __main__.py
-- | otherstuff.py
When downloading the repo as a zip to use with url+zip
as the source of the function, it downloads the contents of the repo in a reponame-master
directory in the zip. So when it's extracted, it's extracted to /kubeless/reponame-master/
. Meaning that if I set handler
to modulename.__main__
, it says
FileNotFoundError: [Errno 2] No such file or directory: '/kubeless/modulename.py'
And if I set handler to reponame-master/modulename.__main__
, I get the error in the kubeless controller pod
Invalid value: "reponame-master/modulename": a valid config key must consist of alphanumeric characters, '-', '_' or '.' (e.g. 'key.name', or 'KEY_NAME', or 'key-name', regex used for validation is '[-.a-zA-Z0-9]+')" pkg=function-controller time="2020-07-28T01:35:39Z" level=error msg="Error processing bots/examplefunction (giving up): ConfigMap "examplefunction" is invalid: data[reponame-master/modulename]: Invalid value: "reponame-master/modulename": a valid config key must consist of alphanumeric characters, '-', '' or '.' (e.g. 'key.name', or 'KEY_NAME', or 'key-name', regex used for validation is '[-.a-zA-Z0-9]+')" pkg=function-controller ERROR: logging before flag.Parse: E0728 01:35:39.002352 1 function_controller.go:185] ConfigMap "examplefunction" is invalid: data[reponame-master/modulename]: Invalid value: "reponame-master/modulename": a valid config key must consist of alphanumeric characters, '-', '' or '.' (e.g. 'key.name', or 'KEY_NAME', or 'key-name', regex used for validation is '[-._a-zA-Z0-9]+')
So what would be the proper way to deploy this function using kubeless?
The rest of my function yaml:
---
apiVersion: kubeless.io/v1beta1
kind: Function
metadata:
name: examplefunction
namespace: bots
label:
created-by: kubeless
function: examplefunction
spec:
runtime: python3.7
timeout: "180"
handler: "modulename.__main__"
deps: |
flask
requests
xmltodict
bs4
coloredlogs
pillow
environs
psycopg2-binary
function-content-type: url+zip
function: https://gitlab.example.com/cclloyd/reponame/-/archive/master/reponame-master.zip
deployment:
spec:
template:
spec:
containers:
- env:
- name: STUFF
value: "REDACTED"
Hi @cclloyd,
Unfortunately, subfolders are not supported by Kubeless, the function should be at the root of the folder. Also requested here: https://github.com/kubeless/kubeless/issues/803