Documentation
¶
Index ¶
- Constants
- Variables
- func GenerateCommonAnnotations(f fn.Function, decorator DeployDecorator, daprInstalled bool, ...) map[string]string
- func GenerateCommonLabels(f fn.Function, decorator DeployDecorator) (map[string]string, error)
- func GenerateDaprAnnotations(appID string) map[string]string
- func IdentityAnnotations(deployerName string) map[string]string
- func IdentityLabels(name, runtime string) map[string]string
- func SelectorLabels(ll map[string]string) map[string]string
- type DeployDecorator
- type Exposer
- type Exposure
- type ExposureRef
Constants ¶
const ( DeployerNameAnnotation = "function.knative.dev/deployer" // DomainLabel records the custom domain a function was deployed with. // On a Route it is the domain spec.host was built from, which ensure() // compares to detect a domain change (host updates are permission-gated, // so a change means recreating the Route). DomainLabel = "func.domain" // Dapr constants DaprEnabled = "true" DaprMetricsPort = "9092" DaprEnableAPILogging = "true" )
Variables ¶
var ErrExposureNotVisible = errors.New("cannot determine whether an exposing object exists")
ErrExposureNotVisible means the Exposer could not tell whether an exposing object exists, not that none does. Denial is the usual cause: an account with no rights in the object's namespace gets the same answer either way.
The two need opposite handling. A caller removing what the user asked to remove must not report success on this; a caller reconciling a function that never mentioned exposure must not fail on it.
Functions ¶
func GenerateCommonAnnotations ¶
func GenerateCommonAnnotations(f fn.Function, decorator DeployDecorator, daprInstalled bool, deployerName string) map[string]string
GenerateCommonAnnotations creates annotations common to both Knative and K8s deployments
func GenerateCommonLabels ¶
GenerateCommonLabels is identity plus user labels, domain, and decorator. Identity keys win over the same keys in func.yaml.
func GenerateDaprAnnotations ¶
GenerateDaprAnnotations generates annotations for Dapr support These annotations, if included and Dapr control plane is installed in the target cluster, will result in a sidecar exposing the Dapr HTTP API on localhost:3500 and metrics on 9092
func IdentityAnnotations ¶ added in v0.51.0
IdentityAnnotations is the ownership stamp on annotations: function.knative.dev/deployer. Empty deployerName yields an empty map.
func IdentityLabels ¶ added in v0.51.0
IdentityLabels are the find/ownership stamp every object this deploy writes carries: the func marker, the function's name, and its runtime.
func SelectorLabels ¶ added in v0.51.0
SelectorLabels is the subset of ll that may be a pod selector: identity only. Deployment.spec.selector is immutable, so it may only carry values fixed for the lifetime of the function. Domain, user labels, and decorator labels stay on object metadata and the pod template, where they can change on redeploy. Older Deployments that pinned the full map keep that live selector via preserveDeploymentSelector.
Types ¶
type DeployDecorator ¶
type DeployDecorator interface {
UpdateAnnotations(fn.Function, map[string]string) map[string]string
UpdateLabels(fn.Function, map[string]string) map[string]string
}
DeployDecorator is an interface for customizing deployment metadata
type Exposer ¶ added in v0.51.0
type Exposer interface {
// Expose creates or updates the exposing object and returns the hostname
// a router admitted it at, waiting for that admission.
Expose(ctx context.Context, client dynamic.Interface, e Exposure) (host string, err error)
// Unexpose removes the object belonging to ref's function. It takes a
// ref, not a name, so it removes the object func labelled and leaves
// anything else alone. Finding nothing to remove is success.
Unexpose(ctx context.Context, client dynamic.Interface, ref ExposureRef) error
}
Exposer gives a function an address reachable from outside the cluster, one implementation per mechanism. A deployer with no Exposer leaves its functions cluster-local, which is the default.
The dynamic client is a parameter, not a field: constructing an Exposer must not need a kubeconfig, because every command builds the deployer, including those that never reach a cluster.
type Exposure ¶ added in v0.51.0
type Exposure struct {
// Name of the function being exposed: the identity for lookup, like
// FunctionNamespace.
FunctionName string
// Where the function is deployed, which is not always where its exposing
// object goes. See ExposureRef.
FunctionNamespace string
// Name of the exposing object, not always the function's. Where one
// namespace collects every function's objects it must carry the function's
// namespace too, or same-named functions collide. Creation uses it; lookup
// goes by label.
Name string
// Namespace holds the exposing object. See ExposureRef.
Namespace string
// TargetService is the Service to send traffic to, TargetPort the port name
// on it. The raw deployer targets the function's own Service on "http";
// keda targets the interceptor on "proxy".
TargetService string
TargetPort string
// Owner is deleted together with the exposing object. Nil where the two
// cannot be linked, since Kubernetes rejects an owner reference across
// namespaces, which obliges the caller to Unexpose by hand.
Owner *metav1.OwnerReference
Labels map[string]string
Annotations map[string]string
}
Exposure describes the external address wanted for one function: which Service to send traffic to, and what to name the object that does it. Labels and Annotations are the stamps the deployer already built; the exposer does not see fn.Function.
func (Exposure) Ref ¶ added in v0.51.0
func (e Exposure) Ref() ExposureRef
Ref is what identifies this Exposure's object on the cluster, as opposed to what describes how to build it.
type ExposureRef ¶ added in v0.51.0
type ExposureRef struct {
// Both are needed: where one namespace collects every function's objects,
// the name alone cannot separate two functions of the same name.
FunctionName string
FunctionNamespace string
// Namespace holds the exposing object, not always the function's own:
// keda targets the interceptor Service in the operator's namespace, and an
// exposing object can only target a Service beside it.
Namespace string
}
ExposureRef identifies one function's exposing object without describing how to build it. Teardown needs only this, and finds the object by the labels these fields become: func looks for the object it labelled, not for whatever sits at a name it would have chosen.
func NewExposureRef ¶ added in v0.51.0
func NewExposureRef(functionName, functionNamespace, namespace string) ExposureRef
NewExposureRef is the identity of one function's exposing object: the function's name and namespace, and the namespace holding the object.