nuclio
nuclio copied to clipboard
Deploy a function inside a specific network
Hello, I have a docker-compose file in which I run a container running nuctl, which then deploys some functions. The container which are then deployed won't join the docker-compose network, making difficult to communicate between the services inside the network and the functions.
Is there any way to deploy the function inside a network, or some way to bypass this problem?
on your function configuration, under platform.attributes
block you may use network
and specify the docker network you want your function to use.
e.g.:
meta:
name: my-func
spec:
handler: main:handler
runtime: python:3.8
platform:
attributes:
network: my-docker-network
Even by specifying the network in platform.attributes
, when I inspect the container it is connected only to the default bridge, not on the created network
I have the same problem. I can't get this to work. Even if a disable the default bridge network in the daemon.json.
Also I could not find this network setting in the documentation.
This is related to https://github.com/nuclio/nuclio/issues/989 So i guess it worked for someone at some point.
@emdant I made it work. I had platform twice in my file. In this case it does not work correctly.
i added the name (cvat_cvat ) I got from docker network ls
:
NETWORK ID NAME DRIVER SCOPE
30fef26c5013 cvat_cvat bridge local
to the yaml file:
metadata:
name: dummy-model
namespace: cvat
annotations:
name: Dummy Model
type: detector
framework: pytorch
spec: |
[
{ "id": 1, "name": "ball" }
]
spec:
description: Detectron2
runtime: 'python:3.8'
handler: main:handler
eventTimeout: 30s
build:
image: cvat/dummy
baseImage: ubuntu:20.04
directives:
preCopy:
- kind: ENV
value: DEBIAN_FRONTEND=noninteractive
- kind: RUN
value: apt-get update && apt-get -y install curl git python3 python3-pip libgl1-mesa-glx libglib2.0-0 python-is-python3
- kind: RUN
value: python3 -m pip install opencv-python
triggers:
myHttpTrigger:
maxWorkers: 2
kind: 'http'
workerAvailabilityTimeoutMilliseconds: 10000
attributes:
maxRequestBodySize: 33554432 # 32MB
platform:
attributes:
restartPolicy:
name: always
maximumRetryCount: 3
mountMode: volume
network: cvat_cvat
Maybe my example can help you.