Function-Configuration Reference#
This document provides a reference of the Nuclio function configuration.
In This Document#
Basic configuration structure#
The basic structure of the Nuclio function configuration resembles Kubernetes resource definitions, and includes
the apiVersion, kind, metadata, spec, and status sections. Following is an example of a minimal definition:
apiVersion: "nuclio.io/v1"
kind: NuclioFunction
metadata:
name: example
spec:
image: example:latest
Function Metadata#
The metadata section includes the following attributes:
Path |
Type |
Description |
|---|---|---|
name |
string |
The name of the function |
namespace |
string |
A level of isolation provided by the platform (e.g., Kubernetes) |
labels |
map |
A list of key-value tags that are used for looking up the function (immutable, can’t update after first deployment) |
annotations |
map |
A list of annotations based on the key-value tags |
Example#
metadata:
name: example
namespace: nuclio
labels:
l1: lv1
l2: lv2
l3: 100
annotations:
a1: av1
Function Specification (spec)#
The spec section contains the requirements and attributes and has the following elements:
Path |
Type |
Description |
|---|---|---|
|
string |
A textual description of the function |
|
string |
The entry point to the function, in the form of |
|
string |
The name of the language runtime - |
|
string |
The name of the function’s container image — used for the |
|
map |
A name-value environment-variables tuple; it’s also possible to reference secrets from the map elements, as demonstrated in the specification example |
|
[]v1.EnvFromSource |
List of sources from which the function takes environment variables (ConfigMaps/Secrets). It is being merged with the correspondent platform |
|
map |
A map in an architecture similar to Kubernetes volumes, for Docker deployment |
|
int |
The number of desired instances; 0 for auto-scaling. |
|
int |
The minimum number of replicas |
|
string |
The name of the restart policy for the function-image container; applicable only to Docker platforms |
|
int |
The maximum retries for restarting the function-image container; applicable only to Docker platforms |
|
string |
Function mount mode, which determines how Docker mounts the function configurations - |
|
string,int |
The interval between health checks, in seconds or as a duration string (e.g., |
|
int |
The maximum number of replicas |
|
int |
Target CPU when auto scaling, as a percentage (default: 75%) |
|
See reference |
A map of data sources used by the function (“data bindings”) |
|
int |
The number of concurrent requests this trigger can process |
~~ |
int |
Deprecated: The max number of concurrent requests this trigger can process |
|
string |
The trigger type (kind) - |
|
string |
The trigger specific URL (not used by all triggers) |
|
string |
Waiting time for workers to drop or ACK on events before rebalance in seconds or as a duration string (e.g., |
|
list of strings |
Annotations to be assigned to the trigger, if applicable |
|
int |
The number of milliseconds to wait for a worker if one is not available. 0 = never wait (default: 10000, which is 10 seconds) |
|
See reference |
The per-trigger attributes |
|
string |
Batching mode, can be |
|
int |
Size of batch |
|
string |
Timeout after which the batch is sent to runtime even if the batch is not full yet (e.g., |
|
string |
Event processing mode. Can be |
|
int |
The minimum number of connections to maintain for asynchronous triggers (default is 1000). |
|
int |
The maximum number of connections to maintain for asynchronous triggers (default is 1000). |
|
string |
The mode of connection creation for asynchronous triggers. Can be |
|
string |
Timeout during which connection must be allocated for an event, in the format supported for the |
|
string |
Total budget for the Go processor to establish connections to the Python wrapper and receive its readiness signal during function startup (e.g., |
|
string |
The URL of a GitHub repository or an archive-file that contains the function code — for the |
|
string |
Base-64 encoded function source code for the |
|
string |
The container image repository to which the built image will be pushed |
|
string |
Do not pull any base images when building, use local images only |
|
string |
Do not use any caching when building container images |
|
string |
The name of a base container image from which to build the function’s processor image |
|
list of string |
Commands run opaquely as part of container image build |
|
map |
Build directives in the form of key to list of |
|
string |
The name of an “onbuild” container image from which to build the function’s processor image; the name can include |
|
string |
The name of the built container image (default: the function name) |
|
map |
Build args to pass to the docker file when building the function. The map is a key-value for each argument |
|
[]string |
Build flags to pass to the container builder-pusher. List of flags is here: Kaniko - GoogleContainerTools/kaniko, Docker - https://docs.docker.com/engine/reference/commandline/image_build/ |
|
string |
The function’s code-entry type - |
|
See reference |
Code-entry attributes, which provide information for downloading the function when using the |
|
string |
The name of the service account for the builder pods (relevant for a kubernetes setup with |
|
string |
The container image repository from which the platform will pull the image |
|
See reference |
Runtime-specific attributes |
|
See reference |
Limit resources allocated to deployed function |
|
int |
Number of seconds that the controller will wait for the function to become ready before declaring failure (default: 60) |
|
bool |
Wait for the expiration of the readiness timeout period even if the deployment fails or isn’t expected to complete before the readinessTimeout expires |
|
string |
Base64 representation of an icon to be shown in UI for the function (Deprecated) |
|
string |
Global event timeout, in the format supported for the |
|
string |
Timeout per chunk when streaming response from a runtime. Applied for all chunks except the 1st one, |
|
int |
The user ID (UID) for running the entry point of the container process |
|
int |
The group ID (GID) for running the entry point of the container process |
|
int |
A supplemental group to add and use for running the entry point of the container process |
|
string |
Describes ingress methods for a service |
|
v1.Affinity |
Set of rules used to determine the node that schedule the pod |
|
map |
Constrain function pod to a node by key-value pairs selectors. Node selectors with empty values are automatically removed from the map. |
|
string |
Constrain function pod to a node by node name |
|
string |
Kubernetes RuntimeClass name for function pods. When unset, the cluster default runtime is used. |
|
string |
Indicates the importance of a function pod relatively to other function pods |
|
string |
Function pod preemption policy (one of |
|
[]v1.Toleration |
Function pod tolerations |
|
bool |
Don’t scrub sensitive information form the function configuration |
|
autosv2.MetricSpec |
Custom function horizontal pod autoscaling metric spec, allowing to override the default |
|
[]string |
List of devices to be made available to the function. Relevant for local platform only. (e.g. /dev/video0:/dev/video0:rwm) |
|
*bool |
Disable default http trigger creation. If flag isn’t set, value is taken from the platform config. |
|
[]*v1.Container |
See kubernetes docs for more info |
|
[]*v1.Container |
See kubernetes docs for more info |
|
*v1.Probe |
See kubernetes docs for more info . |
|
*v1.Probe |
See kubernetes docs for more info . |
|
[]LoggerSink |
A list of logging sinks that define where function logs should be sent and at what log level. Each sink entry defines a destination and the minimum level of log messages to send. |
|
string |
Minimum severity level for messages to be sent to this sink (e.g. |
|
string |
The log sink destination. For example: |
Specification example#
spec:
description: my Go function
handler: main:Handler
runtime: golang
image: myfunctionimage:latest
platform:
attributes:
# Docker will retry starting the function's image container 3 times.
# For more information, see https://docs.docker.com/config/containers/start-containers-automatically.
restartPolicy:
name: on-failure
maximumRetryCount: 3
# Set the healthcheck interval to specific value
# For more information, see https://docs.docker.com/engine/reference/builder/#healthcheck
# By default, set to 1s by Nuclio.
# Note: This is relevant for local platform only (Docker).
healthCheckInterval: 10s
# Use `volume` to mount the processor into the function.
# For more information, see https://docs.docker.com/storage/volumes.
mountMode: volume
env:
- name: SOME_ENV
value: abc
- name: SECRET_PASSWORD_ENV_VAR
valueFrom:
secretKeyRef:
name: my-secret
key: password
volumes:
- volume:
hostPath:
path: "/var/run/docker.sock"
volumeMount:
mountPath: "/var/run/docker.sock"
minReplicas: 2
maxReplicas: 8
targetCPU: 60
build:
registry: localhost:5000
noBaseImagePull: true
noCache: true
commands:
- apk --update --no-cache add curl
- pip install simplejson
resources:
# Kubernetes Limits & Requests for the function's CPU and memory usage.
# For more information, see https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
# Leave empty to use the default values.
# Note: This is mostly relevant for Kubernetes platform only.
# For local platform (Docker), only the `limits` section is relevant.
# When nvidia gpu limit is set, the function will be deployed with "--gpus all"
# When cpu limit set, the function will be deployed with "--cpus <cpu limit>"
# When memory limit set, the function will be deployed with "--memory <memory limit>"
requests:
cpu: 1
memory: 128M
limits:
cpu: 2
memory: 256M
nvidia.com/gpu: 1
securityContext:
runAsUser: 1000
runAsGroup: 2000
fsGroup: 3000
runtimeClassName: nvidia
Function Status#
The status section contains the requirements and attributes and has the following elements:
Path |
Type |
Description |
|---|---|---|
state |
string |
A textual representation of the function status |
message |
string |
Function state message, mostly in use to represent why a function has failed |
logs |
map |
The function deployment logs to be returned |
scaleToZero |
object |
The details of the last scale event of the function (contains event message and time) |
apiGateways |
[]string |
A list of the function’s api-gateways |
httpPort |
int |
The http port used to invoke the function |
containerImage |
string |
The name of the built function container image, including the registry. |
internalInvocationUrls |
[]string |
A list of internal URLs to invoke the function |
externalInvocationUrls |
[]string |
A list of external URLs to invoke the function, including ingresses and external-ip:function-port |
Function state (state)#
The state field describes the current function status, and can be one of the following:
State |
Description |
|---|---|
ready |
Function is deployed successfully and ready to process events. |
imported |
Function is imported but not yet deployed. |
scaledToZero |
Function is scaled to zero, so the number of function replicas is zero. |
building |
Function image is being built. |
waitingForResourceConfiguration |
Function waits for resources to be ready. For instance, in case of k8s function waits for deployment/pods and etc. |
waitingForScaleResourceFromZero |
Function is scaling up from zero replicas. |
waitingForScaleResourceToZero |
Function is scaling down to zero replicas. |
error |
An error occurred during function deployment that cannot be rectified without redeployment. |
unhealthy |
An error occurred during function deployment, which might be resolved over time, and might require redeployment. For example, issues with insufficient resources or a missing image. |
Status example#
status:
state: ready
scaleToZero:
lastScaleEvent: resourceUpdated
lastScaleEventTime: "2022-12-11T16:23:52.130851057Z"
apiGateways:
- some-api-gateway
containerImage: localhost:5000/nuclio-my-function-image-processor:latest
externalInvocationUrls:
- ing-nuclio.my-nuclio-domain.com/function-name
internalInvocationUrls:
- nuclio-function-name.nuclio.svc.cluster.local:8080