Documentation
¶
Index ¶
- Constants
- Variables
- func BatchModeEnabled(batchConfiguration *BatchConfiguration) bool
- func ExplicitAckEnabled(mode ExplicitAckMode) bool
- func ExplicitAckModeInSlice(ackMode ExplicitAckMode, ackModes []ExplicitAckMode) bool
- func FunctionStateInSlice(functionState FunctionState, functionStates []FunctionState) bool
- func FunctionStateProvisioned(functionState FunctionState) bool
- func FunctionStateProvisioning(functionState FunctionState) bool
- func GetFunctionIngresses(config *Config) map[string]Ingress
- func GetTriggersByKind(triggers map[string]Trigger, kind string) map[string]Trigger
- func GetTriggersByKinds(triggers map[string]Trigger, kinds []string) map[string]Trigger
- func IsPreviousFunctionStateAllowedToBeSet(prevState FunctionState) bool
- func ParseHandler(handler string) (string, string, error)
- func ResolveFunctionServiceType(functionSpec *Spec, defaultServiceType v1.ServiceType) v1.ServiceType
- func RuntimeSupportExplicitAck(runtime string) bool
- func RuntimeSupportsBatching(runtime string) bool
- func ShouldSkipBuild(annotations map[string]string) bool
- func ShouldSkipDeploy(annotations map[string]string) bool
- func TriggerKindSupportsBatching(triggerKind string) bool
- type AutoScaleDisplayType
- type AutoScaleMetric
- type BatchConfiguration
- type BatchMode
- type Build
- type BuildMode
- type Checkpoint
- type Config
- func (c *Config) AddPrevStateAnnotation(state string)
- func (c *Config) AddSkipAnnotations()
- func (c *Config) CleanFunctionSpec()
- func (c *Config) EnrichWithNodeSelectors(nodeSelector map[string]string)
- func (c *Config) EnrichWithTolerations(tolerations []v1.Toleration)
- func (c *Config) GetProjectName() (string, error)
- func (c *Config) PrepareFunctionForExport(exportOptions *common.ExportFunctionOptions)
- func (c *Config) PruneAffinityNodeSelectorRequirement(nodeSelectorRequirements []v1.NodeSelectorRequirement, mode string)
- func (c *Config) PruneNodeSelector(nodeSelector map[string]string)
- func (c *Config) PruneTolerations(tolerations []v1.Toleration)
- type ConfigWithStatus
- type DataBinding
- type Directive
- type ExplicitAckMode
- type FunctionState
- type Ingress
- type IngressTLS
- type LoggerSink
- type Meta
- type Metric
- type Partition
- type Platform
- type Reader
- type RunOnPreemptibleNodeMode
- type ScaleResource
- type ScaleToZeroSpec
- type ScaleToZeroStatus
- type Scrubber
- func (s *Scrubber) ConvertMapToConfig(mapConfig interface{}) (interface{}, error)
- func (s *Scrubber) RestoreFunctionConfig(ctx context.Context, functionConfig *Config, platformName string) (*Config, error)
- func (s *Scrubber) ScrubFunctionConfig(ctx context.Context, functionConfig *Config) (*Config, error)
- func (s *Scrubber) ValidateReference(objectToScrub interface{}, existingSecretMap map[string]string, ...) error
- type Spec
- type Status
- type Trigger
- type TriggerWorkMode
- type Volume
Constants ¶
const ( ReferencePrefix = "$ref:" ReferenceToEnvVarPrefix = "NUCLIO_B64_" NuclioFlexVolumeSecretNamePrefix = "nuclio-flexvolume" SecretTypeFunctionConfig = "nuclio.io/functionconfig" SecretTypeV3ioFuse = "v3io/fuse" SecretContentKey = "content" FunctionSecretMountPath = "/etc/nuclio/secrets" )
const ( BatchModeEnable BatchMode = "enable" BatchModeDisable BatchMode = "disable" DefaultBatchSize = 10 DefaultBatchTimeout = "1s" )
const ( // ExplicitAckModeEnable allows explicit and implicit ack according to the "x-nuclio-stream-no-ack" header ExplicitAckModeEnable ExplicitAckMode = "enable" // ExplicitAckModeDisable disables the explicit ack feature and allows only implicit acks (default) ExplicitAckModeDisable ExplicitAckMode = "disable" // ExplicitAckModeExplicitOnly allows only explicit acks and disables implicit acks ExplicitAckModeExplicitOnly ExplicitAckMode = "explicitOnly" // DefaultWorkerTerminationTimeout wait time for workers to drop or ack events before rebalance initiates DefaultWorkerTerminationTimeout string = "10s" )
const ( FunctionAnnotationSkipBuild = "skip-build" FunctionAnnotationSkipDeploy = "skip-deploy" FunctionAnnotationPrevState = "nuclio.io/previous-state" FunctionAnnotationForceUpdate = "nuclio.io/force-update" )
const (
NvidiaGPUResourceName = "nvidia.com/gpu"
)
Variables ¶
var FixableValidationErrors = []string{"V3IO Stream trigger does not support autoscaling"}
Functions ¶
func BatchModeEnabled ¶
func BatchModeEnabled(batchConfiguration *BatchConfiguration) bool
func ExplicitAckEnabled ¶
func ExplicitAckEnabled(mode ExplicitAckMode) bool
func ExplicitAckModeInSlice ¶
func ExplicitAckModeInSlice(ackMode ExplicitAckMode, ackModes []ExplicitAckMode) bool
func FunctionStateInSlice ¶
func FunctionStateInSlice(functionState FunctionState, functionStates []FunctionState) bool
func FunctionStateProvisioned ¶
func FunctionStateProvisioned(functionState FunctionState) bool
func FunctionStateProvisioning ¶
func FunctionStateProvisioning(functionState FunctionState) bool
func GetFunctionIngresses ¶
func GetTriggersByKind ¶
GetTriggersByKind returns a map of triggers by their kind
func GetTriggersByKinds ¶
GetTriggersByKinds returns a map of triggers by their kinds
func IsPreviousFunctionStateAllowedToBeSet ¶
func IsPreviousFunctionStateAllowedToBeSet(prevState FunctionState) bool
func ResolveFunctionServiceType ¶
func ResolveFunctionServiceType(functionSpec *Spec, defaultServiceType v1.ServiceType) v1.ServiceType
func RuntimeSupportsBatching ¶
func ShouldSkipBuild ¶
func ShouldSkipDeploy ¶
Types ¶
type AutoScaleDisplayType ¶
type AutoScaleDisplayType string
const ( AutoScaleMetricTypeInt AutoScaleDisplayType = "int" AutoScaleMetricTypePercentage AutoScaleDisplayType = "percentage" )
type AutoScaleMetric ¶
type AutoScaleMetric struct {
ScaleResource `json:",inline"`
SourceType autosv2.MetricSourceType `json:"sourceType,omitempty"`
DisplayType AutoScaleDisplayType `json:"displayType,omitempty"`
}
type BatchConfiguration ¶
type Build ¶
type Build struct {
Path string `json:"path,omitempty"`
FunctionSourceCode string `json:"functionSourceCode,omitempty"`
FunctionConfigPath string `json:"functionConfigPath,omitempty"`
TempDir string `json:"tempDir,omitempty"`
Registry string `json:"registry,omitempty"`
BaseImageRegistry string `json:"baseImageRegistry,omitempty"`
Image string `json:"image,omitempty"`
NoBaseImagesPull bool `json:"noBaseImagesPull,omitempty"`
NoCache bool `json:"noCache,omitempty"`
NoCleanup bool `json:"noCleanup,omitempty"`
BaseImage string `json:"baseImage,omitempty"`
Commands []string `json:"commands,omitempty"`
Directives map[string][]Directive `json:"directives,omitempty"`
ScriptPaths []string `json:"scriptPaths,omitempty"`
AddedObjectPaths map[string]string `json:"addedPaths,omitempty"`
Dependencies []string `json:"dependencies,omitempty"`
OnbuildImage string `json:"onbuildImage,omitempty"`
Offline bool `json:"offline,omitempty"`
RuntimeAttributes map[string]interface{} `json:"runtimeAttributes,omitempty"`
CodeEntryType string `json:"codeEntryType,omitempty"`
CodeEntryAttributes map[string]interface{} `json:"codeEntryAttributes,omitempty"`
Timestamp int64 `json:"timestamp,omitempty"`
BuildTimeoutSeconds *int64 `json:"buildTimeoutSeconds,omitempty"`
Mode BuildMode `json:"mode,omitempty"`
Args map[string]string `json:"args,omitempty"`
Flags []string `json:"flags,omitempty"`
BuilderServiceAccount string `json:"builderServiceAccount,omitempty"`
}
Build holds all configuration parameters related to building a function
type Config ¶
Config holds the configuration of a function - meta and spec
func GetFunctionConfigFromInterface ¶
func GetFunctionConfigFromInterface(functionConfigInterface interface{}) *Config
func (*Config) AddPrevStateAnnotation ¶
func (*Config) AddSkipAnnotations ¶
func (c *Config) AddSkipAnnotations()
func (*Config) CleanFunctionSpec ¶
func (c *Config) CleanFunctionSpec()
func (*Config) EnrichWithNodeSelectors ¶
func (*Config) EnrichWithTolerations ¶
func (c *Config) EnrichWithTolerations(tolerations []v1.Toleration)
func (*Config) GetProjectName ¶
func (*Config) PrepareFunctionForExport ¶
func (c *Config) PrepareFunctionForExport(exportOptions *common.ExportFunctionOptions)
func (*Config) PruneAffinityNodeSelectorRequirement ¶
func (c *Config) PruneAffinityNodeSelectorRequirement(nodeSelectorRequirements []v1.NodeSelectorRequirement, mode string)
PruneAffinityNodeSelectorRequirement prunes given affinity node selector requirement from function spec
func (*Config) PruneNodeSelector ¶
PruneNodeSelector prunes given node selector key from function spec if their key, value are matching
func (*Config) PruneTolerations ¶
func (c *Config) PruneTolerations(tolerations []v1.Toleration)
PruneTolerations prunes given tolerations from function spec
type ConfigWithStatus ¶
type ConfigWithStatus struct {
Config `json:",inline" yaml:",inline"`
Status Status `json:"status,omitempty"`
}
ConfigWithStatus holds the config and status of a function
type DataBinding ¶
type DataBinding struct {
Name string `json:"name,omitempty"`
Class string `json:"class"`
Kind string `json:"kind"`
URL string `json:"url"`
Path string `json:"path,omitempty"`
Query string `json:"query,omitempty"`
Secret string `json:"secret,omitempty"`
Attributes map[string]interface{} `json:"attributes,omitempty"`
}
DataBinding holds configuration for a databinding
type ExplicitAckMode ¶
type ExplicitAckMode string
type FunctionState ¶
type FunctionState string
FunctionState is state of function
const ( FunctionStateWaitingForBuild FunctionState = "waitingForBuild" FunctionStateBuilding FunctionState = "building" FunctionStateWaitingForResourceConfiguration FunctionState = "waitingForResourceConfiguration" FunctionStateWaitingForScaleResourcesFromZero FunctionState = "waitingForScaleResourceFromZero" FunctionStateWaitingForScaleResourcesToZero FunctionState = "waitingForScaleResourceToZero" FunctionStateConfiguringResources FunctionState = "configuringResources" FunctionStateReady FunctionState = "ready" FunctionStateError FunctionState = "error" FunctionStateUnhealthy FunctionState = "unhealthy" FunctionStateScaledToZero FunctionState = "scaledToZero" FunctionStateImported FunctionState = "imported" )
Possible function states
type Ingress ¶
type Ingress struct {
Host string `json:"host,omitempty"`
Paths []string `json:"paths,omitempty"`
PathType networkingv1.PathType `json:"pathType,omitempty"`
TLS IngressTLS `json:"tls,omitempty"`
IngressClassName string `json:"ingressClassName,omitempty"`
}
Ingress holds configuration for an ingress - an entity that can route HTTP requests to the function
type IngressTLS ¶
type IngressTLS struct {
Hosts []string `json:"hosts,omitempty"`
SecretName string `json:"secretName,omitempty"`
}
IngressTLS holds configuration for an ingress's TLS
type LoggerSink ¶
type LoggerSink struct {
Level string `json:"level,omitempty"`
Sink string `json:"sink,omitempty"`
}
LoggerSink overrides the default platform configuration for function loggers
type Meta ¶
type Meta struct {
Name string `json:"name,omitempty"`
Namespace string `json:"namespace,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
// Used to determine whether the object is stale
// more details @ https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions
ResourceVersion string `json:"resourceVersion,omitempty"`
}
Meta identifies a function
func (*Meta) AddSkipBuildAnnotation ¶
func (m *Meta) AddSkipBuildAnnotation()
func (*Meta) AddSkipDeployAnnotation ¶
func (m *Meta) AddSkipDeployAnnotation()
func (*Meta) RemoveSkipBuildAnnotation ¶
func (m *Meta) RemoveSkipBuildAnnotation()
func (*Meta) RemoveSkipDeployAnnotation ¶
func (m *Meta) RemoveSkipDeployAnnotation()
type Partition ¶
type Partition struct {
ID string `json:"id"`
Checkpoint Checkpoint `json:"checkpoint,omitempty"`
}
Partition is a partition information
type Platform ¶
type Platform struct {
Attributes map[string]interface{} `json:"attributes,omitempty"`
}
Platform holds platform specific attributes
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
type RunOnPreemptibleNodeMode ¶
type RunOnPreemptibleNodeMode string
const ( // RunOnPreemptibleNodesAllow makes function pods be able to run on preemptible nodes RunOnPreemptibleNodesAllow RunOnPreemptibleNodeMode = "allow" // RunOnPreemptibleNodesConstrain makes the function pods run on preemtible nodes only RunOnPreemptibleNodesConstrain RunOnPreemptibleNodeMode = "constrain" // RunOnPreemptibleNodesPrevent prevents the function pods from running on preemptible nodes RunOnPreemptibleNodesPrevent RunOnPreemptibleNodeMode = "prevent" // RunOnPreemptibleNodesNone do nothing RunOnPreemptibleNodesNone RunOnPreemptibleNodeMode = "none" )
type ScaleResource ¶
type ScaleToZeroSpec ¶
type ScaleToZeroSpec struct {
ScaleResources []ScaleResource `json:"scaleResources,omitempty"`
}
type ScaleToZeroStatus ¶
type ScaleToZeroStatus struct {
LastScaleEvent scalertypes.ScaleEvent `json:"lastScaleEvent,omitempty"`
LastScaleEventTime *time.Time `json:"lastScaleEventTime,omitempty"`
}
type Scrubber ¶
type Scrubber struct {
*common.AbstractScrubber
}
func NewScrubber ¶
func NewScrubber(parentLogger logger.Logger, sensitiveFields []*regexp.Regexp, kubeClientSet kubernetes.Interface) *Scrubber
NewScrubber returns a new scrubber
func (*Scrubber) ConvertMapToConfig ¶
func (*Scrubber) RestoreFunctionConfig ¶
func (s *Scrubber) RestoreFunctionConfig(ctx context.Context, functionConfig *Config, platformName string) (*Config, error)
RestoreFunctionConfig restores a function config from a secret, in case we're running in a kube platform
type Spec ¶
type Spec struct {
Description string `json:"description,omitempty"`
Disable bool `json:"disable,omitempty"`
Publish bool `json:"publish,omitempty"`
Handler string `json:"handler,omitempty"`
Runtime string `json:"runtime,omitempty"`
Env []v1.EnvVar `json:"env,omitempty"`
EnvFrom []v1.EnvFromSource `json:"envFrom,omitempty"`
Resources v1.ResourceRequirements `json:"resources,omitempty"`
Image string `json:"image,omitempty"`
ImageHash string `json:"imageHash,omitempty"`
Replicas *int `json:"replicas,omitempty"`
MinReplicas *int `json:"minReplicas,omitempty"`
MaxReplicas *int `json:"maxReplicas,omitempty"`
TargetCPU int `json:"targetCPU,omitempty"`
DataBindings map[string]DataBinding `json:"dataBindings,omitempty"`
Triggers map[string]Trigger `json:"triggers,omitempty"`
Volumes []Volume `json:"volumes,omitempty"`
Version int `json:"version,omitempty"`
Alias string `json:"alias,omitempty"`
Build Build `json:"build,omitempty"`
RunRegistry string `json:"runRegistry,omitempty"`
ImagePullSecrets string `json:"imagePullSecrets,omitempty"`
RuntimeAttributes map[string]interface{} `json:"runtimeAttributes,omitempty"`
LoggerSinks []LoggerSink `json:"loggerSinks,omitempty"`
DealerURI string `json:"dealerURI,omitempty"`
Platform Platform `json:"platform,omitempty"`
ReadinessTimeoutSeconds int `json:"readinessTimeoutSeconds,omitempty"`
ServiceType v1.ServiceType `json:"serviceType,omitempty"`
ImagePullPolicy v1.PullPolicy `json:"imagePullPolicy,omitempty"`
SecurityContext *v1.PodSecurityContext `json:"securityContext,omitempty"`
ServiceAccount string `json:"serviceAccount,omitempty"`
ScaleToZero *ScaleToZeroSpec `json:"scaleToZero,omitempty"`
// If set to nil, the value is taken from the platform configuration. When set explicitly in function config, it has a priority
DisableDefaultHTTPTrigger *bool `json:"disableDefaultHTTPTrigger,omitempty"`
// When set to true, the function spec would not be scrubbed
DisableSensitiveFieldsMasking bool `json:"disableSensitiveFieldsMasking,omitempty"`
// Used for local platform functions mounting specific devices
// https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities
// E.g.: /dev/video0:/dev/video0 or /dev/video0:/dev/video0:rwm or /dev/fuse
Devices []string `json:"devices,omitempty"`
// Run function on a particular set of node(s)
// https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/
Affinity *v1.Affinity `json:"affinity,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
NodeName string `json:"nodeName,omitempty"`
// Allow function to run on a node with matching taint
// https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/
Tolerations []v1.Toleration `json:"tolerations,omitempty"`
// Priority and Preemption
PriorityClassName string `json:"priorityClassName,omitempty"`
PreemptionPolicy *v1.PreemptionPolicy `json:"preemptionPolicy,omitempty"`
// How to replace existing function pods with new ones
DeploymentStrategy *appsv1.DeploymentStrategy `json:"deploymentStrategy,omitempty"`
// Use the host's ipc namespace
HostIPC bool `json:"hostIPC,omitempty"`
// Scale function's replica (when min < max replicas) based on given custom metric specs
CustomScalingMetricSpecs []autosv2.MetricSpec `json:"customScalingMetricSpecs,omitempty"`
AutoScaleMetrics []AutoScaleMetric `json:"autoScaleMetrics,omitempty"`
// WaitReadinessTimeoutBeforeFailure is relevant only for k8s platform
// if true - wait the whole ReadinessTimeoutSeconds before marking this function as unhealthy
// otherwise, fail the function instantly when there is indication of deployment failure (e.g. pod stuck on crash
// loop, pod container exited with an error, pod is unschedulable).
// Default: false
WaitReadinessTimeoutBeforeFailure bool `json:"waitReadinessTimeoutBeforeFailure,omitempty"`
// We're letting users write "20s" and not the default marshalled time.Duration
// (Which is in nanoseconds)
EventTimeout string `json:"eventTimeout"`
// PreemptionMode is a mode to allow the user to allow running function pods on preemptible nodes
// When filled, tolerations, node labels, and affinity would be populated correspondingly to
// the platformconfig.PreemptibleNodes values.
PreemptionMode RunOnPreemptibleNodeMode `json:"preemptionMode,omitempty"`
// Sidecars are containers that run alongside the function container in the same pod
// the configuration for each sidecar is the same as k8s containers
Sidecars []*v1.Container `json:"sidecars,omitempty"`
// InitContainers are specialized containers that run before app containers in a Pod
// Init containers can contain utilities or setup scripts not present in an app image
InitContainers []*v1.Container `json:"initContainers,omitempty"`
}
Spec holds all parameters related to a function's configuration
func (*Spec) GetEventTimeout ¶
GetEventTimeout returns the event timeout as time.Duration
func (*Spec) PositiveGPUResourceLimit ¶
PositiveGPUResourceLimit returns whether function requested at least one GPU
type Status ¶
type Status struct {
State FunctionState `json:"state,omitempty"`
Message string `json:"message,omitempty"`
Logs []map[string]interface{} `json:"logs,omitempty"`
ScaleToZero *ScaleToZeroStatus `json:"scaleToZero,omitempty"`
APIGateways []string `json:"apiGateways,omitempty"`
HTTPPort int `json:"httpPort,omitempty"`
// the built and pushed image name, populated by the function operator after the function has been deployed
ContainerImage string `json:"containerImage,omitempty"`
// list of internal urls
// e.g.:
// Kubernetes - [ my-namespace.my-function.svc.cluster.local:8080 ]
// Docker - [ function-container-name:8080 ]
InternalInvocationURLs []string `json:"internalInvocationUrls,omitempty"`
// list of external urls, containing ingresses and external-ip:function-port
// e.g.: [ my-function.some-domain.com/pathA, other-ingress.some-domain.co, 1.2.3.4:3000 ]
ExternalInvocationURLs []string `json:"externalInvocationUrls,omitempty"`
// node selector from function config enriched with project's and platform node selectors
EnrichedNodeSelector map[string]string `json:"enrichedNodeSelector,omitempty"`
}
Status holds the status of the function
func (*Status) DeepCopyInto ¶
DeepCopyInto copies to appease k8s
func (*Status) InvocationURLs ¶
type Trigger ¶
type Trigger struct {
Class string `json:"class"`
Kind string `json:"kind"`
Name string `json:"name"`
Disabled bool `json:"disabled,omitempty"`
NumWorkers int `json:"numWorkers,omitempty"`
URL string `json:"url,omitempty"`
Paths []string `json:"paths,omitempty"`
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
Secret string `json:"secret,omitempty"`
Partitions []Partition `json:"partitions,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
// TODO: move all these params to attributes for kafka trigger
WorkerTerminationTimeout string `json:"workerTerminationTimeout,omitempty"`
WorkerAvailabilityTimeoutMilliseconds *int `json:"workerAvailabilityTimeoutMilliseconds,omitempty"`
WorkerAllocatorName string `json:"workerAllocatorName,omitempty"`
ExplicitAckMode ExplicitAckMode `json:"explicitAckMode,omitempty"`
WaitExplicitAckDuringRebalanceTimeout string `json:"waitExplicitAckDuringRebalanceTimeout,omitempty"`
Batch *BatchConfiguration `json:"batch,omitempty"`
// Dealer Information
TotalTasks int `json:"total_tasks,omitempty"`
MaxTaskAllocation int `json:"max_task_allocation,omitempty"`
// General attributes
Attributes map[string]interface{} `json:"attributes,omitempty"`
Mode TriggerWorkMode `json:"mode,omitempty"`
// Deprecated: MaxWorkers is replaced by NumWorkers, and will be removed in 1.15.x
// TODO: remove in 1.15.x
MaxWorkers int `json:"maxWorkers,omitempty"`
}
Trigger holds configuration for a trigger
func GetDefaultHTTPTrigger ¶
func GetDefaultHTTPTrigger() Trigger
type TriggerWorkMode ¶
type TriggerWorkMode string
const ( SyncTriggerWorkMode TriggerWorkMode = "sync" AsyncTriggerWorkMode TriggerWorkMode = "async" )