utils

package
v1.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2021 License: Apache-2.0 Imports: 44 Imported by: 30

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildOutOfClusterConfig

func BuildOutOfClusterConfig() (*rest.Config, error)

BuildOutOfClusterConfig returns k8s config

func CreateAutoscale added in v0.2.3

func CreateAutoscale(client kubernetes.Interface, hpa v2beta1.HorizontalPodAutoscaler) error

CreateAutoscale creates HPA object for function

func CreateFunctionCustomResource added in v0.5.0

func CreateFunctionCustomResource(kubelessClient versioned.Interface, f *kubelessApi.Function) error

CreateFunctionCustomResource will create a custom function object

func CreateServiceMonitor added in v0.3.2

func CreateServiceMonitor(smclient monitoringv1alpha1.MonitoringV1alpha1Client, funcObj *kubelessApi.Function, ns string, or []metav1.OwnerReference) error

CreateServiceMonitor creates a Service Monitor for the given function

func DeleteAutoscale added in v0.2.3

func DeleteAutoscale(client kubernetes.Interface, name, ns string) error

DeleteAutoscale deletes an autoscale rule

func DeleteFunctionCustomResource added in v0.5.0

func DeleteFunctionCustomResource(kubelessClient versioned.Interface, funcName, ns string) error

DeleteFunctionCustomResource will delete custom function object

func DeleteServiceMonitor added in v0.2.3

func DeleteServiceMonitor(smclient monitoringv1alpha1.MonitoringV1alpha1Client, name, ns string) error

DeleteServiceMonitor cleans the sm if it exists

func DryRunFmt added in v1.0.0

func DryRunFmt(format string, trigger interface{}) (string, error)

DryRunFmt stringify the given interface in a specific format

func EnsureFuncConfigMap added in v0.2.4

func EnsureFuncConfigMap(client kubernetes.Interface, funcObj *kubelessApi.Function, or []metav1.OwnerReference, lr *langruntime.Langruntimes) error

EnsureFuncConfigMap creates/updates a config map with a function specification

func EnsureFuncDeployment added in v0.2.4

func EnsureFuncDeployment(client kubernetes.Interface, funcObj *kubelessApi.Function, or []metav1.OwnerReference, lr *langruntime.Langruntimes, prebuiltRuntimeImage, provisionImage string, imagePullSecrets []v1.LocalObjectReference) error

EnsureFuncDeployment creates/updates a function deployment

func EnsureFuncImage added in v0.5.0

func EnsureFuncImage(client kubernetes.Interface, funcObj *kubelessApi.Function, lr *langruntime.Langruntimes, or []metav1.OwnerReference, imageName, tag, builderImage, registryHost, dockerSecretName, provisionImage string, registryTLSEnabled bool, imagePullSecrets []v1.LocalObjectReference) error

EnsureFuncImage creates a Job to build a function image

func EnsureFuncService added in v0.2.4

func EnsureFuncService(client kubernetes.Interface, funcObj *kubelessApi.Function, or []metav1.OwnerReference) error

EnsureFuncService creates/updates a function service

func Exec added in v0.2.4

func Exec(client corev1.CoreV1Interface, pod, namespace string, opts v1.PodExecOptions) (*http.Request, error)

Exec returns an "exec" Request suitable for ExecRoundTripper.

func ExecRoundTripper added in v0.2.4

func ExecRoundTripper(conf *rest.Config, f RoundTripCallback) (http.RoundTripper, error)

ExecRoundTripper creates a wrapped WebsocketRoundTripper

func FunctionObjAddFinalizer added in v0.5.0

func FunctionObjAddFinalizer(kubelessClient versioned.Interface, funcObj *kubelessApi.Function, finalizerString string) error

FunctionObjAddFinalizer add specified finalizer string to function object

func FunctionObjHasFinalizer added in v0.5.0

func FunctionObjHasFinalizer(funcObj *kubelessApi.Function, finalizerString string) bool

FunctionObjHasFinalizer checks if function object already has the Function controller finalizer

func FunctionObjRemoveFinalizer added in v0.5.0

