UNPKG

@kubernetes-models/fission

Version:
862 lines 392 kB
import { IObjectMeta } from "@kubernetes-models/apimachinery/apis/meta/v1/ObjectMeta"; import { Model, ModelData } from "@kubernetes-models/base"; /** * Function is function runs within environment runtime with given package and secrets/configmaps. */ export interface IFunction { /** * APIVersion defines the versioned schema of this representation of an object. * Servers should convert recognized schemas to the latest internal value, and * may reject unrecognized values. * More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources */ "apiVersion": "fission.io/v1"; /** * Kind is a string value representing the REST resource this object represents. * Servers may infer this from the endpoint the client submits requests to. * Cannot be updated. * In CamelCase. * More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds */ "kind": "Function"; "metadata": IObjectMeta; /** * FunctionSpec describes the contents of the function. */ "spec": { /** * InvokeStrategy is a set of controls which affect how function executes */ "InvokeStrategy": { /** * ExecutionStrategy specifies low-level parameters for function execution, * such as the number of instances. */ "ExecutionStrategy"?: { /** * ExecutorType is the executor type of function used. Defaults to "poolmgr". * * * Available value: * - poolmgr * - newdeploy * - container */ "ExecutorType"?: string; /** * This is only for newdeploy to set up maximum replicas of deployment. */ "MaxScale"?: number; /** * This is only for newdeploy to set up minimum replicas of deployment. */ "MinScale"?: number; /** * This is the timeout setting for executor to wait for pod specialization. */ "SpecializationTimeout"?: number; /** * Deprecated: use hpaMetrics instead. * This is only for executor type newdeploy and container to set up target CPU utilization of HPA. * Applicable for executor type newdeploy and container. */ "TargetCPUPercent"?: number; /** * hpaBehavior is the behavior of HPA when scaling in up/down direction. * Applicable for executor type newdeploy and container. */ "hpaBehavior"?: { /** * scaleDown is scaling policy for scaling Down. * If not set, the default value is to allow to scale down to minReplicas pods, with a * 300 second stabilization window (i.e., the highest recommendation for * the last 300sec is used). */ "scaleDown"?: { /** * policies is a list of potential scaling polices which can be used during scaling. * At least one policy must be specified, otherwise the HPAScalingRules will be discarded as invalid */ "policies"?: Array<{ /** * periodSeconds specifies the window of time for which the policy should hold true. * PeriodSeconds must be greater than zero and less than or equal to 1800 (30 min). */ "periodSeconds": number; /** * type is used to specify the scaling policy. */ "type": string; /** * value contains the amount of change which is permitted by the policy. * It must be greater than zero */ "value": number; }>; /** * selectPolicy is used to specify which policy should be used. * If not set, the default value Max is used. */ "selectPolicy"?: string; /** * stabilizationWindowSeconds is the number of seconds for which past recommendations should be * considered while scaling up or scaling down. * StabilizationWindowSeconds must be greater than or equal to zero and less than or equal to 3600 (one hour). * If not set, use the default values: * - For scale up: 0 (i.e. no stabilization is done). * - For scale down: 300 (i.e. the stabilization window is 300 seconds long). */ "stabilizationWindowSeconds"?: number; }; /** * scaleUp is scaling policy for scaling Up. * If not set, the default value is the higher of: * \* increase no more than 4 pods per 60 seconds * \* double the number of pods per 60 seconds * No stabilization is used. */ "scaleUp"?: { /** * policies is a list of potential scaling polices which can be used during scaling. * At least one policy must be specified, otherwise the HPAScalingRules will be discarded as invalid */ "policies"?: Array<{ /** * periodSeconds specifies the window of time for which the policy should hold true. * PeriodSeconds must be greater than zero and less than or equal to 1800 (30 min). */ "periodSeconds": number; /** * type is used to specify the scaling policy. */ "type": string; /** * value contains the amount of change which is permitted by the policy. * It must be greater than zero */ "value": number; }>; /** * selectPolicy is used to specify which policy should be used. * If not set, the default value Max is used. */ "selectPolicy"?: string; /** * stabilizationWindowSeconds is the number of seconds for which past recommendations should be * considered while scaling up or scaling down. * StabilizationWindowSeconds must be greater than or equal to zero and less than or equal to 3600 (one hour). * If not set, use the default values: * - For scale up: 0 (i.e. no stabilization is done). * - For scale down: 300 (i.e. the stabilization window is 300 seconds long). */ "stabilizationWindowSeconds"?: number; }; }; /** * hpaMetrics is the list of metrics used to determine the desired replica count of the Deployment * created for the function. * Applicable for executor type newdeploy and container. */ "hpaMetrics"?: Array<{ /** * containerResource refers to a resource metric (such as those specified in * requests and limits) known to Kubernetes describing a single container in * each pod of the current scale target (e.g. CPU or memory). Such metrics are * built in to Kubernetes, and have special scaling options on top of those * available to normal per-pod metrics using the "pods" source. * This is an alpha feature and can be enabled by the HPAContainerMetrics feature flag. */ "containerResource"?: { /** * container is the name of the container in the pods of the scaling target */ "container": string; /** * name is the name of the resource in question. */ "name": string; /** * target specifies the target value for the given metric */ "target": { /** * averageUtilization is the target value of the average of the * resource metric across all relevant pods, represented as a percentage of * the requested value of the resource for the pods. * Currently only valid for Resource metric source type */ "averageUtilization"?: number; /** * averageValue is the target value of the average of the * metric across all relevant pods (as a quantity) */ "averageValue"?: number | string; /** * type represents whether the metric type is Utilization, Value, or AverageValue */ "type": string; /** * value is the target value of the metric (as a quantity). */ "value"?: number | string; }; }; /** * external refers to a global metric that is not associated * with any Kubernetes object. It allows autoscaling based on information * coming from components running outside of cluster * (for example length of queue in cloud messaging service, or * QPS from loadbalancer running outside of cluster). */ "external"?: { /** * metric identifies the target metric by name and selector */ "metric": { /** * name is the name of the given metric */ "name": string; /** * selector is the string-encoded form of a standard kubernetes label selector for the given metric * When set, it is passed as an additional parameter to the metrics server for more specific metrics scoping. * When unset, just the metricName will be used to gather metrics. */ "selector"?: { /** * matchExpressions is a list of label selector requirements. The requirements are ANDed. */ "matchExpressions"?: Array<{ /** * key is the label key that the selector applies to. */ "key": string; /** * operator represents a key's relationship to a set of values. * Valid operators are In, NotIn, Exists and DoesNotExist. */ "operator": string; /** * values is an array of string values. If the operator is In or NotIn, * the values array must be non-empty. If the operator is Exists or DoesNotExist, * the values array must be empty. This array is replaced during a strategic * merge patch. */ "values"?: Array<string>; }>; /** * matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels * map is equivalent to an element of matchExpressions, whose key field is "key", the * operator is "In", and the values array contains only "value". The requirements are ANDed. */ "matchLabels"?: { [key: string]: string; }; }; }; /** * target specifies the target value for the given metric */ "target": { /** * averageUtilization is the target value of the average of the * resource metric across all relevant pods, represented as a percentage of * the requested value of the resource for the pods. * Currently only valid for Resource metric source type */ "averageUtilization"?: number; /** * averageValue is the target value of the average of the * metric across all relevant pods (as a quantity) */ "averageValue"?: number | string; /** * type represents whether the metric type is Utilization, Value, or AverageValue */ "type": string; /** * value is the target value of the metric (as a quantity). */ "value"?: number | string; }; }; /** * object refers to a metric describing a single kubernetes object * (for example, hits-per-second on an Ingress object). */ "object"?: { /** * describedObject specifies the descriptions of a object,such as kind,name apiVersion */ "describedObject": { /** * apiVersion is the API version of the referent */ "apiVersion"?: string; /** * kind is the kind of the referent; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds */ "kind": string; /** * name is the name of the referent; More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names */ "name": string; }; /** * metric identifies the target metric by name and selector */ "metric": { /** * name is the name of the given metric */ "name": string; /** * selector is the string-encoded form of a standard kubernetes label selector for the given metric * When set, it is passed as an additional parameter to the metrics server for more specific metrics scoping. * When unset, just the metricName will be used to gather metrics. */ "selector"?: { /** * matchExpressions is a list of label selector requirements. The requirements are ANDed. */ "matchExpressions"?: Array<{ /** * key is the label key that the selector applies to. */ "key": string; /** * operator represents a key's relationship to a set of values. * Valid operators are In, NotIn, Exists and DoesNotExist. */ "operator": string; /** * values is an array of string values. If the operator is In or NotIn, * the values array must be non-empty. If the operator is Exists or DoesNotExist, * the values array must be empty. This array is replaced during a strategic * merge patch. */ "values"?: Array<string>; }>; /** * matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels * map is equivalent to an element of matchExpressions, whose key field is "key", the * operator is "In", and the values array contains only "value". The requirements are ANDed. */ "matchLabels"?: { [key: string]: string; }; }; }; /** * target specifies the target value for the given metric */ "target": { /** * averageUtilization is the target value of the average of the * resource metric across all relevant pods, represented as a percentage of * the requested value of the resource for the pods. * Currently only valid for Resource metric source type */ "averageUtilization"?: number; /** * averageValue is the target value of the average of the * metric across all relevant pods (as a quantity) */ "averageValue"?: number | string; /** * type represents whether the metric type is Utilization, Value, or AverageValue */ "type": string; /** * value is the target value of the metric (as a quantity). */ "value"?: number | string; }; }; /** * pods refers to a metric describing each pod in the current scale target * (for example, transactions-processed-per-second). The values will be * averaged together before being compared to the target value. */ "pods"?: { /** * metric identifies the target metric by name and selector */ "metric": { /** * name is the name of the given metric */ "name": string; /** * selector is the string-encoded form of a standard kubernetes label selector for the given metric * When set, it is passed as an additional parameter to the metrics server for more specific metrics scoping. * When unset, just the metricName will be used to gather metrics. */ "selector"?: { /** * matchExpressions is a list of label selector requirements. The requirements are ANDed. */ "matchExpressions"?: Array<{ /** * key is the label key that the selector applies to. */ "key": string; /** * operator represents a key's relationship to a set of values. * Valid operators are In, NotIn, Exists and DoesNotExist. */ "operator": string; /** * values is an array of string values. If the operator is In or NotIn, * the values array must be non-empty. If the operator is Exists or DoesNotExist, * the values array must be empty. This array is replaced during a strategic * merge patch. */ "values"?: Array<string>; }>; /** * matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels * map is equivalent to an element of matchExpressions, whose key field is "key", the * operator is "In", and the values array contains only "value". The requirements are ANDed. */ "matchLabels"?: { [key: string]: string; }; }; }; /** * target specifies the target value for the given metric */ "target": { /** * averageUtilization is the target value of the average of the * resource metric across all relevant pods, represented as a percentage of * the requested value of the resource for the pods. * Currently only valid for Resource metric source type */ "averageUtilization"?: number; /** * averageValue is the target value of the average of the * metric across all relevant pods (as a quantity) */ "averageValue"?: number | string; /** * type represents whether the metric type is Utilization, Value, or AverageValue */ "type": string; /** * value is the target value of the metric (as a quantity). */ "value"?: number | string; }; }; /** * resource refers to a resource metric (such as those specified in * requests and limits) known to Kubernetes describing each pod in the * current scale target (e.g. CPU or memory). Such metrics are built in to * Kubernetes, and have special scaling options on top of those available * to normal per-pod metrics using the "pods" source. */ "resource"?: { /** * name is the name of the resource in question. */ "name": string; /** * target specifies the target value for the given metric */ "target": { /** * averageUtilization is the target value of the average of the * resource metric across all relevant pods, represented as a percentage of * the requested value of the resource for the pods. * Currently only valid for Resource metric source type */ "averageUtilization"?: number; /** * averageValue is the target value of the average of the * metric across all relevant pods (as a quantity) */ "averageValue"?: number | string; /** * type represents whether the metric type is Utilization, Value, or AverageValue */ "type": string; /** * value is the target value of the metric (as a quantity). */ "value"?: number | string; }; }; /** * type is the type of metric source. It should be one of "ContainerResource", "External", * "Object", "Pods" or "Resource", each mapping to a matching field in the object. * Note: "ContainerResource" type is available on when the feature-gate * HPAContainerMetrics is enabled */ "type": string; }>; }; /** * StrategyType is the strategy type of function. * Now it only supports 'execution'. */ "StrategyType"?: string; }; /** * Maximum number of pods to be specialized which will serve requests * This is optional. If not specified default value will be taken as 500 */ "concurrency"?: number; /** * Reference to a list of configmaps. */ "configmaps"?: Array<{ "name": string; "namespace": string; }>; /** * Environment is the build and runtime environment that this function is * associated with. An Environment with this name should exist, otherwise the * function cannot be invoked. */ "environment": { "name": string; "namespace": string; }; /** * FunctionTimeout provides a maximum amount of duration within which a request for * a particular function execution should be complete. * This is optional. If not specified default value will be taken as 60s */ "functionTimeout"?: number; /** * IdleTimeout specifies the length of time that a function is idle before the * function pod(s) are eligible for deletion. If no traffic to the function * is detected within the idle timeout, the executor will then recycle the * function pod(s) to release resources. */ "idletimeout"?: number; /** * OnceOnly specifies if specialized pod will serve exactly one request in its lifetime and would be garbage collected after serving that one request * This is optional. If not specified default value will be taken as false */ "onceOnly"?: boolean; /** * Reference to a package containing deployment and optionally the source. */ "package": { /** * FunctionName specifies a specific function within the package. This allows * functions to share packages, by having different functions within the same * package. * * * Fission itself does not interpret this path. It is passed verbatim to * build and runtime environments. * * * This is optional: if unspecified, the environment has a default name. */ "functionName"?: string; /** * Package reference */ "packageref"?: { "name"?: string; "namespace"?: string; /** * Including resource version in the reference forces the function to be updated on * package update, making it possible to cache the function based on its metadata. */ "resourceversion"?: string; }; }; /** * Podspec specifies podspec to use for executor type container based functions * Different arguments mentioned for container based function are populated inside a pod. */ "podspec"?: { /** * Optional duration in seconds the pod may be active on the node relative to * StartTime before the system will actively try to mark it failed and kill associated containers. * Value must be a positive integer. */ "activeDeadlineSeconds"?: number; /** * If specified, the pod's scheduling constraints */ "affinity"?: { /** * Describes node affinity scheduling rules for the pod. */ "nodeAffinity"?: { /** * The scheduler will prefer to schedule pods to nodes that satisfy * the affinity expressions specified by this field, but it may choose * a node that violates one or more of the expressions. The node that is * most preferred is the one with the greatest sum of weights, i.e. * for each node that meets all of the scheduling requirements (resource * request, requiredDuringScheduling affinity expressions, etc.), * compute a sum by iterating through the elements of this field and adding * "weight" to the sum if the node matches the corresponding matchExpressions; the * node(s) with the highest sum are the most preferred. */ "preferredDuringSchedulingIgnoredDuringExecution"?: Array<{ /** * A node selector term, associated with the corresponding weight. */ "preference": { /** * A list of node selector requirements by node's labels. */ "matchExpressions"?: Array<{ /** * The label key that the selector applies to. */ "key": string; /** * Represents a key's relationship to a set of values. * Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt. */ "operator": string; /** * An array of string values. If the operator is In or NotIn, * the values array must be non-empty. If the operator is Exists or DoesNotExist, * the values array must be empty. If the operator is Gt or Lt, the values * array must have a single element, which will be interpreted as an integer. * This array is replaced during a strategic merge patch. */ "values"?: Array<string>; }>; /** * A list of node selector requirements by node's fields. */ "matchFields"?: Array<{ /** * The label key that the selector applies to. */ "key": string; /** * Represents a key's relationship to a set of values. * Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt. */ "operator": string; /** * An array of string values. If the operator is In or NotIn, * the values array must be non-empty. If the operator is Exists or DoesNotExist, * the values array must be empty. If the operator is Gt or Lt, the values * array must have a single element, which will be interpreted as an integer. * This array is replaced during a strategic merge patch. */ "values"?: Array<string>; }>; }; /** * Weight associated with matching the corresponding nodeSelectorTerm, in the range 1-100. */ "weight": number; }>; /** * If the affinity requirements specified by this field are not met at * scheduling time, the pod will not be scheduled onto the node. * If the affinity requirements specified by this field cease to be met * at some point during pod execution (e.g. due to an update), the system * may or may not try to eventually evict the pod from its node. */ "requiredDuringSchedulingIgnoredDuringExecution"?: { /** * Required. A list of node selector terms. The terms are ORed. */ "nodeSelectorTerms": Array<{ /** * A list of node selector requirements by node's labels. */ "matchExpressions"?: Array<{ /** * The label key that the selector applies to. */ "key": string; /** * Represents a key's relationship to a set of values. * Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt. */ "operator": string; /** * An array of string values. If the operator is In or NotIn, * the values array must be non-empty. If the operator is Exists or DoesNotExist, * the values array must be empty. If the operator is Gt or Lt, the values * array must have a single element, which will be interpreted as an integer. * This array is replaced during a strategic merge patch. */ "values"?: Array<string>; }>; /** * A list of node selector requirements by node's fields. */ "matchFields"?: Array<{ /** * The label key that the selector applies to. */ "key": string; /** * Represents a key's relationship to a set of values. * Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt. */ "operator": string; /** * An array of string values. If the operator is In or NotIn, * the values array must be non-empty. If the operator is Exists or DoesNotExist, * the values array must be empty. If the operator is Gt or Lt, the values * array must have a single element, which will be interpreted as an integer. * This array is replaced during a strategic merge patch. */ "values"?: Array<string>; }>; }>; }; }; /** * Describes pod affinity scheduling rules (e.g. co-locate this pod in the same node, zone, etc. as some other pod(s)). */ "podAffinity"?: { /** * The scheduler will prefer to schedule pods to nodes that satisfy * the affinity expressions specified by this field, but it may choose * a node that violates one or more of the expressions. The node that is * most preferred is the one with the greatest sum of weights, i.e. * for each node that meets all of the scheduling requirements (resource * request, requiredDuringScheduling affinity expressions, etc.), * compute a sum by iterating through the elements of this field and adding * "weight" to the sum if the node has pods which matches the corresponding podAffinityTerm; the * node(s) with the highest sum are the most preferred. */ "preferredDuringSchedulingIgnoredDuringExecution"?: Array<{ /** * Required. A pod affinity term, associated with the corresponding weight. */ "podAffinityTerm": { /** * A label query over a set of resources, in this case pods. * If it's null, this PodAffinityTerm matches with no Pods. */ "labelSelector"?: { /** * matchExpressions is a list of label selector requirements. The requirements are ANDed. */ "matchExpressions"?: Array<{ /** * key is the label key that the selector applies to. */ "key": string; /** * operator represents a key's relationship to a set of values. * Valid operators are In, NotIn, Exists and DoesNotExist. */ "operator": string; /** * values is an array of string values. If the operator is In or NotIn, * the values array must be non-empty. If the operator is Exists or DoesNotExist, * the values array must be empty. This array is replaced during a strategic * merge patch. */ "values"?: Array<string>; }>; /** * matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels * map is equivalent to an element of matchExpressions, whose key field is "key", the * operator is "In", and the values array contains only "value". The requirements are ANDed. */ "matchLabels"?: { [key: string]: string; }; }; /** * MatchLabelKeys is a set of pod label keys to select which pods will * be taken into consideration. The keys are used to lookup values from the * incoming pod labels, those key-value labels are merged with `LabelSelector` as `key in (value)` * to select the group of existing pods which pods will be taken into consideration * for the incoming pod's pod (anti) affinity. Keys that don't exist in the incoming * pod labels will be ignored. The default value is empty. * The same key is forbidden to exist in both MatchLabelKeys and LabelSelector. * Also, MatchLabelKeys cannot be set when LabelSelector isn't set. * This is an alpha field and requires enabling MatchLabelKeysInPodAffinity feature gate. */ "matchLabelKeys"?: Array<string>; /** * MismatchLabelKeys is a set of pod label keys to select which pods will * be taken into consideration. The keys are used to lookup values from the * incoming pod labels, those key-value labels are merged with `LabelSelector` as `key notin (value)` * to select the group of existing pods which pods will be taken into consideration * for the incoming pod's pod (anti) affinity. Keys that don't exist in the incoming * pod labels will be ignored. The default value is empty. * The same key is forbidden to exist in both MismatchLabelKeys and LabelSelector. * Also, MismatchLabelKeys cannot be set when LabelSelector isn't set. * This is an alpha field and requires enabling MatchLabelKeysInPodAffinity feature gate. */ "mismatchLabelKeys"?: Array<string>; /** * A label query over the set of namespaces that the term applies to. * The term is applied to the union of the namespaces selected by this field * and the ones listed in the namespaces field. * null selector and null or empty namespaces list means "this pod's namespace". * An empty selector ({}) matches all namespaces. */ "namespaceSelector"?: { /** * matchExpressions is a list of label selector requirements. The requirements are ANDed. */ "matchExpressions"?: Array<{ /** * key is the label key that the selector applies to. */ "key": string; /** * operator represents a key's relationship to a set of values. * Valid operators are In, NotIn, Exists and DoesNotExist. */ "operator": string; /** * values is an array of string values. If the operator is In or NotIn, * the values array must be non-empty. If the operator is Exists or DoesNotExist, * the values array must be empty. This array is replaced during a strategic * merge patch. */ "values"?: Array<string>; }>; /** * matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels * map is equivalent to an element of matchExpressions, whose key field is "key", the * operator is "In", and the values array contains only "value". The requirements are ANDed. */ "matchLabels"?: { [key: string]: string; }; }; /** * namespaces specifies a static list of namespace names that the term applies to. * The term is applied to the union of the namespaces listed in this field * and the ones selected by namespaceSelector. * null or empty namespaces list and null namespaceSelector means "this pod's namespace". */ "namespaces"?: Array<string>; /** * This pod should be co-located (affinity) or not co-located (anti-affinity) with the pods matching * the labelSelector in the specified namespaces, where co-located is defined as running on a node * whose value of the label with key topologyKey matches that of any node on which any of the * selected pods is running. * Empty topologyKey is not allowed. */ "topologyKey": string; }; /** * weight associated with matching the corresponding podAffinityTerm, * in the range 1-100. */ "weight": number; }>; /** * If the affinity requirements specified by this field are not met at * scheduling time, the pod will not be scheduled onto the node. * If the affinity requirements specified by this field cease to be met * at some point during pod executio