func FunctionObjRemoveFinalizer(kubelessClient versioned.Interface, funcObj *kubelessApi.Function, finalizerString string) error

FunctionObjRemoveFinalizer removes the finalizer from the function object

func GetAPIExtensionsClientInCluster added in v0.5.0

func GetAPIExtensionsClientInCluster() clientsetAPIExtensions.Interface

GetAPIExtensionsClientInCluster returns a k8s clientset to access APIExtensions from inside of cluster

func GetAPIExtensionsClientOutOfCluster added in v0.5.0

func GetAPIExtensionsClientOutOfCluster() clientsetAPIExtensions.Interface

GetAPIExtensionsClientOutOfCluster returns a k8s clientset to access APIExtensions from outside of cluster

func GetAnnotationsFromCRD added in v0.5.0

func GetAnnotationsFromCRD(clientset clientsetAPIExtensions.Interface, name string) (map[string]string, error)

GetAnnotationsFromCRD gets annotations from a CustomResourceDefinition

func GetClient

func GetClient() kubernetes.Interface

GetClient returns a k8s clientset to the request from inside of cluster

func GetClientOutOfCluster

func GetClientOutOfCluster() kubernetes.Interface

GetClientOutOfCluster returns a k8s clientset to the request from outside of cluster

func GetContentType added in v1.0.7

func GetContentType(filename string) (string, error)

GetContentType Gets the content type of a given filename

func GetDefaultNamespace added in v0.3.0

func GetDefaultNamespace() string

GetDefaultNamespace returns the namespace set in current cluster context

func GetFunction

func GetFunction(funcName, ns string) (kubelessApi.Function, error)

GetFunction returns specification of a function

func GetFunctionClientInCluster added in v0.4.0

func GetFunctionClientInCluster() (versioned.Interface, error)

GetFunctionClientInCluster returns function clientset to the request from inside of cluster

func GetFunctionCustomResource added in v0.5.0

func GetFunctionCustomResource(kubelessClient versioned.Interface, funcName, ns string) (*kubelessApi.Function, error)

GetFunctionCustomResource will delete custom function object

func GetFunctionPort added in v1.0.0

func GetFunctionPort(clientset kubernetes.Interface, namespace, functionName string) (string, error)

GetFunctionPort returns the port for a function service

func GetInClusterConfig added in v1.0.0

func GetInClusterConfig() (*rest.Config, error)

GetInClusterConfig returns necessary Config object to authenticate k8s clients if env variable is set

func GetKubelessClientOutCluster added in v0.5.0

func GetKubelessClientOutCluster() (versioned.Interface, error)

GetKubelessClientOutCluster returns kubeless clientset to make kubeless API request from outside of cluster

func GetKubelessConfig added in v1.0.0

func GetKubelessConfig(cli kubernetes.Interface, cliAPIExtensions clientsetAPIExtensions.Interface) (*v1.ConfigMap, error)

GetKubelessConfig Returns Kubeless ConfigMap

func GetLocalHostname

func GetLocalHostname(config *rest.Config, funcName string) (string, error)

GetLocalHostname returns hostname

func GetOwnerReference added in v0.3.1

func GetOwnerReference(kind, apiVersion, name string, uid types.UID) ([]metav1.OwnerReference, error)

GetOwnerReference returns ownerRef for appending to objects's metadata

func GetPodsByLabel

func GetPodsByLabel(c kubernetes.Interface, ns, k, v string) (*v1.PodList, error)

GetPodsByLabel returns list of pods which match the label We use this to returns pods to which the function is deployed or pods running controllers

func GetRandString added in v0.5.0

func GetRandString(n int) (string, error)

GetRandString returns a random string of lenght N

func GetReadyPod

func GetReadyPod(pods *v1.PodList) (v1.Pod, error)

GetReadyPod returns the first pod has passed the liveness probe check

func GetSecretsAsLocalObjectReference added in v1.0.0

func GetSecretsAsLocalObjectReference(secrets ...string) []v1.LocalObjectReference

GetSecretsAsLocalObjectReference returns a list of LocalObjectReference based on secret names

func IsJSON added in v0.6.0

func IsJSON(s string) bool

IsJSON returns true if the string is json

func MergeDeployments added in v0.4.0

func MergeDeployments(destinationDeployment *appsv1.Deployment, sourceDeployment *appsv1.Deployment) error

MergeDeployments merges two deployment objects

func ParseContent added in v1.0.7

func ParseContent(file, contentType string) (string, string, error)

ParseContent Parses the content of a file as string

func PatchFunctionCustomResource added in v0.5.0

func PatchFunctionCustomResource(kubelessClient versioned.Interface, f *kubelessApi.Function) error

PatchFunctionCustomResource applies changes to the function custom object

func UpdateAutoscale added in v1.0.7

func UpdateAutoscale(client kubernetes.Interface, hpa v2beta1.HorizontalPodAutoscaler) error

UpdateAutoscale updates an existing HPA object for a function

func UpdateFunctionCustomResource added in v0.5.0

func UpdateFunctionCustomResource(kubelessClient versioned.Interface, f *kubelessApi.Function) error

UpdateFunctionCustomResource applies changes to the function custom object

Types

type Cmd added in v0.2.4

type Cmd struct {
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
}

Cmd stores information relevant to an individual remote command being run

func (*Cmd) RoundTripCallback added in v0.2.4

func (c *Cmd) RoundTripCallback(conn *websocket.Conn) (*http.Response, error)

RoundTripCallback is suitable to use with `ExecRoundTripper` and will copy data to/from stdio channels. The returned `Response` is currently always `nil`.

type ConfigLocation added in v0.5.0

type ConfigLocation struct {
	Name      string
	Namespace string
}

ConfigLocation is a struct to store the location of kubeless configuration specific ConfigMap

type Metric added in v1.0.0

type Metric struct {
	FunctionName         string  `json:"function,omitempty"`
	Namespace            string  `json:"namespace,omitempty"`
	Method               string  `json:"method,omitempty"`
	Message              string  `json:"message,omitempty"`
	TotalCalls           float64 `json:"total_calls,omitempty"`
	TotalFailures        float64 `json:"total_failures,omitempty"`
	TotalDurationSeconds float64 `json:"total_duration_seconds,omitempty"`
	AvgDurationSeconds   float64 `json:"avg_duration_seconds,omitempty"`
}

Metric contains metrics for a functions

func GetFunctionMetrics added in v1.0.0

func GetFunctionMetrics(apiV1Client kubernetes.Interface, h MetricsRetriever, namespace, functionName string) []*Metric

GetFunctionMetrics returns Prometheus metrics as a slice of *Metrics

type MetricsRetriever added in v1.0.0

type MetricsRetriever interface {
	GetRawMetrics(kubernetes.Interface, string, string) ([]byte, error)
}

MetricsRetriever is an interface for retreiving metrics from an endpoint

type PrometheusMetricsHandler added in v1.0.0

type PrometheusMetricsHandler struct{}

PrometheusMetricsHandler is a handler for retreiving metrics from Prometheus

func (*PrometheusMetricsHandler) GetRawMetrics added in v1.0.0

func (h *PrometheusMetricsHandler) GetRawMetrics(apiV1Client kubernetes.Interface, namespace, functionName string) ([]byte, error)

GetRawMetrics returns the raw metrics for a Prometheus endpoint

type RoundTripCallback added in v0.2.4

type RoundTripCallback func(conn *websocket.Conn) (*http.Response, error)

A RoundTripCallback is used to process the websocket from an individual command execution.

type WebsocketRoundTripper added in v0.2.4

type WebsocketRoundTripper struct {
	TLSConfig *tls.Config
	Do        RoundTripCallback
}

WebsocketRoundTripper is an http.RoundTripper that invokes a callback on a websocket connection.

func (*WebsocketRoundTripper) RoundTrip added in v0.2.4

func (d *WebsocketRoundTripper) RoundTrip(r *http.Request) (*http.Response, error)

RoundTrip implements the http.RoundTripper interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL